Unverified Commit e8381f9f authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

nixosTests.varnish60: fix failing test (#441164)

parents c0321665 aaa2d76d
Loading
Loading
Loading
Loading
+30 −18
Original line number Diff line number Diff line
{ pkgs, package, ... }:
let
  testPath = pkgs.hello;

  # Same stateDir logic as in nixos/modules/services/web-servers/varnish/default.nix
  stateDir =
    hostName:
    if (pkgs.lib.versionOlder package.version "7") then
      "/var/run/varnish/${hostName}"
    else
      "/var/run/varnishd";
in
{
  name = "varnish";
@@ -37,13 +45,16 @@ in
              port = 8080;
              proto = "PROXY";
            }
            { address = "@asdf"; }
            {
              address = "/run/varnishd/client.http.sock";
              address = "${stateDir config.networking.hostName}/client.http.sock";
              user = "varnish";
              group = "varnish";
              mode = "660";
            }
          ]
          ++ lib.optionals (lib.versionAtLeast package.version "7.3") [
            # Support added in 7.3.0
            { address = "@asdf"; }
          ];
          config = ''
            vcl 4.1;
@@ -59,24 +70,25 @@ in
        system.extraDependencies = [ testPath ];

        assertions =
          map
            (
              pattern:
          let
            cmdline = config.systemd.services.varnish.serviceConfig.ExecStart;
          in
              {
          map
            (pattern: {
              assertion = lib.hasInfix pattern cmdline;
              message = "Address argument `${pattern}` missing in commandline `${cmdline}`.";
              }
            )
            })
            (
              [
                " -a 0.0.0.0:80,HTTP "
                " -a proxyport=0.0.0.0:8080,PROXY "
              " -a @asdf,HTTP "
              " -a /run/varnishd/client.http.sock,HTTP,user=varnish,group=varnish,mode=660 "
                " -a ${stateDir config.networking.hostName}/client.http.sock,HTTP,user=varnish,group=varnish,mode=660 "
                " -a 0.0.0.0:81 "
            ];
              ]
              ++ lib.optionals (lib.versionAtLeast package.version "7.3") [
                " -a @asdf,HTTP "
              ]
            );
      };

    client =