mirror of
https://github.com/nix-community/nixos-anywhere.git
synced 2024-08-15 19:30:31 +03:00
add nixos test fro build-on-remote
This commit is contained in:
parent
7671a880e3
commit
d2911784c3
@ -18,5 +18,7 @@
|
|||||||
from-nixos-stable = import ./from-nixos.nix testInputsStable;
|
from-nixos-stable = import ./from-nixos.nix testInputsStable;
|
||||||
from-nixos-with-sudo = import ./from-nixos-with-sudo.nix testInputsUnstable;
|
from-nixos-with-sudo = import ./from-nixos-with-sudo.nix testInputsUnstable;
|
||||||
from-nixos-with-sudo-stable = import ./from-nixos-with-sudo.nix testInputsStable;
|
from-nixos-with-sudo-stable = import ./from-nixos-with-sudo.nix testInputsStable;
|
||||||
|
|
||||||
|
from-nixos-build-on-remote = import ./from-nixos-build-on-remote.nix testInputsUnstable;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
43
tests/from-nixos-build-on-remote.nix
Normal file
43
tests/from-nixos-build-on-remote.nix
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
(import ./lib/test-base.nix) {
|
||||||
|
name = "from-nixos-build-on-remote";
|
||||||
|
nodes = {
|
||||||
|
installer = ./modules/installer.nix;
|
||||||
|
installed = {
|
||||||
|
services.openssh.enable = true;
|
||||||
|
virtualisation.memorySize = 1512;
|
||||||
|
|
||||||
|
users.users.root.openssh.authorizedKeys.keyFiles = [ ./modules/ssh-keys/ssh.pub ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
def create_test_machine(oldmachine=None, args={}): # taken from <nixpkgs/nixos/tests/installer.nix>
|
||||||
|
machine = create_machine({
|
||||||
|
"qemuFlags":
|
||||||
|
'-cpu max -m 1024 -virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store,'
|
||||||
|
f' -drive file={oldmachine.state_dir}/installed.qcow2,id=drive1,if=none,index=1,werror=report'
|
||||||
|
f' -device virtio-blk-pci,drive=drive1',
|
||||||
|
} | args)
|
||||||
|
driver.machines.append(machine)
|
||||||
|
return machine
|
||||||
|
start_all()
|
||||||
|
|
||||||
|
installer.succeed("""
|
||||||
|
nixos-anywhere \
|
||||||
|
-i /root/.ssh/install_key \
|
||||||
|
--debug \
|
||||||
|
--build-on-remote \
|
||||||
|
--kexec /etc/nixos-anywhere/kexec-installer \
|
||||||
|
--store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
|
||||||
|
root@installed >&2
|
||||||
|
""")
|
||||||
|
try:
|
||||||
|
installed.shutdown()
|
||||||
|
except BrokenPipeError:
|
||||||
|
# qemu has already exited
|
||||||
|
pass
|
||||||
|
new_machine = create_test_machine(oldmachine=installed, args={ "name": "after_install" })
|
||||||
|
new_machine.start()
|
||||||
|
hostname = new_machine.succeed("hostname").strip()
|
||||||
|
assert "nixos-anywhere" == hostname, f"'nixos-anywhere' != '{hostname}'"
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user