summary refs log tree commit diff
path: root/nixos/tests/cloud-init.nix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2020-10-15 00:24:39 +0200
committerFlorian Klink <flokli@flokli.de>2020-10-15 01:03:13 +0200
commita299fc23515d50d8161027af87b649eca27662d8 (patch)
tree7e3fdf6958aaf213e5756fefaee6f8989f5dcfaa /nixos/tests/cloud-init.nix
parent00347e9537d6e6ddef599094429a1ac5392d6f28 (diff)
nixosTests.cloud-init: test changing hostname actually works
Diffstat (limited to 'nixos/tests/cloud-init.nix')
-rw-r--r--nixos/tests/cloud-init.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/nixos/tests/cloud-init.nix b/nixos/tests/cloud-init.nix
index d23e9c64b373d..a127be6dd85f1 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"
+    )
   '';
 }