1import ./make-test.nix ({ pkgs, ...}: {
2 name = "haproxy";
3 nodes = {
4 machine = { ... }: {
5 imports = [ ../modules/profiles/minimal.nix ];
6 services.haproxy = {
7 enable = true;
8 config = ''
9 defaults
10 timeout connect 10s
11
12 backend http_server
13 mode http
14 server httpd [::1]:8000
15
16 frontend http
17 bind *:80
18 mode http
19 use_backend http_server
20 '';
21 };
22 services.httpd = {
23 enable = true;
24 documentRoot = pkgs.writeTextDir "index.txt" "We are all good!";
25 adminAddr = "notme@yourhost.local";
26 listen = [{
27 ip = "::1";
28 port = 8000;
29 }];
30 };
31 };
32 };
33 testScript = ''
34 startAll;
35 $machine->waitForUnit('multi-user.target');
36 $machine->waitForUnit('haproxy.service');
37 $machine->waitForUnit('httpd.service');
38 $machine->succeed('curl -k http://localhost:80/index.txt | grep "We are all good!"');
39
40 '';
41})