lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

nixosTests.caddy: migrate to runTest (#395444)

authored by

Gaétan Lepage and committed by
GitHub
b1ab0f8d 0dfc5ab5

+133 -135
+1 -1
nixos/tests/all-tests.nix
··· 270 270 buildbot = runTest ./buildbot.nix; 271 271 buildkite-agents = handleTest ./buildkite-agents.nix { }; 272 272 c2fmzq = handleTest ./c2fmzq.nix { }; 273 - caddy = handleTest ./caddy.nix { }; 273 + caddy = runTest ./caddy.nix; 274 274 cadvisor = handleTestOn [ "x86_64-linux" ] ./cadvisor.nix { }; 275 275 cage = handleTest ./cage.nix { }; 276 276 cagebreak = handleTest ./cagebreak.nix { };
+132 -134
nixos/tests/caddy.nix
··· 1 - import ./make-test-python.nix ( 2 - { pkgs, ... }: 3 - { 4 - name = "caddy"; 5 - meta = with pkgs.lib.maintainers; { 6 - maintainers = [ 7 - Br1ght0ne 8 - stepbrobd 9 - ]; 10 - }; 1 + { pkgs, ... }: 2 + { 3 + name = "caddy"; 4 + meta = with pkgs.lib.maintainers; { 5 + maintainers = [ 6 + Br1ght0ne 7 + stepbrobd 8 + ]; 9 + }; 10 + 11 + nodes = { 12 + webserver = 13 + { pkgs, ... }: 14 + { 15 + services.caddy.enable = true; 16 + services.caddy.extraConfig = '' 17 + http://localhost { 18 + encode gzip 19 + 20 + file_server 21 + root * ${ 22 + pkgs.runCommand "testdir" { } '' 23 + mkdir "$out" 24 + echo hello world > "$out/example.html" 25 + '' 26 + } 27 + } 28 + ''; 29 + services.caddy.enableReload = true; 11 30 12 - nodes = { 13 - webserver = 14 - { pkgs, ... }: 15 - { 16 - services.caddy.enable = true; 31 + specialisation.config-reload.configuration = { 17 32 services.caddy.extraConfig = '' 18 - http://localhost { 19 - encode gzip 20 - 21 - file_server 22 - root * ${ 23 - pkgs.runCommand "testdir" { } '' 24 - mkdir "$out" 25 - echo hello world > "$out/example.html" 26 - '' 27 - } 33 + http://localhost:8080 { 28 34 } 29 35 ''; 30 - services.caddy.enableReload = true; 31 - 32 - specialisation.config-reload.configuration = { 33 - services.caddy.extraConfig = '' 34 - http://localhost:8080 { 35 - } 36 - ''; 36 + }; 37 + specialisation.multiple-configs.configuration = { 38 + services.caddy.virtualHosts = { 39 + "http://localhost:8080" = { }; 40 + "http://localhost:8081" = { }; 37 41 }; 38 - specialisation.multiple-configs.configuration = { 39 - services.caddy.virtualHosts = { 40 - "http://localhost:8080" = { }; 41 - "http://localhost:8081" = { }; 42 - }; 42 + }; 43 + specialisation.multiple-hostnames.configuration = { 44 + services.caddy.virtualHosts = { 45 + "http://localhost:8080 http://localhost:8081" = { }; 43 46 }; 44 - specialisation.multiple-hostnames.configuration = { 45 - services.caddy.virtualHosts = { 46 - "http://localhost:8080 http://localhost:8081" = { }; 47 + }; 48 + specialisation.rfc42.configuration = { 49 + services.caddy.settings = { 50 + apps.http.servers.default = { 51 + listen = [ ":80" ]; 52 + routes = [ 53 + { 54 + handle = [ 55 + { 56 + body = "hello world"; 57 + handler = "static_response"; 58 + status_code = 200; 59 + } 60 + ]; 61 + } 62 + ]; 47 63 }; 48 64 }; 49 - specialisation.rfc42.configuration = { 50 - services.caddy.settings = { 51 - apps.http.servers.default = { 52 - listen = [ ":80" ]; 53 - routes = [ 54 - { 55 - handle = [ 56 - { 57 - body = "hello world"; 58 - handler = "static_response"; 59 - status_code = 200; 60 - } 61 - ]; 62 - } 63 - ]; 64 - }; 65 + }; 66 + specialisation.explicit-config-file.configuration = { 67 + services.caddy.configFile = pkgs.writeText "Caddyfile" '' 68 + localhost:80 69 + 70 + respond "hello world" 71 + ''; 72 + }; 73 + specialisation.with-plugins.configuration = { 74 + services.caddy = { 75 + package = pkgs.caddy.withPlugins { 76 + plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20241211194404-3865845790a7" ]; 77 + hash = "sha256-WPmJPnyOrAnuJxvn3ywswqvLGV8SZzzn3gU1Tbtpao4="; 65 78 }; 66 - }; 67 - specialisation.explicit-config-file.configuration = { 68 - services.caddy.configFile = pkgs.writeText "Caddyfile" '' 69 - localhost:80 79 + configFile = pkgs.writeText "Caddyfile" '' 80 + { 81 + order replace after encode 82 + } 70 83 71 - respond "hello world" 84 + localhost:80 { 85 + respond "hello world" 86 + replace world caddy 87 + } 72 88 ''; 73 89 }; 74 - specialisation.with-plugins.configuration = { 75 - services.caddy = { 76 - package = pkgs.caddy.withPlugins { 77 - plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20241211194404-3865845790a7" ]; 78 - hash = "sha256-WPmJPnyOrAnuJxvn3ywswqvLGV8SZzzn3gU1Tbtpao4="; 79 - }; 80 - configFile = pkgs.writeText "Caddyfile" '' 81 - { 82 - order replace after encode 83 - } 84 - 85 - localhost:80 { 86 - respond "hello world" 87 - replace world caddy 88 - } 89 - ''; 90 - }; 91 - }; 92 90 }; 93 - }; 91 + }; 92 + }; 94 93 95 - testScript = 96 - { nodes, ... }: 97 - let 98 - explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file"; 99 - justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload"; 100 - multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs"; 101 - multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames"; 102 - rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42"; 103 - withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins"; 104 - in 105 - '' 106 - url = "http://localhost/example.html" 107 - webserver.wait_for_unit("caddy") 108 - webserver.wait_for_open_port(80) 94 + testScript = 95 + { nodes, ... }: 96 + let 97 + explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file"; 98 + justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload"; 99 + multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs"; 100 + multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames"; 101 + rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42"; 102 + withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins"; 103 + in 104 + '' 105 + url = "http://localhost/example.html" 106 + webserver.wait_for_unit("caddy") 107 + webserver.wait_for_open_port(80) 109 108 110 109 111 - with subtest("config is reloaded on nixos-rebuild switch"): 112 - webserver.succeed( 113 - "${justReloadSystem}/bin/switch-to-configuration test >&2" 114 - ) 115 - webserver.wait_for_open_port(8080) 116 - webserver.fail("journalctl -u caddy | grep -q -i stopped") 117 - webserver.succeed("journalctl -u caddy | grep -q -i reloaded") 110 + with subtest("config is reloaded on nixos-rebuild switch"): 111 + webserver.succeed( 112 + "${justReloadSystem}/bin/switch-to-configuration test >&2" 113 + ) 114 + webserver.wait_for_open_port(8080) 115 + webserver.fail("journalctl -u caddy | grep -q -i stopped") 116 + webserver.succeed("journalctl -u caddy | grep -q -i reloaded") 118 117 119 - with subtest("multiple configs are correctly merged"): 120 - webserver.succeed( 121 - "${multipleConfigs}/bin/switch-to-configuration test >&2" 122 - ) 123 - webserver.wait_for_open_port(8080) 124 - webserver.wait_for_open_port(8081) 118 + with subtest("multiple configs are correctly merged"): 119 + webserver.succeed( 120 + "${multipleConfigs}/bin/switch-to-configuration test >&2" 121 + ) 122 + webserver.wait_for_open_port(8080) 123 + webserver.wait_for_open_port(8081) 125 124 126 - with subtest("a virtual host with multiple hostnames works"): 127 - webserver.succeed( 128 - "${multipleHostnames}/bin/switch-to-configuration test >&2" 129 - ) 130 - webserver.wait_for_open_port(8080) 131 - webserver.wait_for_open_port(8081) 125 + with subtest("a virtual host with multiple hostnames works"): 126 + webserver.succeed( 127 + "${multipleHostnames}/bin/switch-to-configuration test >&2" 128 + ) 129 + webserver.wait_for_open_port(8080) 130 + webserver.wait_for_open_port(8081) 132 131 133 - with subtest("rfc42 settings config"): 134 - webserver.succeed( 135 - "${rfc42Config}/bin/switch-to-configuration test >&2" 136 - ) 137 - webserver.wait_for_open_port(80) 138 - webserver.succeed("curl http://localhost | grep hello") 132 + with subtest("rfc42 settings config"): 133 + webserver.succeed( 134 + "${rfc42Config}/bin/switch-to-configuration test >&2" 135 + ) 136 + webserver.wait_for_open_port(80) 137 + webserver.succeed("curl http://localhost | grep hello") 139 138 140 - with subtest("explicit configFile"): 141 - webserver.succeed( 142 - "${explicitConfigFile}/bin/switch-to-configuration test >&2" 143 - ) 144 - webserver.wait_for_open_port(80) 145 - webserver.succeed("curl http://localhost | grep hello") 139 + with subtest("explicit configFile"): 140 + webserver.succeed( 141 + "${explicitConfigFile}/bin/switch-to-configuration test >&2" 142 + ) 143 + webserver.wait_for_open_port(80) 144 + webserver.succeed("curl http://localhost | grep hello") 146 145 147 - with subtest("plugins are correctled installed and configurable"): 148 - webserver.succeed( 149 - "${withPluginsConfig}/bin/switch-to-configuration test >&2" 150 - ) 151 - webserver.wait_for_open_port(80) 152 - webserver.succeed("curl http://localhost | grep caddy") 153 - ''; 154 - } 155 - ) 146 + with subtest("plugins are correctled installed and configurable"): 147 + webserver.succeed( 148 + "${withPluginsConfig}/bin/switch-to-configuration test >&2" 149 + ) 150 + webserver.wait_for_open_port(80) 151 + webserver.succeed("curl http://localhost | grep caddy") 152 + ''; 153 + }