arr-init: fix bazarr API endpoint and update test

This commit is contained in:
2026-02-19 22:43:27 -05:00
parent 8ced6a530c
commit 1facd8a764
2 changed files with 80 additions and 13 deletions

View File

@@ -124,6 +124,11 @@ testPkgs.testers.runNixOSTest {
enable = true;
};
services.bazarr = {
enable = true;
listenPort = 6767;
};
services.arrInit.sonarr = {
enable = true;
serviceName = "sonarr";
@@ -217,6 +222,24 @@ testPkgs.testers.runNixOSTest {
}
];
};
services.bazarrInit = {
enable = true;
dataDir = "/var/lib/bazarr";
port = 6767;
sonarr = {
enable = true;
dataDir = "/var/lib/sonarr/.config/NzbDrone";
port = 8989;
serviceName = "sonarr";
};
radarr = {
enable = true;
dataDir = "/var/lib/radarr/.config/Radarr";
port = 7878;
serviceName = "radarr";
};
};
};
testScript = ''
@@ -228,6 +251,7 @@ testPkgs.testers.runNixOSTest {
machine.wait_for_unit("sonarr.service")
machine.wait_for_unit("radarr.service")
machine.wait_for_unit("prowlarr.service")
machine.wait_for_unit("bazarr.service")
# Wait for Sonarr API to be ready (config.xml is auto-generated on first start)
machine.wait_until_succeeds(
@@ -350,5 +374,46 @@ testPkgs.testers.runNixOSTest {
"jq '. | length'"
).strip()
assert result == "2", f"Expected 2 Prowlarr synced apps, got {result}"
# Wait for Bazarr to generate config.yaml
machine.wait_until_succeeds(
"test -f /var/lib/bazarr/config/config.yaml",
timeout=120,
)
# Wait for Bazarr API to be ready
machine.wait_until_succeeds(
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
"curl -sf http://localhost:6767/api/system/status -H \"X-API-KEY: $API_KEY\"",
timeout=120,
)
# Restart bazarr-init now that config.yaml exists
machine.succeed("systemctl restart bazarr-init.service")
machine.wait_for_unit("bazarr-init.service")
# Verify Sonarr provider configured in Bazarr
machine.succeed(
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
"curl -sf http://localhost:6767/api/system/settings -H \"X-API-KEY: $API_KEY\" | "
"jq -e '.general.use_sonarr == true and (.sonarr.apikey // \"\") != \"\"'"
)
# Verify Radarr provider configured in Bazarr
machine.succeed(
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
"curl -sf http://localhost:6767/api/system/settings -H \"X-API-KEY: $API_KEY\" | "
"jq -e '.general.use_radarr == true and (.radarr.apikey // \"\") != \"\"'"
)
# Idempotency: restart bazarr-init and verify no duplicate config
machine.succeed("systemctl restart bazarr-init.service")
machine.wait_for_unit("bazarr-init.service")
machine.succeed(
"API_KEY=$(awk '/^auth:/{f=1} f && /apikey:/{gsub(/.*apikey: /, \"\"); print; exit}' /var/lib/bazarr/config/config.yaml) && "
"curl -sf http://localhost:6767/api/system/settings -H \"X-API-KEY: $API_KEY\" | "
"jq -e '.general.use_sonarr == true and (.sonarr.apikey // \"\") != \"\"'"
)
'';
}