From 6431fec2c4757522ce9fe2e173a088012e206ac2 Mon Sep 17 00:00:00 2001 From: emilylange Date: Tue, 24 Oct 2023 02:32:56 +0200 Subject: [PATCH] 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. --- nixos/tests/forgejo.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nixos/tests/forgejo.nix b/nixos/tests/forgejo.nix index b326819e3190..0f7e1585f3d3 100644 --- a/nixos/tests/forgejo.nix +++ b/nixos/tests/forgejo.nix @@ -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