-
Notifications
You must be signed in to change notification settings - Fork 0
/
integration.nix
73 lines (62 loc) · 1.42 KB
/
integration.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ pkgs
, makeTest
, backend
, static
}:
let
test_port = 80;
sharedModule = {
# Since it's common for CI not to have $DISPLAY available, we have to explicitly tell the tests "please don't expect any screen available"
virtualisation.graphics = false;
};
in
makeTest
{
name = "integration";
nodes = {
server = {
imports = [
sharedModule
backend.nixosModules.x86_64-linux.default
static.nixosModules.x86_64-linux.default
];
networking.firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
services = {
backend = {
enable = true;
domain = "blog.flakm.com";
};
static-website = {
enable = true;
domain = "blog.flakm.com";
};
nginx.enable = true;
};
};
client = {
imports = [ sharedModule ];
};
};
extraPythonPackages = p: [ p.termcolor ];
testScript = ''
start_all()
import sys
from termcolor import cprint
server.wait_for_open_port(${toString test_port})
server.wait_for_open_port(3000)
expected = "<h1>Hello, World!</h1>"
actual = client.succeed(
"${pkgs.curl}/bin/curl -vv http://server/api"
)
if expected != actual:
cprint("Test failed unexpected result: " + actual, "red", attrs=["bold"], file=sys.stderr)
sys.exit(1)
'';
}
{
inherit pkgs;
inherit (pkgs) system;
}