nixos/tests/prowlarr: add subtest for dataDir migration

This commit is contained in:
Marie Ramlow 2025-05-24 15:27:10 +02:00
parent 97557de1e2
commit 71d5f0f591
2 changed files with 32 additions and 14 deletions

View file

@ -1125,7 +1125,7 @@ in
prosody = handleTest ./xmpp/prosody.nix { }; prosody = handleTest ./xmpp/prosody.nix { };
prosody-mysql = handleTest ./xmpp/prosody-mysql.nix { }; prosody-mysql = handleTest ./xmpp/prosody-mysql.nix { };
proxy = handleTest ./proxy.nix { }; proxy = handleTest ./proxy.nix { };
prowlarr = handleTest ./prowlarr.nix { }; prowlarr = runTest ./prowlarr.nix;
pt2-clone = handleTest ./pt2-clone.nix { }; pt2-clone = handleTest ./pt2-clone.nix { };
pykms = handleTest ./pykms.nix { }; pykms = handleTest ./pykms.nix { };
public-inbox = handleTest ./public-inbox.nix { }; public-inbox = handleTest ./public-inbox.nix { };

View file

@ -1,22 +1,40 @@
import ./make-test-python.nix ( { lib, config, ... }:
{ lib, ... }:
{ {
name = "prowlarr"; name = "prowlarr";
meta.maintainers = with lib.maintainers; [ ]; meta.maintainers = with lib.maintainers; [ ];
nodes.machine = nodes.machine =
{ pkgs, ... }: { pkgs, ... }:
{ {
services.prowlarr.enable = true; services.prowlarr.enable = true;
specialisation.customDataDir = {
inheritParentConfig = true;
configuration.services.prowlarr.dataDir = "/srv/prowlarr";
}; };
};
testScript = '' testScript = ''
def verify_prowlarr_works():
machine.wait_for_unit("prowlarr.service") machine.wait_for_unit("prowlarr.service")
machine.wait_for_open_port(9696) machine.wait_for_open_port(9696)
response = machine.succeed("curl --fail http://localhost:9696/") response = machine.succeed("curl --fail http://localhost:9696/")
assert '<title>Prowlarr</title>' in response, "Login page didn't load successfully" assert '<title>Prowlarr</title>' in response, "Login page didn't load successfully"
machine.succeed("[ -d /var/lib/prowlarr ]") machine.succeed("[ -d /var/lib/prowlarr ]")
'';
} with subtest("Prowlarr starts and responds to requests"):
) verify_prowlarr_works()
with subtest("Prowlarr data directory migration works"):
machine.systemctl("stop prowlarr.service")
machine.succeed("mkdir -p /tmp/prowlarr-migration")
machine.succeed("mv /var/lib/prowlarr/* /tmp/prowlarr-migration")
machine.succeed("${config.nodes.machine.system.build.toplevel}/specialisation/customDataDir/bin/switch-to-configuration test")
machine.wait_for_unit("var-lib-private-prowlarr.mount")
machine.succeed("mv /tmp/prowlarr-migration/* /var/lib/prowlarr")
machine.systemctl("restart prowlarr.service")
# Check that we're using a bind mount when using a non-default dataDir
machine.succeed("findmnt /var/lib/private/prowlarr | grep /srv/prowlarr")
verify_prowlarr_works()
'';
}