Skip to content

Commit c01965b

Browse files
authored
nixosTests.varnish{75,76,60}: migrate to runTest (NixOS#394659)
2 parents 55bfb51 + 26497c8 commit c01965b

File tree

2 files changed

+63
-61
lines changed

2 files changed

+63
-61
lines changed

nixos/tests/all-tests.nix

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,18 @@ in {
12771277
ustreamer = handleTest ./ustreamer.nix {};
12781278
uwsgi = handleTest ./uwsgi.nix {};
12791279
v2ray = handleTest ./v2ray.nix {};
1280-
varnish60 = handleTest ./varnish.nix { package = pkgs.varnish60; };
1281-
varnish75 = handleTest ./varnish.nix { package = pkgs.varnish75; };
1282-
varnish76 = handleTest ./varnish.nix { package = pkgs.varnish76; };
1280+
varnish60 = runTest {
1281+
imports = [ ./varnish.nix ];
1282+
_module.args.package = pkgs.varnish60;
1283+
};
1284+
varnish75 = runTest {
1285+
imports = [ ./varnish.nix ];
1286+
_module.args.package = pkgs.varnish75;
1287+
};
1288+
varnish76 = runTest {
1289+
imports = [ ./varnish.nix ];
1290+
_module.args.package = pkgs.varnish76;
1291+
};
12831292
vault = handleTest ./vault.nix {};
12841293
vault-agent = handleTest ./vault-agent.nix {};
12851294
vault-dev = handleTest ./vault-dev.nix {};

nixos/tests/varnish.nix

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,60 @@
1+
{ pkgs, package, ... }:
2+
let
3+
testPath = pkgs.hello;
4+
in
15
{
2-
system ? builtins.currentSystem,
3-
pkgs ? import ../.. { inherit system; },
4-
package,
5-
}:
6-
import ./make-test-python.nix (
7-
{ pkgs, lib, ... }:
8-
let
9-
testPath = pkgs.hello;
10-
in
11-
{
12-
name = "varnish";
13-
meta = {
14-
maintainers = [ ];
15-
};
16-
17-
nodes = {
18-
varnish =
19-
{ config, pkgs, ... }:
20-
{
21-
services.nix-serve = {
22-
enable = true;
23-
};
24-
25-
services.varnish = {
26-
inherit package;
27-
enable = true;
28-
http_address = "0.0.0.0:80";
29-
config = ''
30-
vcl 4.0;
31-
32-
backend nix-serve {
33-
.host = "127.0.0.1";
34-
.port = "${toString config.services.nix-serve.port}";
35-
}
36-
'';
37-
};
6+
name = "varnish";
7+
meta = {
8+
maintainers = [ ];
9+
};
10+
11+
nodes = {
12+
varnish =
13+
{ config, pkgs, ... }:
14+
{
15+
services.nix-serve = {
16+
enable = true;
17+
};
3818

39-
networking.firewall.allowedTCPPorts = [ 80 ];
40-
system.extraDependencies = [ testPath ];
19+
services.varnish = {
20+
inherit package;
21+
enable = true;
22+
http_address = "0.0.0.0:80";
23+
config = ''
24+
vcl 4.0;
25+
26+
backend nix-serve {
27+
.host = "127.0.0.1";
28+
.port = "${toString config.services.nix-serve.port}";
29+
}
30+
'';
4131
};
4232

43-
client =
44-
{ lib, ... }:
45-
{
46-
nix.settings = {
47-
require-sigs = false;
48-
substituters = lib.mkForce [ "http://varnish" ];
49-
};
33+
networking.firewall.allowedTCPPorts = [ 80 ];
34+
system.extraDependencies = [ testPath ];
35+
};
36+
37+
client =
38+
{ lib, ... }:
39+
{
40+
nix.settings = {
41+
require-sigs = false;
42+
substituters = lib.mkForce [ "http://varnish" ];
5043
};
51-
};
44+
};
45+
};
5246

53-
testScript = ''
54-
start_all()
55-
varnish.wait_for_open_port(80)
47+
testScript = ''
48+
start_all()
49+
varnish.wait_for_open_port(80)
5650
57-
client.wait_until_succeeds("curl -f http://varnish/nix-cache-info");
51+
client.wait_until_succeeds("curl -f http://varnish/nix-cache-info");
5852
59-
client.wait_until_succeeds("nix-store -r ${testPath}")
60-
client.succeed("${testPath}/bin/hello")
53+
client.wait_until_succeeds("nix-store -r ${testPath}")
54+
client.succeed("${testPath}/bin/hello")
6155
62-
output = varnish.succeed("varnishadm status")
63-
print(output)
64-
assert "Child in state running" in output, "Unexpected varnishadm response"
65-
'';
66-
}
67-
)
56+
output = varnish.succeed("varnishadm status")
57+
print(output)
58+
assert "Child in state running" in output, "Unexpected varnishadm response"
59+
'';
60+
}

0 commit comments

Comments
 (0)