1 # this is a set of tests for non-default options. typically the default options
2 # will be handled by the other tests
3 import ../make-test-python.nix (
7 incus ? pkgs.incus-lts,
12 releases = import ../../release.nix {
14 # Building documentation makes the test unnecessarily take a longer time:
15 documentation.enable = lib.mkForce false;
19 container-image-metadata = "${
20 releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}
21 }/tarball/nixos-system-${pkgs.stdenv.hostPlatform.system}.tar.xz";
22 container-image-rootfs = "${
23 releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}
24 }/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs";
27 name = "incusd-options";
30 maintainers = lib.teams.lxc.members;
42 softDaemonRestart = false;
47 name = "nixostestbr0";
50 "ipv4.address" = "10.0.100.1/24";
61 network = "nixostestbr0";
66 pool = "nixostest_pool";
75 name = "nixostest_pool";
82 networking.nftables.enable = true;
86 def instance_is_up(_) -> bool:
87 status, _ = machine.execute("incus exec container --disable-stdin --force-interactive /run/current-system/sw/bin/systemctl -- is-system-running")
90 machine.wait_for_unit("incus.service")
91 machine.wait_for_unit("incus-preseed.service")
93 with subtest("Container image can be imported"):
94 machine.succeed("incus image import ${container-image-metadata} ${container-image-rootfs} --alias nixos")
96 with subtest("Container can be launched and managed"):
97 machine.succeed("incus launch nixos container")
98 with machine.nested("Waiting for instance to start and be usable"):
100 machine.succeed("echo true | incus exec container /run/current-system/sw/bin/bash -")
102 with subtest("Verify preseed resources created"):
103 machine.succeed("incus profile show default")
104 machine.succeed("incus network info nixostestbr0")
105 machine.succeed("incus storage show nixostest_pool")
107 with subtest("Instance is stopped when softDaemonRestart is disabled and services is stopped"):
108 pid = machine.succeed("incus info container | grep 'PID'").split(":")[1].strip()
109 machine.succeed(f"ps {pid}")
110 machine.succeed("systemctl stop incus")
111 machine.fail(f"ps {pid}")