summaryrefslogtreecommitdiffstats
path: root/nixos/tests/containers-names.nix
blob: bdbadf5252a1369e4771744cf9d57d99fe828b92 (plain)
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
{ pkgs, lib, ... }:
{
  name = "containers-names";
  meta = {
    maintainers = with lib.maintainers; [ patryk27 ];
  };

  nodes.machine =
    { ... }:
    {
      # We're using the newest kernel, so that we can test containers with long names.
      # Please see https://github.com/NixOS/nixpkgs/issues/38509 for details.
      boot.kernelPackages = pkgs.linuxPackages_latest;

      containers =
        let
          container = subnet: {
            autoStart = true;
            privateNetwork = true;
            hostAddress = "192.168.${subnet}.1";
            localAddress = "192.168.${subnet}.2";
            config = {
              nix.enable = false; # disabled by default on the test's host. See all-tests.nix / tag(no-nix-by-default)
            };
          };

        in
        {
          first = container "1";
          second = container "2";
          really-long-name = container "3";
          really-long-long-name-2 = container "4";
        };
    };

  testScript = ''
    machine.wait_for_unit("default.target")

    machine.succeed("ip link show | grep ve-first")
    machine.succeed("ip link show | grep ve-second")
    machine.succeed("ip link show | grep ve-really-lFYWO")
    machine.succeed("ip link show | grep ve-really-l3QgY")
  '';
}