Commit 871a9b28 authored by Bert Proesmans's avatar Bert Proesmans
Browse files

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

Includes timeout=1 while checking existence of unix socket file paths
parent 2309ec35
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
{ ... }:
let
  defaultNginxSocketPath = "/var/run/nginx/default-test.sock";
  nginxSocketPath = "/var/run/nginx/test.sock";
in
{
@@ -11,6 +12,13 @@ in
      {
        services.nginx = {
          enable = true;

          defaultListen = [ { addr = "unix:${defaultNginxSocketPath}"; } ];
          virtualHosts.defaultLocalhost = {
            serverName = "defaultLocalhost";
            locations."/default".return = "200 'bar'";
          };

          virtualHosts.localhost = {
            serverName = "localhost";
            listen = [ { addr = "unix:${nginxSocketPath}"; } ];
@@ -22,8 +30,10 @@ in

  testScript = ''
    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$'")
  '';
}