From abb345f6caff2d986b6c8d9afa55f3be02379608 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 13 Mar 2025 23:18:09 +0100 Subject: [PATCH] nixosTests.amazon-init-shell: migrate to runTest Part Of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/amazon-init-shell.nix | 48 ++++++++++++++----------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 3dc4798e7303..5316fdd7cb76 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -163,7 +163,7 @@ in { allTerminfo = runTest ./all-terminfo.nix; alps = runTest ./alps.nix; amazon-cloudwatch-agent = runTest ./amazon-cloudwatch-agent.nix; - amazon-init-shell = handleTest ./amazon-init-shell.nix {}; + amazon-init-shell = runTest ./amazon-init-shell.nix; amazon-ssm-agent = handleTest ./amazon-ssm-agent.nix {}; amd-sev = runTest ./amd-sev.nix; angie-api = handleTest ./angie-api.nix {}; diff --git a/nixos/tests/amazon-init-shell.nix b/nixos/tests/amazon-init-shell.nix index f79cd0364684..e051faa4e2f1 100644 --- a/nixos/tests/amazon-init-shell.nix +++ b/nixos/tests/amazon-init-shell.nix @@ -6,41 +6,35 @@ # configuration expression. { - system ? builtins.currentSystem, - config ? { }, - pkgs ? import ../.. { inherit system config; }, + lib, + ... }: -with import ../lib/testing-python.nix { inherit system pkgs; }; -with pkgs.lib; - -makeTest { +{ name = "amazon-init"; - meta = with maintainers; { + meta = with lib.maintainers; { maintainers = [ urbas ]; }; - nodes.machine = - { lib, pkgs, ... }: - { - imports = [ - ../modules/profiles/headless.nix - ../modules/virtualisation/amazon-init.nix - ]; - services.openssh.enable = true; - system.switch.enable = true; - networking.hostName = ""; - environment.etc."ec2-metadata/user-data" = { - text = '' - #!/usr/bin/bash + nodes.machine = { + imports = [ + ../modules/profiles/headless.nix + ../modules/virtualisation/amazon-init.nix + ]; + services.openssh.enable = true; + system.switch.enable = true; + networking.hostName = ""; + environment.etc."ec2-metadata/user-data" = { + text = '' + #!/usr/bin/bash - echo successful > /tmp/evidence + echo successful > /tmp/evidence - # Emulate running nixos-rebuild switch, just without any building. - # https://github.com/nixos/nixpkgs/blob/4c62505847d88f16df11eff3c81bf9a453a4979e/nixos/modules/virtualisation/amazon-init.nix#L55 - /run/current-system/bin/switch-to-configuration test - ''; - }; + # Emulate running nixos-rebuild switch, just without any building. + # https://github.com/nixos/nixpkgs/blob/4c62505847d88f16df11eff3c81bf9a453a4979e/nixos/modules/virtualisation/amazon-init.nix#L55 + /run/current-system/bin/switch-to-configuration test + ''; }; + }; testScript = '' # To wait until amazon-init terminates its run unnamed.wait_for_unit("amazon-init.service")