Skip to content

Commit

Permalink
Merge pull request #2 from frederictobiasc/tests/importctl
Browse files Browse the repository at this point in the history
Test integration with importctl
  • Loading branch information
frederictobiasc authored Jan 15, 2025
2 parents b22021c + 8e1a2a4 commit 7d44684
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nix/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ in
{
appliance = runNixosTest ./appliance.nix;
basic = runNixosTest ./basic.nix;

with-importctl = runNixosTest ./with-importctl.nix;
}
// heavyTests
45 changes: 45 additions & 0 deletions nix/tests/with-importctl.nix
Original file line number Diff line number Diff line change
@@ -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"
'';
}

0 comments on commit 7d44684

Please sign in to comment.