at 25.11-pre 2.1 kB view raw
1import ../make-test-python.nix ( 2 { pkgs, lib, ... }: 3 4 let 5 releases = import ../../release.nix { 6 configuration = { 7 # Building documentation makes the test unnecessarily take a longer time: 8 documentation.enable = lib.mkForce false; 9 10 # Our tests require `grep` & friends: 11 environment.systemPackages = with pkgs; [ busybox ]; 12 }; 13 }; 14 15 lxd-image-metadata = releases.lxdVirtualMachineImageMeta.${pkgs.stdenv.hostPlatform.system}; 16 lxd-image-disk = releases.lxdVirtualMachineImage.${pkgs.stdenv.hostPlatform.system}; 17 18 instance-name = "instance1"; 19 in 20 { 21 name = "lxd-virtual-machine"; 22 23 nodes.machine = 24 { lib, ... }: 25 { 26 virtualisation = { 27 diskSize = 4096; 28 29 cores = 2; 30 31 # Ensure we have enough memory for the nested virtual machine 32 memorySize = 1024; 33 34 lxc.lxcfs.enable = true; 35 lxd.enable = true; 36 }; 37 }; 38 39 testScript = '' 40 def instance_is_up(_) -> bool: 41 status, _ = machine.execute("lxc exec ${instance-name} --disable-stdin --force-interactive /run/current-system/sw/bin/true") 42 return status == 0 43 44 machine.wait_for_unit("sockets.target") 45 machine.wait_for_unit("lxd.service") 46 machine.wait_for_file("/var/lib/lxd/unix.socket") 47 48 # Wait for lxd to settle 49 machine.succeed("lxd waitready") 50 51 machine.succeed("lxd init --minimal") 52 53 with subtest("virtual-machine image can be imported"): 54 machine.succeed("lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-disk}/nixos.qcow2 --alias nixos") 55 56 with subtest("virtual-machine can be launched and become available"): 57 machine.succeed("lxc launch nixos ${instance-name} --vm --config limits.memory=512MB --config security.secureboot=false") 58 with machine.nested("Waiting for instance to start and be usable"): 59 retry(instance_is_up) 60 61 with subtest("lxd-agent is started"): 62 machine.succeed("lxc exec ${instance-name} systemctl is-active lxd-agent") 63 ''; 64 } 65)