diff --git a/nixos/tests/cloud-init.nix b/nixos/tests/cloud-init.nix index d23e9c64b37..a127be6dd85 100644 --- a/nixos/tests/cloud-init.nix +++ b/nixos/tests/cloud-init.nix @@ -48,7 +48,7 @@ in makeTest { virtualisation.qemu.options = [ "-cdrom" "${metadataDrive}/metadata.iso" ]; services.cloud-init.enable = true; services.openssh.enable = true; - + networking.hostName = ""; }; testScript = '' machine.wait_for_unit("cloud-init.service") @@ -70,5 +70,13 @@ in makeTest { machine.succeed( "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/id_snakeoil nixos@localhost 'true'" ) + + # test changing hostname via cloud-init worked + assert ( + machine.succeed( + "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/id_snakeoil nixos@localhost 'hostname'" + ).strip() + == "test" + ) ''; }