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

+13 -11
+4 -2
nixos/lib/make-disk-image.nix
··· 23 postVM ? "" 24 25 , name ? "nixos-disk-image" 26 }: 27 28 with lib; ··· 32 { preVM = 33 '' 34 mkdir $out 35 - diskImage=$out/nixos.img 36 - ${pkgs.vmTools.qemu}/bin/qemu-img create -f raw $diskImage "${toString diskSize}M" 37 mv closure xchg/ 38 ''; 39 buildInputs = [ pkgs.utillinux pkgs.perl pkgs.e2fsprogs pkgs.parted ];
··· 23 postVM ? "" 24 25 , name ? "nixos-disk-image" 26 + 27 + , format ? "raw" 28 }: 29 30 with lib; ··· 34 { preVM = 35 '' 36 mkdir $out 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" 39 mv closure xchg/ 40 ''; 41 buildInputs = [ pkgs.utillinux pkgs.perl pkgs.e2fsprogs pkgs.parted ];
+3 -1
nixos/maintainers/scripts/ec2/amazon-image.nix
··· 10 ]; 11 12 system.build.amazonImage = import ../../../lib/make-disk-image.nix { 13 - inherit pkgs lib config; 14 partitioned = config.ec2.hvm; 15 diskSize = if config.ec2.hvm then 2048 else 8192; 16 configFile = pkgs.writeText "configuration.nix" 17 '' 18 {
··· 10 ]; 11 12 system.build.amazonImage = import ../../../lib/make-disk-image.nix { 13 + inherit lib config; 14 + pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package 15 partitioned = config.ec2.hvm; 16 diskSize = if config.ec2.hvm then 2048 else 8192; 17 + format = "qcow2"; 18 configFile = pkgs.writeText "configuration.nix" 19 '' 20 {
+1 -2
nixos/modules/virtualisation/amazon-image.nix
··· 65 fi 66 67 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" 70 fi 71 72 if ! [ -e "$metaDir/hostname" ]; then
··· 65 fi 66 67 if ! [ -e "$metaDir/user-data" ]; then 68 + wget -q -O "$metaDir/user-data" http://169.254.169.254/1.0/user-data && chmod 600 "$metaDir/user-data" 69 fi 70 71 if ! [ -e "$metaDir/hostname" ]; then
+5 -6
nixos/tests/ec2.nix
··· 11 modules = [ 12 ../maintainers/scripts/ec2/amazon-image.nix 13 ../modules/testing/test-instrumentation.nix 14 - ../modules/profiles/minimal.nix 15 ../modules/profiles/qemu-guest.nix 16 { ec2.hvm = true; 17 ··· 30 metaData = pkgs.stdenv.mkDerivation { 31 name = "metadata"; 32 buildCommand = '' 33 - mkdir -p $out/2011-01-01 34 - ln -s ${pkgs.writeText "userData" userData} $out/2011-01-01/user-data 35 mkdir -p $out/1.0/meta-data 36 echo "${hostname}" > $out/1.0/meta-data/hostname 37 echo "(unknown)" > $out/1.0/meta-data/ami-manifest-path 38 '' + optionalString (sshPublicKey != null) '' ··· 48 my $imageDir = ($ENV{'TMPDIR'} // "/tmp") . "/vm-state-machine"; 49 mkdir $imageDir, 0700; 50 my $diskImage = "$imageDir/machine.qcow2"; 51 - system("qemu-img create -f qcow2 -o backing_file=${image}/nixos.img $diskImage") == 0 or die; 52 system("qemu-img resize $diskImage 10G") == 0 or die; 53 54 # Note: we use net=169.0.0.0/8 rather than ··· 91 ''; 92 script = '' 93 $machine->start; 94 - $machine->waitForFile("/root/user-data"); 95 $machine->waitForUnit("sshd.service"); 96 97 $machine->succeed("grep unknown /etc/ec2-metadata/ami-manifest-path"); ··· 121 # Just to make sure resizing is idempotent. 122 $machine->shutdown; 123 $machine->start; 124 - $machine->waitForFile("/root/user-data"); 125 ''; 126 }; 127 ··· 135 imports = [ 136 <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> 137 <nixpkgs/nixos/modules/testing/test-instrumentation.nix> 138 ]; 139 environment.etc.testFile = { 140 text = "whoa";
··· 11 modules = [ 12 ../maintainers/scripts/ec2/amazon-image.nix 13 ../modules/testing/test-instrumentation.nix 14 ../modules/profiles/qemu-guest.nix 15 { ec2.hvm = true; 16 ··· 29 metaData = pkgs.stdenv.mkDerivation { 30 name = "metadata"; 31 buildCommand = '' 32 mkdir -p $out/1.0/meta-data 33 + ln -s ${pkgs.writeText "userData" userData} $out/1.0/user-data 34 echo "${hostname}" > $out/1.0/meta-data/hostname 35 echo "(unknown)" > $out/1.0/meta-data/ami-manifest-path 36 '' + optionalString (sshPublicKey != null) '' ··· 46 my $imageDir = ($ENV{'TMPDIR'} // "/tmp") . "/vm-state-machine"; 47 mkdir $imageDir, 0700; 48 my $diskImage = "$imageDir/machine.qcow2"; 49 + system("qemu-img create -f qcow2 -o backing_file=${image}/nixos.qcow2 $diskImage") == 0 or die; 50 system("qemu-img resize $diskImage 10G") == 0 or die; 51 52 # Note: we use net=169.0.0.0/8 rather than ··· 89 ''; 90 script = '' 91 $machine->start; 92 + $machine->waitForFile("/etc/ec2-metadata/user-data"); 93 $machine->waitForUnit("sshd.service"); 94 95 $machine->succeed("grep unknown /etc/ec2-metadata/ami-manifest-path"); ··· 119 # Just to make sure resizing is idempotent. 120 $machine->shutdown; 121 $machine->start; 122 + $machine->waitForFile("/etc/ec2-metadata/user-data"); 123 ''; 124 }; 125 ··· 133 imports = [ 134 <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> 135 <nixpkgs/nixos/modules/testing/test-instrumentation.nix> 136 + <nixpkgs/nixos/modules/profiles/qemu-guest.nix> 137 ]; 138 environment.etc.testFile = { 139 text = "whoa";