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