at 25.11-pre 2.0 kB view raw
1import ../make-test-python.nix ( 2 { ... }: 3 { 4 name = "immich-nixos"; 5 6 nodes.machine = 7 { pkgs, ... }: 8 { 9 # These tests need a little more juice 10 virtualisation = { 11 cores = 2; 12 memorySize = 2048; 13 diskSize = 4096; 14 }; 15 16 environment.systemPackages = with pkgs; [ immich-cli ]; 17 18 services.immich = { 19 enable = true; 20 environment.IMMICH_LOG_LEVEL = "verbose"; 21 }; 22 }; 23 24 testScript = '' 25 import json 26 27 machine.wait_for_unit("immich-server.service") 28 29 machine.wait_for_open_port(2283) # Server 30 machine.wait_for_open_port(3003) # Machine learning 31 machine.succeed("curl --fail http://localhost:2283/") 32 33 machine.succeed(""" 34 curl -f --json '{ "email": "test@example.com", "name": "Admin", "password": "admin" }' http://localhost:2283/api/auth/admin-sign-up 35 """) 36 res = machine.succeed(""" 37 curl -f --json '{ "email": "test@example.com", "password": "admin" }' http://localhost:2283/api/auth/login 38 """) 39 token = json.loads(res)['accessToken'] 40 41 res = machine.succeed(""" 42 curl -f -H 'Cookie: immich_access_token=%s' --json '{ "name": "API Key", "permissions": ["all"] }' http://localhost:2283/api/api-keys 43 """ % token) 44 key = json.loads(res)['secret'] 45 46 machine.succeed(f"immich login http://localhost:2283/api {key}") 47 res = machine.succeed("immich server-info") 48 print(res) 49 50 machine.succeed(""" 51 curl -f -X PUT -H 'Cookie: immich_access_token=%s' --json '{ "command": "start" }' http://localhost:2283/api/jobs/backupDatabase 52 """ % token) 53 res = machine.succeed(""" 54 curl -f -H 'Cookie: immich_access_token=%s' http://localhost:2283/api/jobs 55 """ % token) 56 assert sum(json.loads(res)["backupDatabase"]["jobCounts"].values()) >= 1 57 machine.wait_until_succeeds("ls /var/lib/immich/backups/*.sql.gz") 58 ''; 59 } 60)