1# Test for NixOS' container support.
2
3let
4 hostIp = "fc00::2";
5 localIp = "fc00::1";
6in
7
8import ./make-test.nix ({ pkgs, ...} : {
9 name = "containers-ipv6";
10 meta = with pkgs.stdenv.lib.maintainers; {
11 maintainers = [ aristid aszlig eelco chaoflow kampfschlaefer ];
12 };
13
14 machine =
15 { config, pkgs, ... }:
16 { imports = [ ../modules/installer/cd-dvd/channel.nix ];
17 virtualisation.writableStore = true;
18 virtualisation.memorySize = 768;
19
20 containers.webserver =
21 { privateNetwork = true;
22 hostAddress6 = hostIp;
23 localAddress6 = localIp;
24 config =
25 { services.httpd.enable = true;
26 services.httpd.adminAddr = "foo@example.org";
27 networking.firewall.allowedTCPPorts = [ 80 ];
28 networking.firewall.allowPing = true;
29 };
30 };
31
32 virtualisation.pathsInNixDB = [ pkgs.stdenv ];
33 };
34
35 testScript =
36 ''
37 $machine->waitForUnit("default.target");
38 $machine->succeed("nixos-container list") =~ /webserver/ or die;
39
40 # Start the webserver container.
41 $machine->succeed("nixos-container start webserver");
42
43 # wait two seconds for the container to start and the network to be up
44 sleep 2;
45
46 # Since "start" returns after the container has reached
47 # multi-user.target, we should now be able to access it.
48 my $ip = "${localIp}";
49 chomp $ip;
50 $machine->succeed("ping6 -n -c 1 $ip");
51 $machine->succeed("curl --fail http://[$ip]/ > /dev/null");
52
53 # Stop the container.
54 $machine->succeed("nixos-container stop webserver");
55 $machine->fail("curl --fail --connect-timeout 2 http://[$ip]/ > /dev/null");
56
57 # Destroying a declarative container should fail.
58 $machine->fail("nixos-container destroy webserver");
59 '';
60
61})