summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeon Barrett <Leon.Barrett@sony.com>2023-04-15 17:27:20 -0700
committerLeon Barrett <Leon.Barrett@sony.com>2023-04-16 09:54:10 -0700
commita711e445cc057ac06160816b848f5752a6b4b753 (patch)
tree87489659de14e8a1daa0e260c5ede6edab5615ce
parentb9f6082ee1e5079045513ea885935f6589306c13 (diff)
downloadnixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.tar
nixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.tar.gz
nixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.tar.bz2
nixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.tar.lz
nixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.tar.xz
nixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.tar.zst
nixpkgs-a711e445cc057ac06160816b848f5752a6b4b753.zip
nixos/tests/ec2: Fix test tooling
This change fixes two problems with the qemu testing code:
1. Previously, the qemu-img command was missing a disk image format
   argument.
2. Previously, if a test assertion failed, the test hung because the VM
   was not torn down.
-rw-r--r--nixos/tests/common/ec2.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/nixos/tests/common/ec2.nix b/nixos/tests/common/ec2.nix
index 6ed420e0aae..1a64c464039 100644
--- a/nixos/tests/common/ec2.nix
+++ b/nixos/tests/common/ec2.nix
@@ -17,6 +17,7 @@ with pkgs.lib;
           ln -s ${pkgs.writeText "sshPublicKey" sshPublicKey} $out/1.0/meta-data/public-keys/0/openssh-key
         '';
       };
+      indentLines = str: concatLines (map (s: "  " + s) (splitString "\n" str));
     in makeTest {
       name = "ec2-" + name;
       nodes = {};
@@ -36,6 +37,8 @@ with pkgs.lib;
                 "create",
                 "-f",
                 "qcow2",
+                "-F",
+                "qcow2",
                 "-o",
                 "backing_file=${image}",
                 disk_image,
@@ -59,7 +62,11 @@ with pkgs.lib;
         )
 
         machine = create_machine({"startCommand": start_command})
-      '' + script;
+        try:
+      '' + indentLines script + ''
+        finally:
+          machine.shutdown()
+      '';
 
       inherit meta;
     };