nixosTests.varnish{75,76,60}: migrate to runTest

Part of #386873
This commit is contained in:
Piotr Kwiecinski 2025-03-30 18:22:15 +02:00
parent 494c90cb5d
commit 26497c8351
No known key found for this signature in database
GPG key ID: EC0DE1CB9D5258B4
2 changed files with 63 additions and 61 deletions

View file

@ -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 {};

View file

@ -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"
'';
}