Change:
Describe the bug On current master (), the ec2 tests don't work: Expected behavior They should work in order to be portable to python, see CCing contributors who wrote/touched this code:

Discussion:
my $imageDir = ($ENV{'TMPDIR'} // "/tmp") . "/vm-state-machine"; mkdir $imageDir, 0700; my $diskImage = "$imageDir/machine.qcow2"; <del> system("qemu-img create -f qcow2 -o backing_file=${image}/nixos.qcow2 $diskImage") == 0 or die; </del> <ins> system("qemu-img create -f qcow2 -o backing_file=${image} $diskImage") == 0 or die; </ins> system("qemu-img resize $diskImage 10G") == 0 or die; # Note: we use net=169.0.0.0/8 rather than

# again when it deletes link-local addresses.) Ideally we'd # turn off the DHCP server, but qemu does not have an option # to do that. <del> my $startCommand = "qemu-kvm -m 768"; </del> <ins> my $startCommand = "qemu-kvm -m 1024"; </ins> $startCommand .= " -device virtio-net-pci,netdev=vlan0"; $startCommand .= " -netdev 'user,id=vlan0,net=169.0.0.0/8,guestfwd=tcp:169.254.169.254:80-cmd:${pkgs.micro-httpd}/bin/micro_httpd ${metaData}'"; $startCommand .= " -drive file=$diskImage,if=virtio,werror=report";

with import common/ec2.nix { inherit makeTest pkgs; }; let <del> image = </del> <ins> imageCfg = </ins> (import ../lib/eval-config.nix { inherit system; modules = [

''; # Needed by nixos-rebuild due to the lack of network <del> # access. Mostly copied from # modules/profiles/installation-device.nix. </del> <ins> # access. Determined by trial and error. </ins> system.extraDependencies = <del> with pkgs; [ stdenv busybox perlPackages.ArchiveCpio unionfs-fuse mkinitcpio-nfs-utils # These are used in the configure-from-userdata tests for EC2. Httpd and valgrind are requested # directly by the configuration we set, and libxslt.bin is used indirectly as a build dependency # of the derivation for dbus configuration files. apacheHttpd valgrind.doc libxslt.bin ]; </del> <ins> with pkgs; ( [ # Needed for a nixos-rebuild. busybox stdenv stdenvNoCC mkinitcpio-nfs-utils unionfs-fuse cloud-utils desktop-file-utils texinfo libxslt.bin xorg.lndir # These are used in the configure-from-userdata tests # for EC2. Httpd and valgrind are requested by the # configuration. apacheHttpd apacheHttpd.doc apacheHttpd.man valgrind.doc ] ); </ins> } ]; <del> }).config.system.build.amazonImage; </del> <ins> }).config; image = "${imageCfg.system.build.amazonImage}/${imageCfg.amazonImage.name}.vhd"; </ins> sshKeys = import ./ssh-keys.nix pkgs; snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;

text = "whoa"; }; <ins> networking.hostName = "ec2-test-vm"; # required by services.httpd </ins> services.httpd = { enable = true; adminAddr = "test@example.org"; <del> virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html"; </del> <ins> virtualHosts.localhost.documentRoot = "''${pkgs.valgrind.doc}/share/doc/valgrind/html"; </ins> }; networking.firewall.allowedTCPPorts = [ 80 ]; } ''; script = '' $machine->start; <ins> # amazon-init must succeed. if it fails, make the test fail # immediately instead of timing out in waitForFile. $machine->waitForUnit('amazon-init.service'); </ins> $machine->waitForFile("/etc/testFile"); $machine->succeed("cat /etc/testFile | grep -q 'whoa'");

../modules/testing/test-instrumentation.nix ../modules/profiles/qemu-guest.nix ]; <del> }).config.system.build.openstackImage; </del> <ins> }).config.system.build.openstackImage + "/nixos.qcow2"; </ins> sshKeys = import ./ssh-keys.nix pkgs; snakeOilPrivateKey = sshKeys.snakeOilPrivateKey.text;