106 lines
3.1 KiB
Nix
106 lines
3.1 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
self,
|
|
}:
|
|
|
|
pkgs.testers.runNixOSTest {
|
|
name = "arr-init-error-handling";
|
|
|
|
nodes.machine =
|
|
{ pkgs, lib, ... }:
|
|
{
|
|
imports = [ self.nixosModules.default ];
|
|
|
|
system.stateVersion = "24.11";
|
|
|
|
virtualisation.memorySize = 2048;
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
curl
|
|
jq
|
|
gnugrep
|
|
];
|
|
|
|
# Configure arrInit for a service that doesn't exist
|
|
# The dataDir points to a non-existent config.xml
|
|
services.arrInit.sonarr = {
|
|
enable = true;
|
|
serviceName = "sonarr";
|
|
dataDir = "/var/lib/nonexistent";
|
|
port = 8989;
|
|
downloadClients = [
|
|
{
|
|
name = "qBittorrent";
|
|
implementation = "QBittorrent";
|
|
configContract = "QBittorrentSettings";
|
|
protocol = "torrent";
|
|
fields = {
|
|
host = "127.0.0.1";
|
|
port = 6011;
|
|
useSsl = false;
|
|
};
|
|
}
|
|
];
|
|
rootFolders = [ "/media/tv" ];
|
|
};
|
|
|
|
# Also test bazarrInit with missing config
|
|
services.bazarrInit = {
|
|
enable = true;
|
|
dataDir = "/var/lib/nonexistent-bazarr";
|
|
port = 6767;
|
|
sonarr = {
|
|
enable = true;
|
|
dataDir = "/var/lib/nonexistent";
|
|
port = 8989;
|
|
serviceName = "sonarr";
|
|
};
|
|
};
|
|
|
|
# Override service dependencies since we're testing without real services
|
|
systemd.services.sonarr-init = {
|
|
requires = lib.mkForce [ ];
|
|
after = lib.mkForce [ ];
|
|
};
|
|
systemd.services.bazarr-init = {
|
|
requires = lib.mkForce [ ];
|
|
after = lib.mkForce [ ];
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
# Trigger sonarr-init service - it should exit gracefully
|
|
# because config.xml doesn't exist
|
|
machine.succeed("systemctl start sonarr-init.service || true")
|
|
machine.wait_for_unit("sonarr-init.service")
|
|
|
|
# Verify the service exited with ExitCode=0 (success)
|
|
# The module exits 0 when config.xml is missing
|
|
exit_code = machine.succeed(
|
|
"systemctl show sonarr-init.service --property=ExecMainStatus | cut -d= -f2"
|
|
).strip()
|
|
assert exit_code == "0", f"Expected ExitCode 0 for missing config.xml, got {exit_code}"
|
|
|
|
# Check journal for the skipping message
|
|
journal = machine.succeed("journalctl -u sonarr-init.service --no-pager")
|
|
assert "skipping" in journal.lower(), f"Expected 'skipping' message in journal, got: {journal}"
|
|
|
|
# Trigger bazarr-init service - it should also exit gracefully
|
|
machine.succeed("systemctl start bazarr-init.service || true")
|
|
machine.wait_for_unit("bazarr-init.service")
|
|
|
|
# Verify bazarr-init also exited with ExitCode=0
|
|
exit_code = machine.succeed(
|
|
"systemctl show bazarr-init.service --property=ExecMainStatus | cut -d= -f2"
|
|
).strip()
|
|
assert exit_code == "0", f"Expected ExitCode 0 for missing config.yaml, got {exit_code}"
|
|
|
|
# Check journal for the skipping message
|
|
journal = machine.succeed("journalctl -u bazarr-init.service --no-pager")
|
|
assert "skipping" in journal.lower(), f"Expected 'skipping' message in journal, got: {journal}"
|
|
'';
|
|
}
|