1{ ... }:
2{
3 name = "immich-vectorchord-migration";
4
5 nodes.machine =
6 { lib, pkgs, ... }:
7 {
8 # These tests need a little more juice
9 virtualisation = {
10 cores = 2;
11 memorySize = 2048;
12 diskSize = 4096;
13 };
14
15 environment.systemPackages = with pkgs; [ immich-cli ];
16
17 services.immich = {
18 enable = true;
19 environment.IMMICH_LOG_LEVEL = "verbose";
20 # Simulate an existing setup
21 database.enableVectorChord = lib.mkDefault false;
22 database.enableVectors = lib.mkDefault true;
23 };
24
25 # TODO: Remove when PostgreSQL 17 is supported.
26 services.postgresql.package = pkgs.postgresql_16;
27
28 specialisation."immich-vectorchord-enabled".configuration = {
29 services.immich.database.enableVectorChord = true;
30 };
31
32 specialisation."immich-vectorchord-only".configuration = {
33 services.immich.database = {
34 enableVectorChord = true;
35 enableVectors = false;
36 };
37 };
38 };
39
40 testScript =
41 { nodes, ... }:
42 let
43 specBase = "${nodes.machine.system.build.toplevel}/specialisation";
44 vectorchordEnabled = "${specBase}/immich-vectorchord-enabled";
45 vectorchordOnly = "${specBase}/immich-vectorchord-only";
46 in
47 ''
48 def psql(command: str):
49 machine.succeed(f"sudo -u postgres psql -d ${nodes.machine.services.immich.database.name} -c '{command}'")
50
51 def immich_works():
52 machine.wait_for_unit("immich-server.service")
53
54 machine.wait_for_open_port(2283) # Server
55 machine.wait_for_open_port(3003) # Machine learning
56 machine.succeed("curl --fail http://localhost:2283/")
57
58 immich_works()
59
60 machine.succeed("${vectorchordEnabled}/bin/switch-to-configuration test")
61
62 immich_works()
63
64 psql("DROP EXTENSION vectors;")
65 psql("DROP SCHEMA vectors;")
66
67 machine.succeed("${vectorchordOnly}/bin/switch-to-configuration test")
68
69 immich_works()
70 '';
71}