git.iko.soy/typeable/nixpkgs
on master help sign in
Fix the EC2 test

We now generate a qcow2 image to prevent hitting Hydra's output size limit. Also updated /root/user-data -> /etc/ec2-metadata/user-data. http://hydra.nixos.org/build/33843133

commit0d3738cdcc48bd32a7eae9b914440b67c8db252e authorEelco Dolstra <eelco.dolstra@logicblox.com> dateWed 30 Mar 2016, 21:48 (11 years ago) parent184b7ba
4 files changed+13−11
nixos/lib/make-disk-image.nix+4−2 nixos/maintainers/scripts/ec2/amazon-image.nix+3−1 nixos/modules/virtualisation/amazon-image.nix+1−2 nixos/tests/ec2.nix+5−6
nixos/lib/make-disk-image.nix+4−2
@@ -23,6 +23,8 @@
2323 postVM ? ""
2424
2525, name ? "nixos-disk-image"
26+
27+, format ? "raw"
2628}:
2729
2830with lib;
@@ -32,8 +34,8 @@ pkgs.vmTools.runInLinuxVM (
3234 { preVM =
3335 ''
3436 mkdir $out
35− diskImage=$out/nixos.img
36− ${pkgs.vmTools.qemu}/bin/qemu-img create -f raw $diskImage "${toString diskSize}M"
37+ diskImage=$out/nixos.${if format == "qcow2" then "qcow2" else "img"}
38+ ${pkgs.vmTools.qemu}/bin/qemu-img create -f ${format} $diskImage "${toString diskSize}M"
3739 mv closure xchg/
3840 '';
3941 buildInputs = [ pkgs.utillinux pkgs.perl pkgs.e2fsprogs pkgs.parted ];
nixos/maintainers/scripts/ec2/amazon-image.nix+3−1
@@ -10,9 +10,11 @@ with lib;
1010 ];
1111
1212 system.build.amazonImage = import ../../../lib/make-disk-image.nix {
13− inherit pkgs lib config;
13+ inherit lib config;
14+ pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
1415 partitioned = config.ec2.hvm;
1516 diskSize = if config.ec2.hvm then 2048 else 8192;
17+ format = "qcow2";
1618 configFile = pkgs.writeText "configuration.nix"
1719 ''
1820 {
nixos/modules/virtualisation/amazon-image.nix+1−2
@@ -65,8 +65,7 @@ let cfg = config.ec2; in
6565 fi
6666
6767 if ! [ -e "$metaDir/user-data" ]; then
68− wget -q -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data
69− chmod 600 "$metaDir/user-data"
68+ wget -q -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data && chmod 600 "$metaDir/user-data"
7069 fi
7170
7271 if ! [ -e "$metaDir/hostname" ]; then
nixos/tests/ec2.nix+5−6
@@ -11,7 +11,6 @@ let
1111 modules = [
1212 ../maintainers/scripts/ec2/amazon-image.nix
1313 ../modules/testing/test-instrumentation.nix
14− ../modules/profiles/minimal.nix
1514 ../modules/profiles/qemu-guest.nix
1615 { ec2.hvm = true;
1716
@@ -30,9 +29,8 @@ let
3029 metaData = pkgs.stdenv.mkDerivation {
3130 name = "metadata";
3231 buildCommand = ''
33− mkdir -p $out/2011-01-01
34− ln -s ${pkgs.writeText "userData" userData} $out/2011-01-01/user-data
3532 mkdir -p $out/1.0/meta-data
33+ ln -s ${pkgs.writeText "userData" userData} $out/1.0/user-data
3634 echo "${hostname}" > $out/1.0/meta-data/hostname
3735 echo "(unknown)" > $out/1.0/meta-data/ami-manifest-path
3836 '' + optionalString (sshPublicKey != null) ''
@@ -48,7 +46,7 @@ let
4846 my $imageDir = ($ENV{'TMPDIR'} // "/tmp") . "/vm-state-machine";
4947 mkdir $imageDir, 0700;
5048 my $diskImage = "$imageDir/machine.qcow2";
51− system("qemu-img create -f qcow2 -o backing_file=${image}/nixos.img $diskImage") == 0 or die;
49+ system("qemu-img create -f qcow2 -o backing_file=${image}/nixos.qcow2 $diskImage") == 0 or die;
5250 system("qemu-img resize $diskImage 10G") == 0 or die;
5351
5452 # Note: we use net=169.0.0.0/8 rather than
@@ -91,7 +89,7 @@ in {
9189 '';
9290 script = ''
9391 $machine->start;
94− $machine->waitForFile("/root/user-data");
92+ $machine->waitForFile("/etc/ec2-metadata/user-data");
9593 $machine->waitForUnit("sshd.service");
9694
9795 $machine->succeed("grep unknown /etc/ec2-metadata/ami-manifest-path");
@@ -121,7 +119,7 @@ in {
121119 # Just to make sure resizing is idempotent.
122120 $machine->shutdown;
123121 $machine->start;
124− $machine->waitForFile("/root/user-data");
122+ $machine->waitForFile("/etc/ec2-metadata/user-data");
125123 '';
126124 };
127125
@@ -135,6 +133,7 @@ in {
135133 imports = [
136134 <nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
137135 <nixpkgs/nixos/modules/testing/test-instrumentation.nix>
136+ <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
138137 ];
139138 environment.etc.testFile = {
140139 text = "whoa";