nixpkgs/nixos/tests/varnish.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.3 KiB
Nix
Raw Permalink Normal View History

{ pkgs, package, ... }:
let
testPath = pkgs.hello;
in
2022-09-27 21:22:21 +02:00
{
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}";
}
'';
2022-09-27 21:22:21 +02:00
};
networking.firewall.allowedTCPPorts = [ 80 ];
system.extraDependencies = [ testPath ];
};
client =
{ lib, ... }:
{
nix.settings = {
require-sigs = false;
substituters = lib.mkForce [ "http://varnish" ];
2022-09-27 21:22:21 +02:00
};
};
};
2022-09-27 21:22:21 +02:00
testScript = ''
start_all()
varnish.wait_for_open_port(80)
2022-09-27 21:22:21 +02:00
client.wait_until_succeeds("curl -f http://varnish/nix-cache-info");
2022-09-27 21:22:21 +02:00
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"
'';
}