Skip to content

Commit

Permalink
nixos/tests/immich: init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed Aug 26, 2023
1 parent 91d3677 commit ce90a10
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Expand Up @@ -365,6 +365,7 @@ in {
i3wm = handleTest ./i3wm.nix {};
icingaweb2 = handleTest ./icingaweb2.nix {};
iftop = handleTest ./iftop.nix {};
immich = handleTest ./web-apps/immich.nix {};
incron = handleTest ./incron.nix {};
influxdb = handleTest ./influxdb.nix {};
influxdb2 = handleTest ./influxdb2.nix {};
Expand Down
69 changes: 69 additions & 0 deletions nixos/tests/web-apps/immich.nix
@@ -0,0 +1,69 @@
import ../make-test-python.nix ({pkgs, ...}: let
typesenseApiKeyFile = pkgs.writeText "typesense-api-key" "12318551487654187654";
in {
name = "immich-nixos";
# TODO second machine test distributed setup
nodes.machine = {
self,
pkgs,
...
}: {
# These tests need a little more juice
virtualisation.cores = 2;
virtualisation.memorySize = 2048;

services.immich = {
enable = true;
server.typesense.apiKeyFile = typesenseApiKeyFile;
};

services.typesense = {
enable = true;
# In a real setup you should generate an api key for immich
# and not use the admin key!
apiKeyFile = typesenseApiKeyFile;
settings.server.api-address = "127.0.0.1";
};

services.postgresql = {
enable = true;
identMap = ''
# ArbitraryMapName systemUser DBUser
superuser_map root postgres
superuser_map postgres postgres
# Let other names login as themselves
superuser_map /^(.*)$ \1
'';
authentication = pkgs.lib.mkOverride 10 ''
local sameuser all peer map=superuser_map
'';

ensureDatabases = [ "immich" ];
ensureUsers = [
{
name = "immich";
ensurePermissions = {
"DATABASE immich" = "ALL PRIVILEGES";
};
}
];
};
};

testScript = ''
start_all()
# wait for our service to start
machine.wait_for_unit("immich-server.service")
# machine.wait_for_open_port(${toString 1234})
# machine.succeed("curl --fail http://localhost:${toString 1234}/")
machine.wait_for_open_port(${toString 3000})
machine.wait_for_open_port(${toString 3001})
machine.wait_for_open_port(${toString 3002})
machine.wait_for_open_port(${toString 3003})
# TODO microservices
# TODO machine learning
# TODO web
'';
})
1 change: 1 addition & 0 deletions pkgs/servers/immich/default.nix
Expand Up @@ -189,6 +189,7 @@ buildNpmPackage' {
'';

passthru = {
tests = { inherit (nixosTests) immich; };
inherit cli web machine-learning;
updateScript = ./update.sh;
};
Expand Down

0 comments on commit ce90a10

Please sign in to comment.