lol

nixosTests.invoiceplane: migrate to runTest (#394694)

authored by

Gaétan Lepage and committed by
GitHub
eefc32f2 e5a816a5

+102 -104
+1 -1
nixos/tests/all-tests.nix
··· 578 578 installer = handleTest ./installer.nix {}; 579 579 installer-systemd-stage-1 = handleTest ./installer-systemd-stage-1.nix {}; 580 580 intune = handleTest ./intune.nix {}; 581 - invoiceplane = handleTest ./invoiceplane.nix {}; 581 + invoiceplane = runTest ./invoiceplane.nix; 582 582 iodine = handleTest ./iodine.nix {}; 583 583 ipv6 = handleTest ./ipv6.nix {}; 584 584 iscsi-multipath-root = handleTest ./iscsi-multipath-root.nix {};
+101 -103
nixos/tests/invoiceplane.nix
··· 1 - import ./make-test-python.nix ( 2 - { pkgs, ... }: 1 + { pkgs, ... }: 3 2 4 - { 5 - name = "invoiceplane"; 6 - meta = with pkgs.lib.maintainers; { 7 - maintainers = [ 8 - onny 9 - ]; 10 - }; 3 + { 4 + name = "invoiceplane"; 5 + meta = with pkgs.lib.maintainers; { 6 + maintainers = [ 7 + onny 8 + ]; 9 + }; 11 10 12 - nodes = { 13 - invoiceplane_caddy = 14 - { ... }: 15 - { 16 - services.invoiceplane.webserver = "caddy"; 17 - services.invoiceplane.sites = { 18 - "site1.local" = { 19 - database.name = "invoiceplane1"; 20 - database.createLocally = true; 21 - enable = true; 22 - }; 23 - "site2.local" = { 24 - database.name = "invoiceplane2"; 25 - database.createLocally = true; 26 - enable = true; 27 - }; 11 + nodes = { 12 + invoiceplane_caddy = 13 + { ... }: 14 + { 15 + services.invoiceplane.webserver = "caddy"; 16 + services.invoiceplane.sites = { 17 + "site1.local" = { 18 + database.name = "invoiceplane1"; 19 + database.createLocally = true; 20 + enable = true; 28 21 }; 29 - 30 - networking.firewall.allowedTCPPorts = [ 80 ]; 31 - networking.hosts."127.0.0.1" = [ 32 - "site1.local" 33 - "site2.local" 34 - ]; 22 + "site2.local" = { 23 + database.name = "invoiceplane2"; 24 + database.createLocally = true; 25 + enable = true; 26 + }; 35 27 }; 36 28 37 - invoiceplane_nginx = 38 - { ... }: 39 - { 40 - services.invoiceplane.webserver = "nginx"; 41 - services.invoiceplane.sites = { 42 - "site1.local" = { 43 - database.name = "invoiceplane1"; 44 - database.createLocally = true; 45 - enable = true; 46 - }; 47 - "site2.local" = { 48 - database.name = "invoiceplane2"; 49 - database.createLocally = true; 50 - enable = true; 51 - }; 29 + networking.firewall.allowedTCPPorts = [ 80 ]; 30 + networking.hosts."127.0.0.1" = [ 31 + "site1.local" 32 + "site2.local" 33 + ]; 34 + }; 35 + 36 + invoiceplane_nginx = 37 + { ... }: 38 + { 39 + services.invoiceplane.webserver = "nginx"; 40 + services.invoiceplane.sites = { 41 + "site1.local" = { 42 + database.name = "invoiceplane1"; 43 + database.createLocally = true; 44 + enable = true; 45 + }; 46 + "site2.local" = { 47 + database.name = "invoiceplane2"; 48 + database.createLocally = true; 49 + enable = true; 52 50 }; 53 - 54 - networking.firewall.allowedTCPPorts = [ 80 ]; 55 - networking.hosts."127.0.0.1" = [ 56 - "site1.local" 57 - "site2.local" 58 - ]; 59 51 }; 60 - }; 61 52 62 - testScript = '' 63 - start_all() 53 + networking.firewall.allowedTCPPorts = [ 80 ]; 54 + networking.hosts."127.0.0.1" = [ 55 + "site1.local" 56 + "site2.local" 57 + ]; 58 + }; 59 + }; 64 60 65 - invoiceplane_caddy.wait_for_unit("caddy") 66 - invoiceplane_nginx.wait_for_unit("nginx") 61 + testScript = '' 62 + start_all() 67 63 68 - site_names = ["site1.local", "site2.local"] 64 + invoiceplane_caddy.wait_for_unit("caddy") 65 + invoiceplane_nginx.wait_for_unit("nginx") 69 66 70 - machines = [invoiceplane_caddy, invoiceplane_nginx] 67 + site_names = ["site1.local", "site2.local"] 71 68 72 - for machine in machines: 73 - machine.wait_for_open_port(80) 74 - machine.wait_for_open_port(3306) 69 + machines = [invoiceplane_caddy, invoiceplane_nginx] 75 70 76 - for site_name in site_names: 77 - machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}") 71 + for machine in machines: 72 + machine.wait_for_open_port(80) 73 + machine.wait_for_open_port(3306) 78 74 79 - with subtest("Website returns welcome screen"): 80 - assert "Please install InvoicePlane" in machine.succeed(f"curl -L {site_name}") 75 + for site_name in site_names: 76 + machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}") 81 77 82 - with subtest("Finish InvoicePlane setup"): 83 - machine.succeed( 84 - f"curl -sSfL --cookie-jar cjar {site_name}/setup/language" 85 - ) 86 - csrf_token = machine.succeed( 87 - "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 88 - ) 89 - machine.succeed( 90 - f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&ip_lang=english&btn_continue=Continue' {site_name}/setup/language" 91 - ) 92 - csrf_token = machine.succeed( 93 - "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 94 - ) 95 - machine.succeed( 96 - f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/prerequisites" 97 - ) 98 - csrf_token = machine.succeed( 99 - "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 100 - ) 101 - machine.succeed( 102 - f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/configure_database" 103 - ) 104 - csrf_token = machine.succeed( 105 - "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 106 - ) 107 - machine.succeed( 108 - f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/install_tables" 109 - ) 110 - csrf_token = machine.succeed( 111 - "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 112 - ) 113 - machine.succeed( 114 - f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/upgrade_tables" 115 - ) 116 - ''; 117 - } 118 - ) 78 + with subtest("Website returns welcome screen"): 79 + assert "Please install InvoicePlane" in machine.succeed(f"curl -L {site_name}") 80 + 81 + with subtest("Finish InvoicePlane setup"): 82 + machine.succeed( 83 + f"curl -sSfL --cookie-jar cjar {site_name}/setup/language" 84 + ) 85 + csrf_token = machine.succeed( 86 + "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 87 + ) 88 + machine.succeed( 89 + f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&ip_lang=english&btn_continue=Continue' {site_name}/setup/language" 90 + ) 91 + csrf_token = machine.succeed( 92 + "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 93 + ) 94 + machine.succeed( 95 + f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/prerequisites" 96 + ) 97 + csrf_token = machine.succeed( 98 + "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 99 + ) 100 + machine.succeed( 101 + f"curl -sSfL --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/configure_database" 102 + ) 103 + csrf_token = machine.succeed( 104 + "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 105 + ) 106 + machine.succeed( 107 + f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/install_tables" 108 + ) 109 + csrf_token = machine.succeed( 110 + "grep ip_csrf_cookie cjar | cut -f 7 | tr -d '\n'" 111 + ) 112 + machine.succeed( 113 + f"curl -sSfl --cookie cjar --cookie-jar cjar -d '_ip_csrf={csrf_token}&btn_continue=Continue' {site_name}/setup/upgrade_tables" 114 + ) 115 + ''; 116 + }