mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 08:53:21 +00:00
nixosTests.forgejo: test backup/dump service
This should allow us to catch issues regarding that in the future. nixos/gitea had an issue with the dump service recently, which didn't affect us, fortunately. But to be fair, it only affected non-default-y setups. Not something we are able to catch in the current, rather simple, config of our test. Still, I see a lot of value adding this new subtest to our test suite. Anyhow, this patch also exposes the resulting tarball as test (build) output, which is a nice addition IMHO, as it allows some sort of external sanity-check, if needed, without running the test interactive.
This commit is contained in:
parent
9dc9be256d
commit
6431fec2c4
@ -37,7 +37,7 @@ let
|
|||||||
settings."repository.signing".SIGNING_KEY = signingPrivateKeyId;
|
settings."repository.signing".SIGNING_KEY = signingPrivateKeyId;
|
||||||
settings.actions.ENABLED = true;
|
settings.actions.ENABLED = true;
|
||||||
};
|
};
|
||||||
environment.systemPackages = [ config.services.forgejo.package pkgs.gnupg pkgs.jq ];
|
environment.systemPackages = [ config.services.forgejo.package pkgs.gnupg pkgs.jq pkgs.file ];
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
|
|
||||||
specialisation.runner = {
|
specialisation.runner = {
|
||||||
@ -53,6 +53,14 @@ let
|
|||||||
tokenFile = "/var/lib/forgejo/runner_token";
|
tokenFile = "/var/lib/forgejo/runner_token";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
specialisation.dump = {
|
||||||
|
inheritParentConfig = true;
|
||||||
|
configuration.services.forgejo.dump = {
|
||||||
|
enable = true;
|
||||||
|
type = "tar.zst";
|
||||||
|
file = "dump.tar.zst";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
client1 = { config, pkgs, ... }: {
|
client1 = { config, pkgs, ... }: {
|
||||||
environment.systemPackages = [ pkgs.git ];
|
environment.systemPackages = [ pkgs.git ];
|
||||||
@ -66,6 +74,7 @@ let
|
|||||||
let
|
let
|
||||||
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
|
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
|
||||||
serverSystem = nodes.server.system.build.toplevel;
|
serverSystem = nodes.server.system.build.toplevel;
|
||||||
|
dumpFile = with nodes.server.specialisation.dump.configuration.services.forgejo.dump; "${backupDir}/${file}";
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
GIT_SSH_COMMAND = "ssh -i $HOME/.ssh/privk -o StrictHostKeyChecking=no"
|
GIT_SSH_COMMAND = "ssh -i $HOME/.ssh/privk -o StrictHostKeyChecking=no"
|
||||||
@ -150,6 +159,12 @@ let
|
|||||||
server.succeed("${serverSystem}/specialisation/runner/bin/switch-to-configuration test")
|
server.succeed("${serverSystem}/specialisation/runner/bin/switch-to-configuration test")
|
||||||
server.wait_for_unit("gitea-runner-test.service")
|
server.wait_for_unit("gitea-runner-test.service")
|
||||||
server.succeed("journalctl -o cat -u gitea-runner-test.service | grep -q 'Runner registered successfully'")
|
server.succeed("journalctl -o cat -u gitea-runner-test.service | grep -q 'Runner registered successfully'")
|
||||||
|
|
||||||
|
with subtest("Testing backup service"):
|
||||||
|
server.succeed("${serverSystem}/specialisation/dump/bin/switch-to-configuration test")
|
||||||
|
server.systemctl("start forgejo-dump")
|
||||||
|
assert "Zstandard compressed data" in server.succeed("file ${dumpFile}")
|
||||||
|
server.copy_from_vm("${dumpFile}")
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user