···55# iptables to nftables requires a full reboot, which is a bit hard inside NixOS
66# tests.
7788-import ./make-test-python.nix ({ pkgs, ...} : {
88+import ../make-test-python.nix ({ pkgs, ...} : {
99 name = "lxd-nftables";
10101111 meta = with pkgs.lib.maintainers; {
+1-1
nixos/tests/lxd-ui.nix
nixos/tests/lxd/ui.nix
···11-import ./make-test-python.nix ({ pkgs, lib, ... }: {
11+import ../make-test-python.nix ({ pkgs, lib, ... }: {
22 name = "lxd-ui";
3344 meta = with pkgs.lib.maintainers; {
+21-17
nixos/tests/lxd.nix
nixos/tests/lxd/container.nix
···11-import ./make-test-python.nix ({ pkgs, lib, ... } :
11+import ../make-test-python.nix ({ pkgs, lib, ... } :
2233let
44- lxd-image = import ../release.nix {
44+ lxd-image = import ../../release.nix {
55 configuration = {
66 # Building documentation makes the test unnecessarily take a longer time:
77 documentation.enable = lib.mkForce false;
···3838 };
39394040 testScript = ''
4141+ def instance_is_up(_) -> bool:
4242+ status, _ = machine.execute("lxc exec container --disable-stdin --force-interactive /run/current-system/sw/bin/true")
4343+ return status == 0
4444+4145 machine.wait_for_unit("sockets.target")
4246 machine.wait_for_unit("lxd.service")
4347 machine.wait_for_file("/var/lib/lxd/unix.socket")
44484545- # It takes additional second for lxd to settle
4646- machine.sleep(1)
4949+ # Wait for lxd to settle
5050+ machine.succeed("lxd waitready")
47514848- # lxd expects the pool's directory to already exist
4949- machine.succeed("mkdir /var/lxd-pool")
5050-5151- machine.succeed(
5252- "cat ${./common/lxd/config.yaml} | lxd init --preseed"
5353- )
5252+ machine.succeed("lxd init --minimal")
54535554 machine.succeed(
5655 "lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-rootfs}/*/*.tar.xz --alias nixos"
···58575958 with subtest("Container can be managed"):
6059 machine.succeed("lxc launch nixos container")
6161- machine.sleep(5)
6060+ with machine.nested("Waiting for instance to start and be usable"):
6161+ retry(instance_is_up)
6262 machine.succeed("echo true | lxc exec container /run/current-system/sw/bin/bash -")
6363- machine.succeed("lxc exec container true")
6463 machine.succeed("lxc delete -f container")
65646665 with subtest("Container is mounted with lxcfs inside"):
6766 machine.succeed("lxc launch nixos container")
6868- machine.sleep(5)
6767+ with machine.nested("Waiting for instance to start and be usable"):
6868+ retry(instance_is_up)
69697070 ## ---------- ##
7171 ## limits.cpu ##
72727373 machine.succeed("lxc config set container limits.cpu 1")
7474 machine.succeed("lxc restart container")
7575- machine.sleep(5)
7575+ with machine.nested("Waiting for instance to start and be usable"):
7676+ retry(instance_is_up)
76777778 assert (
7879 "1"
···81828283 machine.succeed("lxc config set container limits.cpu 2")
8384 machine.succeed("lxc restart container")
8484- machine.sleep(5)
8585+ with machine.nested("Waiting for instance to start and be usable"):
8686+ retry(instance_is_up)
85878688 assert (
8789 "2"
···93959496 machine.succeed("lxc config set container limits.memory 64MB")
9597 machine.succeed("lxc restart container")
9696- machine.sleep(5)
9898+ with machine.nested("Waiting for instance to start and be usable"):
9999+ retry(instance_is_up)
9710098101 assert (
99102 "MemTotal: 62500 kB"
···102105103106 machine.succeed("lxc config set container limits.memory 128MB")
104107 machine.succeed("lxc restart container")
105105- machine.sleep(5)
108108+ with machine.nested("Waiting for instance to start and be usable"):
109109+ retry(instance_is_up)
106110107111 assert (
108112 "MemTotal: 125000 kB"
+9
nixos/tests/lxd/default.nix
···11+{
22+ system ? builtins.currentSystem,
33+ config ? {},
44+ pkgs ? import ../../.. {inherit system config;},
55+}: {
66+ container = import ./container.nix {inherit system pkgs;};
77+ nftables = import ./nftables.nix {inherit system pkgs;};
88+ ui = import ./ui.nix {inherit system pkgs;};
99+}