nixos/nginx: add unix-socket default-listen test case

Includes timeout=1 while checking existence of unix socket file paths
This commit is contained in:
Bert Proesmans 2025-01-06 21:16:06 +00:00
parent 2309ec35a2
commit 871a9b2890

View file

@ -1,5 +1,6 @@
{ ... }: { ... }:
let let
defaultNginxSocketPath = "/var/run/nginx/default-test.sock";
nginxSocketPath = "/var/run/nginx/test.sock"; nginxSocketPath = "/var/run/nginx/test.sock";
in in
{ {
@ -11,6 +12,13 @@ in
{ {
services.nginx = { services.nginx = {
enable = true; enable = true;
defaultListen = [ { addr = "unix:${defaultNginxSocketPath}"; } ];
virtualHosts.defaultLocalhost = {
serverName = "defaultLocalhost";
locations."/default".return = "200 'bar'";
};
virtualHosts.localhost = { virtualHosts.localhost = {
serverName = "localhost"; serverName = "localhost";
listen = [ { addr = "unix:${nginxSocketPath}"; } ]; listen = [ { addr = "unix:${nginxSocketPath}"; } ];
@ -22,8 +30,10 @@ in
testScript = '' testScript = ''
webserver.wait_for_unit("nginx") webserver.wait_for_unit("nginx")
webserver.wait_for_open_unix_socket("${nginxSocketPath}") webserver.wait_for_open_unix_socket("${defaultNginxSocketPath}", timeout=1)
webserver.wait_for_open_unix_socket("${nginxSocketPath}", timeout=1)
webserver.succeed("curl --fail --silent --unix-socket '${defaultNginxSocketPath}' http://defaultLocalhost/default | grep '^bar$'")
webserver.succeed("curl --fail --silent --unix-socket '${nginxSocketPath}' http://localhost/test | grep '^foo$'") webserver.succeed("curl --fail --silent --unix-socket '${nginxSocketPath}' http://localhost/test | grep '^foo$'")
''; '';
} }