at 25.11-pre 3.7 kB view raw
1import ../make-test-python.nix ( 2 3 { 4 pkgs, 5 lib, 6 lts ? true, 7 ... 8 }: 9 10 let 11 releases = import ../../release.nix { configuration.documentation.enable = lib.mkForce false; }; 12 13 container-image-metadata = releases.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system}; 14 container-image-rootfs = releases.lxdContainerImage.${pkgs.stdenv.hostPlatform.system}; 15 in 16 { 17 name = "lxd-to-incus"; 18 19 meta = { 20 maintainers = lib.teams.lxc.members; 21 }; 22 23 nodes.machine = 24 { ... }: 25 { 26 virtualisation = { 27 diskSize = 6144; 28 cores = 2; 29 memorySize = 2048; 30 31 lxd.enable = true; 32 lxd.preseed = { 33 networks = [ 34 { 35 name = "nixostestbr0"; 36 type = "bridge"; 37 config = { 38 "ipv4.address" = "10.0.100.1/24"; 39 "ipv4.nat" = "true"; 40 }; 41 } 42 ]; 43 profiles = [ 44 { 45 name = "default"; 46 devices = { 47 eth0 = { 48 name = "eth0"; 49 network = "nixostestbr0"; 50 type = "nic"; 51 }; 52 root = { 53 path = "/"; 54 pool = "nixostest_pool"; 55 size = "35GiB"; 56 type = "disk"; 57 }; 58 }; 59 } 60 { 61 name = "nixos_notdefault"; 62 devices = { }; 63 } 64 ]; 65 storage_pools = [ 66 { 67 name = "nixostest_pool"; 68 driver = "dir"; 69 } 70 ]; 71 }; 72 73 incus = { 74 enable = true; 75 package = if lts then pkgs.incus-lts else pkgs.incus; 76 }; 77 }; 78 networking.nftables.enable = true; 79 }; 80 81 testScript = '' 82 def lxd_wait_for_preseed(_) -> bool: 83 _, output = machine.systemctl("is-active lxd-preseed.service") 84 return ("inactive" in output) 85 86 def lxd_instance_is_up(_) -> bool: 87 status, _ = machine.execute("lxc exec container --disable-stdin --force-interactive /run/current-system/sw/bin/systemctl -- is-system-running") 88 return status == 0 89 90 def incus_instance_is_up(_) -> bool: 91 status, _ = machine.execute("incus exec container --disable-stdin --force-interactive /run/current-system/sw/bin/systemctl -- is-system-running") 92 return status == 0 93 94 with machine.nested("initialize lxd and resources"): 95 machine.wait_for_unit("sockets.target") 96 machine.wait_for_unit("lxd.service") 97 retry(lxd_wait_for_preseed) 98 99 machine.succeed("lxc image import ${container-image-metadata}/*/*.tar.xz ${container-image-rootfs}/*/*.tar.xz --alias nixos") 100 machine.succeed("lxc launch nixos container") 101 retry(lxd_instance_is_up) 102 103 machine.wait_for_unit("incus.service") 104 105 with machine.nested("run migration"): 106 machine.succeed("${pkgs.incus}/bin/lxd-to-incus --yes") 107 108 with machine.nested("verify resources migrated to incus"): 109 machine.succeed("incus config show container") 110 retry(incus_instance_is_up) 111 machine.succeed("incus exec container -- true") 112 machine.succeed("incus profile show default | grep nixostestbr0") 113 machine.succeed("incus profile show default | grep nixostest_pool") 114 machine.succeed("incus profile show nixos_notdefault") 115 machine.succeed("incus storage show nixostest_pool") 116 machine.succeed("incus network show nixostestbr0") 117 ''; 118 } 119)