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:
emilylange 2023-10-24 02:32:56 +02:00
parent 9dc9be256d
commit 6431fec2c4
No known key found for this signature in database
GPG Key ID: 0AD773CE46FD0F87

View File

@ -37,7 +37,7 @@ let
settings."repository.signing".SIGNING_KEY = signingPrivateKeyId;
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;
specialisation.runner = {
@ -53,6 +53,14 @@ let
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, ... }: {
environment.systemPackages = [ pkgs.git ];
@ -66,6 +74,7 @@ let
let
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
serverSystem = nodes.server.system.build.toplevel;
dumpFile = with nodes.server.specialisation.dump.configuration.services.forgejo.dump; "${backupDir}/${file}";
in
''
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.wait_for_unit("gitea-runner-test.service")
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