From 8e1a2a415b45014729266017a35c17adfeadcb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Christ?= Date: Wed, 15 Jan 2025 11:53:24 +0100 Subject: [PATCH] test: Confext + Importctl This test uses importctl to import extension images. --- nix/tests/default.nix | 2 +- nix/tests/with-importctl.nix | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 nix/tests/with-importctl.nix diff --git a/nix/tests/default.nix b/nix/tests/default.nix index 5ae00b3..8809e15 100644 --- a/nix/tests/default.nix +++ b/nix/tests/default.nix @@ -28,6 +28,6 @@ in { appliance = runNixosTest ./appliance.nix; basic = runNixosTest ./basic.nix; - + with-importctl = runNixosTest ./with-importctl.nix; } // heavyTests diff --git a/nix/tests/with-importctl.nix b/nix/tests/with-importctl.nix new file mode 100644 index 0000000..c8d94c4 --- /dev/null +++ b/nix/tests/with-importctl.nix @@ -0,0 +1,45 @@ +#This test showcases how you can use importctl to import and apply an extension image from a remote source. + +{ pkgs, ... }: +{ + name = "Extend via importctl"; + nodes = { + machine = + { config, ... }: + { + naext = { + seed = "12345678-1234-1234-1234-123456789123"; + extensions = { + test = { + extensionType = "confext"; + imageFormat = "raw"; + files = { + "/etc/test".source = pkgs.writeText "example" ''Hello''; + }; + }; + }; + }; + services.nginx = { + enable = true; + virtualHosts."localhost" = { + root = pkgs.runCommand "nginx-root" { } '' + mkdir $out + cp ${config.naext.extensions.test.image} $out/test.confext.raw + ''; + }; + }; + + }; + }; + testScript = + _: + # python + '' + machine.wait_for_unit("nginx.service") + machine.succeed("importctl --verify=no --class=confext pull-raw \"http://localhost/test.confext.raw\" test.confext.raw") + machine.succeed("systemd-confext refresh") + machine.wait_for_file("/etc/test") + content=machine.succeed("cat /etc/test") + assert content=="Hello", "File provided by confext has expected content" + ''; +}