From a299fc23515d50d8161027af87b649eca27662d8 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 15 Oct 2020 00:24:39 +0200 Subject: [PATCH] nixosTests.cloud-init: test changing hostname actually works --- nixos/tests/cloud-init.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/tests/cloud-init.nix b/nixos/tests/cloud-init.nix index d23e9c64b373..a127be6dd85f 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" + ) ''; }