Skip to content

Commit 871a9b2

Browse files
nixos/nginx: add unix-socket default-listen test case
Includes timeout=1 while checking existence of unix socket file paths
1 parent 2309ec3 commit 871a9b2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nixos/tests/nginx-unix-socket.nix

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ ... }:
22
let
3+
defaultNginxSocketPath = "/var/run/nginx/default-test.sock";
34
nginxSocketPath = "/var/run/nginx/test.sock";
45
in
56
{
@@ -11,6 +12,13 @@ in
1112
{
1213
services.nginx = {
1314
enable = true;
15+
16+
defaultListen = [ { addr = "unix:${defaultNginxSocketPath}"; } ];
17+
virtualHosts.defaultLocalhost = {
18+
serverName = "defaultLocalhost";
19+
locations."/default".return = "200 'bar'";
20+
};
21+
1422
virtualHosts.localhost = {
1523
serverName = "localhost";
1624
listen = [ { addr = "unix:${nginxSocketPath}"; } ];
@@ -22,8 +30,10 @@ in
2230

2331
testScript = ''
2432
webserver.wait_for_unit("nginx")
25-
webserver.wait_for_open_unix_socket("${nginxSocketPath}")
33+
webserver.wait_for_open_unix_socket("${defaultNginxSocketPath}", timeout=1)
34+
webserver.wait_for_open_unix_socket("${nginxSocketPath}", timeout=1)
2635
36+
webserver.succeed("curl --fail --silent --unix-socket '${defaultNginxSocketPath}' http://defaultLocalhost/default | grep '^bar$'")
2737
webserver.succeed("curl --fail --silent --unix-socket '${nginxSocketPath}' http://localhost/test | grep '^foo$'")
2838
'';
2939
}

0 commit comments

Comments
 (0)