nixosTests.cloud-init: test changing hostname actually works

This commit is contained in:
Florian Klink 2020-10-15 00:24:39 +02:00
parent 00347e9537
commit a299fc2351

View File

@ -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"
)
'';
}