|
2 | 2 | system ? builtins.currentSystem, |
3 | 3 | pkgs ? import <nixpkgs> {inherit system;}, |
4 | 4 | nixosModules, |
5 | | -}: |
6 | | -pkgs.testers.runNixOSTest { |
7 | | - name = "lidarr-basic-test"; |
8 | | - |
9 | | - nodes.machine = { |
10 | | - config, |
11 | | - pkgs, |
12 | | - ... |
13 | | - }: { |
14 | | - imports = [nixosModules]; |
| 5 | +}: let |
| 6 | + pkgsUnfree = import pkgs.path { |
| 7 | + inherit system; |
| 8 | + config.allowUnfree = true; |
| 9 | + }; |
| 10 | +in |
| 11 | + pkgsUnfree.testers.runNixOSTest { |
| 12 | + name = "lidarr-basic-test"; |
15 | 13 |
|
16 | | - nixflix = { |
17 | | - enable = true; |
| 14 | + nodes.machine = { |
| 15 | + config, |
| 16 | + pkgs, |
| 17 | + ... |
| 18 | + }: { |
| 19 | + imports = [nixosModules]; |
18 | 20 |
|
19 | | - lidarr = { |
| 21 | + nixflix = { |
20 | 22 | enable = true; |
21 | | - user = "testuser"; |
22 | | - mediaDirs = [ |
23 | | - {dir = "/media/music";} |
24 | | - ]; |
25 | | - config = { |
26 | | - hostConfig = { |
27 | | - port = 8686; |
28 | | - username = "admin"; |
29 | | - passwordPath = "${pkgs.writeText "lidarr-password" "testpassword123"}"; |
| 23 | + |
| 24 | + lidarr = { |
| 25 | + enable = true; |
| 26 | + user = "testuser"; |
| 27 | + mediaDirs = [ |
| 28 | + {dir = "/media/music";} |
| 29 | + ]; |
| 30 | + config = { |
| 31 | + hostConfig = { |
| 32 | + port = 8686; |
| 33 | + username = "admin"; |
| 34 | + passwordPath = "${pkgs.writeText "lidarr-password" "testpassword123"}"; |
| 35 | + }; |
| 36 | + apiKeyPath = "${pkgs.writeText "lidarr-apikey" "5678efgh5678efgh5678efgh5678efgh"}"; |
| 37 | + }; |
| 38 | + }; |
| 39 | + |
| 40 | + sabnzbd = { |
| 41 | + enable = true; |
| 42 | + apiKeyPath = "${pkgs.writeText "sabnzbd-apikey" "sabnzbd555555555555555555555555555"}"; |
| 43 | + nzbKeyPath = "${pkgs.writeText "sabnzbd-nzbkey" "sabnzbdnzb666666666666666666666"}"; |
| 44 | + settings = { |
| 45 | + port = 8080; |
| 46 | + host = "127.0.0.1"; |
| 47 | + url_base = "/sabnzbd"; |
30 | 48 | }; |
31 | | - apiKeyPath = "${pkgs.writeText "lidarr-apikey" "5678efgh5678efgh5678efgh5678efgh"}"; |
32 | 49 | }; |
33 | 50 | }; |
34 | 51 | }; |
35 | | - }; |
36 | 52 |
|
37 | | - testScript = '' |
38 | | - start_all() |
| 53 | + testScript = '' |
| 54 | + start_all() |
| 55 | +
|
| 56 | + # Wait for services to start |
| 57 | + machine.wait_for_unit("lidarr.service", timeout=60) |
| 58 | + machine.wait_for_unit("sabnzbd.service", timeout=60) |
| 59 | + machine.wait_for_open_port(8686, timeout=60) |
| 60 | + machine.wait_for_open_port(8080, timeout=60) |
| 61 | +
|
| 62 | + # Wait for configuration services to complete |
| 63 | + machine.wait_for_unit("sabnzbd-config.service", timeout=60) |
| 64 | + machine.wait_for_unit("lidarr-config.service", timeout=180) |
39 | 65 |
|
40 | | - machine.wait_for_unit("lidarr.service", timeout=60) |
41 | | - machine.wait_for_open_port(8686, timeout=60) |
42 | | - machine.wait_for_unit("lidarr-config.service", timeout=60) |
| 66 | + # Wait for lidarr to come back up after restart |
| 67 | + machine.wait_for_unit("lidarr.service", timeout=60) |
| 68 | + machine.wait_for_open_port(8686, timeout=60) |
43 | 69 |
|
44 | | - # Wait for lidarr to come back up after restart |
45 | | - machine.wait_for_unit("lidarr.service", timeout=60) |
46 | | - machine.wait_for_open_port(8686, timeout=60) |
| 70 | + # Test API connectivity |
| 71 | + machine.succeed( |
| 72 | + "curl -f -H 'X-Api-Key: 5678efgh5678efgh5678efgh5678efgh' " |
| 73 | + "http://127.0.0.1:8686/api/v1/system/status" |
| 74 | + ) |
47 | 75 |
|
48 | | - # Test API connectivity |
49 | | - machine.succeed( |
50 | | - "curl -f -H 'X-Api-Key: 5678efgh5678efgh5678efgh5678efgh' " |
51 | | - "http://127.0.0.1:8686/api/v1/system/status" |
52 | | - ) |
| 76 | + # Wait for root folders and download clients services |
| 77 | + machine.wait_for_unit("lidarr-rootfolders.service", timeout=60) |
| 78 | + machine.wait_for_unit("lidarr-downloadclients.service", timeout=60) |
53 | 79 |
|
54 | | - # Wait for root folders service |
55 | | - machine.wait_for_unit("lidarr-rootfolders.service", timeout=60) |
| 80 | + # Check root folder |
| 81 | + folders = machine.succeed( |
| 82 | + "curl -s -H 'X-Api-Key: 5678efgh5678efgh5678efgh5678efgh' " |
| 83 | + "http://127.0.0.1:8686/api/v1/rootfolder" |
| 84 | + ) |
| 85 | + print(f"Root folders: {folders}") |
| 86 | + assert "/media/music" in folders, "Root folder not created" |
56 | 87 |
|
57 | | - # Check root folder |
58 | | - folders = machine.succeed( |
59 | | - "curl -s -H 'X-Api-Key: 5678efgh5678efgh5678efgh5678efgh' " |
60 | | - "http://127.0.0.1:8686/api/v1/rootfolder" |
61 | | - ) |
62 | | - print(f"Root folders: {folders}") |
63 | | - assert "/media/music" in folders, "Root folder not created" |
| 88 | + # Check that SABnzbd download client was configured |
| 89 | + import json |
| 90 | + clients = machine.succeed( |
| 91 | + "curl -s -H 'X-Api-Key: 5678efgh5678efgh5678efgh5678efgh' " |
| 92 | + "http://127.0.0.1:8686/api/v1/downloadclient" |
| 93 | + ) |
| 94 | + clients_list = json.loads(clients) |
| 95 | + print(f"Download clients: {clients}") |
| 96 | + assert len(clients_list) == 1, f"Expected 1 download client, found {len(clients_list)}" |
| 97 | + assert clients_list[0]['name'] == 'SABnzbd', \ |
| 98 | + f"Expected SABnzbd download client, found {clients_list[0]['name']}" |
| 99 | + assert clients_list[0]['implementationName'] == 'SABnzbd', \ |
| 100 | + "Expected SABnzbd implementation" |
| 101 | + print("SABnzbd download client configured successfully!") |
64 | 102 |
|
65 | | - machine.succeed("pgrep -u testuser dotnet") |
66 | | - ''; |
67 | | -} |
| 103 | + machine.succeed("pgrep -u testuser dotnet") |
| 104 | + ''; |
| 105 | + } |
0 commit comments