nixosTests.static-web-server: migrate to runTest

Part of #386873

+35 -37
+1 -1
nixos/tests/all-tests.nix
··· 1233 1233 stargazer = runTest ./web-servers/stargazer.nix; 1234 1234 starship = runTest ./starship.nix; 1235 1235 stash = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stash.nix { }; 1236 - static-web-server = handleTest ./web-servers/static-web-server.nix { }; 1236 + static-web-server = runTest ./web-servers/static-web-server.nix; 1237 1237 step-ca = handleTestOn [ "x86_64-linux" ] ./step-ca.nix { }; 1238 1238 stratis = handleTest ./stratis { }; 1239 1239 strongswan-swanctl = handleTest ./strongswan-swanctl.nix { };
+34 -36
nixos/tests/web-servers/static-web-server.nix
··· 1 - import ../make-test-python.nix ( 2 - { pkgs, lib, ... }: 3 - { 4 - name = "static-web-server"; 5 - meta = { 6 - maintainers = with lib.maintainers; [ mac-chaffee ]; 7 - }; 1 + { pkgs, lib, ... }: 2 + { 3 + name = "static-web-server"; 4 + meta = { 5 + maintainers = with lib.maintainers; [ mac-chaffee ]; 6 + }; 8 7 9 - nodes.machine = 10 - { pkgs, ... }: 11 - { 12 - services.static-web-server = { 13 - enable = true; 14 - listen = "[::]:8080"; 15 - root = toString ( 16 - pkgs.writeTextDir "nixos-test.html" '' 17 - <h1>Hello NixOS!</h1> 18 - '' 19 - ); 20 - configuration = { 21 - general = { 22 - directory-listing = true; 23 - }; 8 + nodes.machine = 9 + { pkgs, ... }: 10 + { 11 + services.static-web-server = { 12 + enable = true; 13 + listen = "[::]:8080"; 14 + root = toString ( 15 + pkgs.writeTextDir "nixos-test.html" '' 16 + <h1>Hello NixOS!</h1> 17 + '' 18 + ); 19 + configuration = { 20 + general = { 21 + directory-listing = true; 24 22 }; 25 23 }; 26 24 }; 25 + }; 27 26 28 - testScript = '' 29 - machine.start() 30 - machine.wait_for_unit("static-web-server.socket") 31 - machine.wait_for_open_port(8080) 32 - # We don't use wait_until_succeeds() because we're testing socket 33 - # activation which better work on the first request 34 - response = machine.succeed("curl -fsS localhost:8080") 35 - assert "nixos-test.html" in response, "The directory listing page did not include a link to our nixos-test.html file" 36 - response = machine.succeed("curl -fsS localhost:8080/nixos-test.html") 37 - assert "Hello NixOS!" in response 38 - machine.wait_for_unit("static-web-server.service") 39 - ''; 40 - } 41 - ) 27 + testScript = '' 28 + machine.start() 29 + machine.wait_for_unit("static-web-server.socket") 30 + machine.wait_for_open_port(8080) 31 + # We don't use wait_until_succeeds() because we're testing socket 32 + # activation which better work on the first request 33 + response = machine.succeed("curl -fsS localhost:8080") 34 + assert "nixos-test.html" in response, "The directory listing page did not include a link to our nixos-test.html file" 35 + response = machine.succeed("curl -fsS localhost:8080/nixos-test.html") 36 + assert "Hello NixOS!" in response 37 + machine.wait_for_unit("static-web-server.service") 38 + ''; 39 + }