diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index e9f6f0f9585e..9753a8ecb366 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1277,9 +1277,18 @@ in { ustreamer = handleTest ./ustreamer.nix {}; uwsgi = handleTest ./uwsgi.nix {}; v2ray = handleTest ./v2ray.nix {}; - varnish60 = handleTest ./varnish.nix { package = pkgs.varnish60; }; - varnish75 = handleTest ./varnish.nix { package = pkgs.varnish75; }; - varnish76 = handleTest ./varnish.nix { package = pkgs.varnish76; }; + varnish60 = runTest { + imports = [ ./varnish.nix ]; + _module.args.package = pkgs.varnish60; + }; + varnish75 = runTest { + imports = [ ./varnish.nix ]; + _module.args.package = pkgs.varnish75; + }; + varnish76 = runTest { + imports = [ ./varnish.nix ]; + _module.args.package = pkgs.varnish76; + }; vault = handleTest ./vault.nix {}; vault-agent = handleTest ./vault-agent.nix {}; vault-dev = handleTest ./vault-dev.nix {}; diff --git a/nixos/tests/varnish.nix b/nixos/tests/varnish.nix index ee60a9e392fa..8fa18da31236 100644 --- a/nixos/tests/varnish.nix +++ b/nixos/tests/varnish.nix @@ -1,67 +1,60 @@ +{ pkgs, package, ... }: +let + testPath = pkgs.hello; +in { - system ? builtins.currentSystem, - pkgs ? import ../.. { inherit system; }, - package, -}: -import ./make-test-python.nix ( - { pkgs, lib, ... }: - let - testPath = pkgs.hello; - in - { - name = "varnish"; - meta = { - maintainers = [ ]; - }; + name = "varnish"; + meta = { + maintainers = [ ]; + }; - nodes = { - varnish = - { config, pkgs, ... }: - { - services.nix-serve = { - enable = true; - }; - - services.varnish = { - inherit package; - enable = true; - http_address = "0.0.0.0:80"; - config = '' - vcl 4.0; - - backend nix-serve { - .host = "127.0.0.1"; - .port = "${toString config.services.nix-serve.port}"; - } - ''; - }; - - networking.firewall.allowedTCPPorts = [ 80 ]; - system.extraDependencies = [ testPath ]; + nodes = { + varnish = + { config, pkgs, ... }: + { + services.nix-serve = { + enable = true; }; - client = - { lib, ... }: - { - nix.settings = { - require-sigs = false; - substituters = lib.mkForce [ "http://varnish" ]; - }; + services.varnish = { + inherit package; + enable = true; + http_address = "0.0.0.0:80"; + config = '' + vcl 4.0; + + backend nix-serve { + .host = "127.0.0.1"; + .port = "${toString config.services.nix-serve.port}"; + } + ''; }; - }; - testScript = '' - start_all() - varnish.wait_for_open_port(80) + networking.firewall.allowedTCPPorts = [ 80 ]; + system.extraDependencies = [ testPath ]; + }; - client.wait_until_succeeds("curl -f http://varnish/nix-cache-info"); + client = + { lib, ... }: + { + nix.settings = { + require-sigs = false; + substituters = lib.mkForce [ "http://varnish" ]; + }; + }; + }; - client.wait_until_succeeds("nix-store -r ${testPath}") - client.succeed("${testPath}/bin/hello") + testScript = '' + start_all() + varnish.wait_for_open_port(80) - output = varnish.succeed("varnishadm status") - print(output) - assert "Child in state running" in output, "Unexpected varnishadm response" - ''; - } -) + client.wait_until_succeeds("curl -f http://varnish/nix-cache-info"); + + client.wait_until_succeeds("nix-store -r ${testPath}") + client.succeed("${testPath}/bin/hello") + + output = varnish.succeed("varnishadm status") + print(output) + assert "Child in state running" in output, "Unexpected varnishadm response" + ''; +}