From 448b9932dfbcc88cb58481240fc739b5793158fc Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Mon, 16 Dec 2024 15:43:53 +0100 Subject: [PATCH 1/4] nixos/tests/ec2: remove ec2-config test It has been broken for as long as I know --- nixos/tests/all-tests.nix | 3 +- nixos/tests/ec2.nix | 71 +-------------------------------------- 2 files changed, 2 insertions(+), 72 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 1eed27e00a54..d43b601b5dee 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -489,9 +489,8 @@ in early-mount-options = runTest ./early-mount-options.nix; earlyoom = runTestOn [ "x86_64-linux" ] ./earlyoom.nix; easytier = runTest ./easytier.nix; - ec2-config = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-config or { }; ec2-image = runTest ./ec2-image.nix; - ec2-nixops = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-nixops or { }; + ec2-nixops = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).ec2-nixops or { }; echoip = runTest ./echoip.nix; ejabberd = runTest ./xmpp/ejabberd.nix; elk = handleTestOn [ "x86_64-linux" ] ./elk.nix { }; diff --git a/nixos/tests/ec2.nix b/nixos/tests/ec2.nix index ae9a79db5403..e38057e6d8ae 100644 --- a/nixos/tests/ec2.nix +++ b/nixos/tests/ec2.nix @@ -31,30 +31,6 @@ let # the configuration in virtualisation/amazon-image.nix. systemd.services."serial-getty@ttyS0".enable = mkForce false; - # Needed by nixos-rebuild due to the lack of network - # access. Determined by trial and error. - system.extraDependencies = with pkgs; [ - # Needed for a nixos-rebuild. - busybox - cloud-utils - desktop-file-utils - libxslt.bin - mkinitcpio-nfs-utils - stdenv - stdenvNoCC - texinfo - unionfs-fuse - 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 - ]; - nixpkgs.pkgs = pkgs; } ]; @@ -68,7 +44,7 @@ let in { - boot-ec2-nixops = makeEc2Test { + ec2-nixops = makeEc2Test { name = "nixops-userdata"; meta.timeout = 600; inherit image; @@ -116,49 +92,4 @@ in machine.wait_for_file("/etc/ec2-metadata/user-data") ''; }; - - boot-ec2-config = makeEc2Test { - name = "config-userdata"; - meta.broken = true; # amazon-init wants to download from the internet while building the system - inherit image; - sshPublicKey = snakeOilPublicKey; - - # ### https://channels.nixos.org/nixos-unstable nixos - userData = '' - { pkgs, ... }: - - { - imports = [ - - - - ]; - environment.etc.testFile = { - text = "whoa"; - }; - - networking.hostName = "ec2-test-vm"; # required by services.httpd - - services.httpd = { - enable = true; - adminAddr = "test@example.org"; - virtualHosts.localhost.documentRoot = "''${pkgs.valgrind.doc}/share/doc/valgrind/html"; - }; - networking.firewall.allowedTCPPorts = [ 80 ]; - } - ''; - script = '' - machine.start() - - # amazon-init must succeed. if it fails, make the test fail - # immediately instead of timing out in wait_for_file. - machine.wait_for_unit("amazon-init.service") - - machine.wait_for_file("/etc/testFile") - assert "whoa" in machine.succeed("cat /etc/testFile") - - machine.wait_for_unit("httpd.service") - assert "Valgrind" in machine.succeed("curl http://localhost") - ''; - }; } From 0e37e9beff812878cf2a18ccfd4dc4d985fa6e69 Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Mon, 16 Dec 2024 15:45:45 +0100 Subject: [PATCH 2/4] nixos/tests/ec2: rename ec2-nixops to ec2-userdata This is more accurate. People dismissed failures in the past in this test because of the name. We don't want that. The test is important! It tests that SSH works! Hopefully this helps with https://github.com/NixOS/nixpkgs/pull/340489#issuecomment-2531494744 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/ec2.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index d43b601b5dee..187fdb17a0ad 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -490,7 +490,7 @@ in earlyoom = runTestOn [ "x86_64-linux" ] ./earlyoom.nix; easytier = runTest ./easytier.nix; ec2-image = runTest ./ec2-image.nix; - ec2-nixops = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).ec2-nixops or { }; + ec2-userdata = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).ec2-userdata or { }; echoip = runTest ./echoip.nix; ejabberd = runTest ./xmpp/ejabberd.nix; elk = handleTestOn [ "x86_64-linux" ] ./elk.nix { }; diff --git a/nixos/tests/ec2.nix b/nixos/tests/ec2.nix index e38057e6d8ae..e80d7de02f22 100644 --- a/nixos/tests/ec2.nix +++ b/nixos/tests/ec2.nix @@ -44,8 +44,8 @@ let in { - ec2-nixops = makeEc2Test { - name = "nixops-userdata"; + ec2-userdata = makeEc2Test { + name = "ec2-userdata"; meta.timeout = 600; inherit image; sshPublicKey = snakeOilPublicKey; # That's right folks! My user's key is also the host key! From 7ab9b03f5b069c2b932845d0e1a1858d0418789b Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Mon, 16 Dec 2024 15:49:46 +0100 Subject: [PATCH 3/4] nixos/tests/ec2: remove hack Not needed anymore. no idea why this was here --- nixos/tests/ec2.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nixos/tests/ec2.nix b/nixos/tests/ec2.nix index e80d7de02f22..c8c26be813cd 100644 --- a/nixos/tests/ec2.nix +++ b/nixos/tests/ec2.nix @@ -18,12 +18,6 @@ let ../modules/testing/test-instrumentation.nix ../modules/profiles/qemu-guest.nix { - # Hack to make the partition resizing work in QEMU. - boot.initrd.postDeviceCommands = mkBefore '' - ln -s vda /dev/xvda - ln -s vda1 /dev/xvda1 - ''; - amazonImage.format = "qcow2"; # In a NixOS test the serial console is occupied by the "backdoor" From c5d4a896c5043f15ae78e69237e6406ec31186c0 Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Mon, 16 Dec 2024 16:01:47 +0100 Subject: [PATCH 4/4] nixos/release-combined: add nixos.tests.ec2-userdata This is to catch issues like https://github.com/NixOS/nixpkgs/pull/340489#issuecomment-253149474 We do not want to push NixOS updates that break SSH access on EC2 instances. --- nixos/release-combined.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix index d299ead82a1b..2289d9156d0d 100644 --- a/nixos/release-combined.nix +++ b/nixos/release-combined.nix @@ -87,6 +87,7 @@ rec { (onFullSupported "nixos.tests.containers-ip") (onSystems [ "x86_64-linux" ] "nixos.tests.docker") (onFullSupported "nixos.tests.env") + (onSystems [ "x86_64-linux" "aarch64-linux" ] "nixos.tests.ec2-userdata") # Way too many manual retries required on Hydra. # Apparently it's hard to track down the cause.