at 23.11-beta 3.1 kB view raw
1import ./make-test-python.nix ({ pkgs, lib, ... }: 2{ 3 name = "hedgedoc"; 4 5 meta = with lib.maintainers; { 6 maintainers = [ willibutz ]; 7 }; 8 9 nodes = { 10 hedgedocSqlite = { ... }: { 11 services.hedgedoc.enable = true; 12 }; 13 14 hedgedocPostgresWithTCPSocket = { ... }: { 15 systemd.services.hedgedoc.after = [ "postgresql.service" ]; 16 services = { 17 hedgedoc = { 18 enable = true; 19 settings.db = { 20 dialect = "postgres"; 21 user = "hedgedoc"; 22 password = "$DB_PASSWORD"; 23 host = "localhost"; 24 port = 5432; 25 database = "hedgedocdb"; 26 }; 27 28 /* 29 * Do not use pkgs.writeText for secrets as 30 * they will end up in the world-readable Nix store. 31 */ 32 environmentFile = pkgs.writeText "hedgedoc-env" '' 33 DB_PASSWORD=snakeoilpassword 34 ''; 35 }; 36 postgresql = { 37 enable = true; 38 initialScript = pkgs.writeText "pg-init-script.sql" '' 39 CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword'; 40 CREATE DATABASE hedgedocdb OWNER hedgedoc; 41 ''; 42 }; 43 }; 44 }; 45 46 hedgedocPostgresWithUNIXSocket = { ... }: { 47 systemd.services.hedgedoc.after = [ "postgresql.service" ]; 48 services = { 49 hedgedoc = { 50 enable = true; 51 settings.db = { 52 dialect = "postgres"; 53 user = "hedgedoc"; 54 password = "$DB_PASSWORD"; 55 host = "/run/postgresql"; 56 database = "hedgedocdb"; 57 }; 58 59 environmentFile = pkgs.writeText "hedgedoc-env" '' 60 DB_PASSWORD=snakeoilpassword 61 ''; 62 }; 63 postgresql = { 64 enable = true; 65 initialScript = pkgs.writeText "pg-init-script.sql" '' 66 CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword'; 67 CREATE DATABASE hedgedocdb OWNER hedgedoc; 68 ''; 69 }; 70 }; 71 }; 72 }; 73 74 testScript = '' 75 start_all() 76 77 with subtest("HedgeDoc sqlite"): 78 hedgedocSqlite.wait_for_unit("hedgedoc.service") 79 hedgedocSqlite.wait_for_open_port(3000) 80 hedgedocSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new") 81 82 with subtest("HedgeDoc postgres with TCP socket"): 83 hedgedocPostgresWithTCPSocket.wait_for_unit("postgresql.service") 84 hedgedocPostgresWithTCPSocket.wait_for_unit("hedgedoc.service") 85 hedgedocPostgresWithTCPSocket.wait_for_open_port(5432) 86 hedgedocPostgresWithTCPSocket.wait_for_open_port(3000) 87 hedgedocPostgresWithTCPSocket.wait_until_succeeds("curl -sSf http://localhost:3000/new") 88 89 with subtest("HedgeDoc postgres with UNIX socket"): 90 hedgedocPostgresWithUNIXSocket.wait_for_unit("postgresql.service") 91 hedgedocPostgresWithUNIXSocket.wait_for_unit("hedgedoc.service") 92 hedgedocPostgresWithUNIXSocket.wait_for_open_port(5432) 93 hedgedocPostgresWithUNIXSocket.wait_for_open_port(3000) 94 hedgedocPostgresWithUNIXSocket.wait_until_succeeds("curl -sSf http://localhost:3000/new") 95 ''; 96})