Add Aarch64 tests and include multiple test images. (#9)
This commit is contained in:
parent
804f9b947f
commit
af43744006
4 changed files with 175 additions and 133 deletions
75
examples/example.nix
Normal file
75
examples/example.nix
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
{ lib, pkgs, ... }: {
|
||||
config = {
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
services.nginx.enable = true;
|
||||
|
||||
environment.etc = {
|
||||
foo = {
|
||||
text = ''
|
||||
This is just a test!
|
||||
'';
|
||||
target = "foo_test";
|
||||
};
|
||||
|
||||
"foo.conf".text = ''
|
||||
launch_the_rockets = true
|
||||
'';
|
||||
|
||||
"baz/bar/foo2" = {
|
||||
text = ''
|
||||
Another test!
|
||||
'';
|
||||
mode = "symlink";
|
||||
};
|
||||
|
||||
foo3 = {
|
||||
text = "boo!";
|
||||
mode = "0700";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
"a/nested/example/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
"a/nested/example2/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
out-of-store = {
|
||||
source = "/run/systemd/system/";
|
||||
};
|
||||
};
|
||||
systemd.services =
|
||||
lib.listToAttrs
|
||||
(lib.flip lib.genList 10 (ix:
|
||||
lib.nameValuePair "service-${toString ix}"
|
||||
{
|
||||
enable = true;
|
||||
description = "service-${toString ix}";
|
||||
wants = [ "network-online.target" ];
|
||||
after = [
|
||||
"network-online.target"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecReload = "${lib.getBin pkgs.coreutils}/bin/true";
|
||||
};
|
||||
wantedBy = [ "system-manager.target" ];
|
||||
requiredBy = lib.mkIf (ix > 5) [ "service-0.service" ];
|
||||
script = ''
|
||||
sleep ${if ix > 5 then "2" else "1"}
|
||||
'';
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
27
flake.nix
27
flake.nix
|
|
@ -186,16 +186,23 @@
|
|||
}).shellHook;
|
||||
};
|
||||
|
||||
checks = {
|
||||
inherit
|
||||
# Build the crate as part of `nix flake check` for convenience
|
||||
system-manager
|
||||
system-manager-clippy
|
||||
system-manager-test;
|
||||
basicTest = import ./test/nix/modules {
|
||||
checks =
|
||||
let
|
||||
# The Aarch64 VM tests seem to hang on garnix, we disable them for now
|
||||
enableVmTests = system != flake-utils.lib.system.aarch64-linux;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
# Build the crate as part of `nix flake check` for convenience
|
||||
system-manager
|
||||
system-manager-clippy
|
||||
system-manager-test;
|
||||
} //
|
||||
pkgs.lib.optionalAttrs enableVmTests (import ./test/nix/modules {
|
||||
inherit system;
|
||||
inherit (pkgs) lib;
|
||||
system-manager = self;
|
||||
};
|
||||
};
|
||||
}));
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
|||
58
nix/lib.nix
58
nix/lib.nix
|
|
@ -175,17 +175,51 @@ in
|
|||
]
|
||||
);
|
||||
|
||||
images = {
|
||||
ubuntu_22_10_cloudimg = {
|
||||
name = "ubuntu-22.10-server-cloudimg-amd64.img";
|
||||
release = "20230302";
|
||||
hash = "sha256-9hjGjlUQoXZfAYTwsEjHE3Zawd6qqrVc6VXshthNS44=";
|
||||
};
|
||||
# TODO: put these in an external JSON file that we can automatically update
|
||||
images.ubuntu = {
|
||||
x86_64-linux = {
|
||||
ubuntu_22_10_cloudimg = {
|
||||
name = "kinetic-server-cloudimg-amd64.img";
|
||||
releaseName = "kinetic";
|
||||
releaseTimeStamp = "20230424";
|
||||
hash = "sha256-54LucfgXtNAxKKQKmvHCk8EzPRlULGq/IfUjAvUaOXk=";
|
||||
};
|
||||
|
||||
ubuntu_20_04_cloudimg = {
|
||||
name = "ubuntu-20.04-server-cloudimg-amd64.img";
|
||||
release = "";
|
||||
hash = "";
|
||||
ubuntu_22_04_cloudimg = {
|
||||
name = "jammy-server-cloudimg-amd64.img";
|
||||
releaseName = "jammy";
|
||||
releaseTimeStamp = "20230427";
|
||||
hash = "sha256-m76TZOKYnBzOLBZpt6kcK70TkFKHaoyBzVLA+q77ZHQ=";
|
||||
};
|
||||
|
||||
ubuntu_20_04_cloudimg = {
|
||||
name = "focal-server-cloudimg-amd64.img";
|
||||
releaseName = "focal";
|
||||
releaseTimeStamp = "20230420";
|
||||
hash = "sha256-XFUVWvk8O1IHfp+sAiOSCU5ASk/qJG2JIF4WH0ex12U=";
|
||||
};
|
||||
};
|
||||
aarch64-linux = {
|
||||
ubuntu_22_10_cloudimg = {
|
||||
name = "kinetic-server-cloudimg-arm64.img";
|
||||
releaseName = "kinetic";
|
||||
releaseTimeStamp = "20230424";
|
||||
hash = "sha256-AS8bXXqWwJdlKUYxI1MO48AyWR++Ttf1+C7ahicKiks=";
|
||||
};
|
||||
|
||||
ubuntu_22_04_cloudimg = {
|
||||
name = "jammy-server-cloudimg-arm64.img";
|
||||
releaseName = "jammy";
|
||||
releaseTimeStamp = "20230427";
|
||||
hash = "sha256-9vkeg5VumVBxj4TaLd0SgJEWjw11pcP7SBz5zd1V0EE=";
|
||||
};
|
||||
|
||||
ubuntu_20_04_cloudimg = {
|
||||
name = "focal-server-cloudimg-arm64.img";
|
||||
releaseName = "focal";
|
||||
releaseTimeStamp = "20230420";
|
||||
hash = "sha256-YUtW3oMHz4Hw7WeIu6ksx+/mUfxp7cCSSETvY6KGwU4=";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -197,7 +231,7 @@ in
|
|||
[Service]
|
||||
Type = oneshot
|
||||
ExecStart = mkdir -p /nix/.ro-store
|
||||
ExecStart = mount -t 9p -o defaults,trans=virtio,version=9p2000.L,cache=loose nix-store /nix/.ro-store
|
||||
ExecStart = mount -t 9p -o defaults,trans=virtio,version=9p2000.L,cache=loose,msize=${toString (256 * 1024 * 1024)} nix-store /nix/.ro-store
|
||||
ExecStart = mkdir -p -m 0755 /nix/.rw-store/ /nix/store
|
||||
ExecStart = mount -t tmpfs tmpfs /nix/.rw-store
|
||||
ExecStart = mkdir -p -m 0755 /nix/.rw-store/store /nix/.rw-store/work
|
||||
|
|
@ -258,7 +292,7 @@ in
|
|||
|
||||
img = pkgs.fetchurl {
|
||||
inherit (image) hash;
|
||||
url = "https://cloud-images.ubuntu.com/releases/kinetic/release-${image.release}/${image.name}";
|
||||
url = "https://cloud-images.ubuntu.com/${image.releaseName}/${image.releaseTimeStamp}/${image.name}";
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "configure-vm" { } ''
|
||||
|
|
|
|||
|
|
@ -1,121 +1,47 @@
|
|||
{ system-manager
|
||||
{ lib
|
||||
, system-manager
|
||||
, system
|
||||
}:
|
||||
|
||||
let
|
||||
testConfig = { lib, pkgs, ... }: {
|
||||
config = {
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
lib.flip lib.mapAttrs' system-manager.lib.images.ubuntu.${system} (imgName: image:
|
||||
lib.nameValuePair "example-${imgName}"
|
||||
(system-manager.lib.make-vm-test {
|
||||
inherit system;
|
||||
modules = [
|
||||
({ config, ... }:
|
||||
let
|
||||
inherit (config) hostPkgs;
|
||||
in
|
||||
{
|
||||
nodes = {
|
||||
node1 = { config, ... }: {
|
||||
modules = [
|
||||
../../../examples/example.nix
|
||||
];
|
||||
|
||||
services.nginx.enable = true;
|
||||
|
||||
environment.etc = {
|
||||
foo = {
|
||||
text = ''
|
||||
This is just a test!
|
||||
'';
|
||||
target = "foo_test";
|
||||
};
|
||||
|
||||
"foo.conf".text = ''
|
||||
launch_the_rockets = true
|
||||
'';
|
||||
|
||||
"baz/bar/foo2" = {
|
||||
text = ''
|
||||
Another test!
|
||||
'';
|
||||
mode = "symlink";
|
||||
};
|
||||
|
||||
foo3 = {
|
||||
text = "boo!";
|
||||
mode = "0700";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
"a/nested/example/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
"a/nested/example2/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
out-of-store = {
|
||||
source = "/run/systemd/system/";
|
||||
};
|
||||
};
|
||||
systemd.services =
|
||||
lib.listToAttrs
|
||||
(lib.flip lib.genList 10 (ix:
|
||||
lib.nameValuePair "service-${toString ix}"
|
||||
{
|
||||
enable = true;
|
||||
description = "service-${toString ix}";
|
||||
wants = [ "network-online.target" ];
|
||||
after = [
|
||||
"network-online.target"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecReload = "${lib.getBin pkgs.coreutils}/bin/true";
|
||||
};
|
||||
wantedBy = [ "system-manager.target" ];
|
||||
requiredBy = lib.mkIf (ix > 5) [ "service-0.service" ];
|
||||
script = ''
|
||||
sleep ${if ix > 5 then "2" else "1"}
|
||||
'';
|
||||
})
|
||||
);
|
||||
};
|
||||
};
|
||||
in
|
||||
system-manager.lib.make-vm-test {
|
||||
inherit system;
|
||||
modules = [
|
||||
({ config, ... }:
|
||||
let
|
||||
inherit (config) hostPkgs;
|
||||
in
|
||||
{
|
||||
nodes = {
|
||||
node1 = { config, ... }: {
|
||||
modules = [
|
||||
testConfig
|
||||
];
|
||||
|
||||
virtualisation.rootImage = system-manager.lib.prepareUbuntuImage {
|
||||
inherit hostPkgs;
|
||||
nodeConfig = config;
|
||||
image = system-manager.lib.images.ubuntu_22_10_cloudimg;
|
||||
virtualisation.rootImage = system-manager.lib.prepareUbuntuImage {
|
||||
inherit hostPkgs image;
|
||||
nodeConfig = config;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
# Start all machines in parallel
|
||||
start_all()
|
||||
testScript = ''
|
||||
# Start all machines in parallel
|
||||
start_all()
|
||||
|
||||
node1.wait_for_unit("default.target")
|
||||
node1.wait_for_unit("default.target")
|
||||
|
||||
node1.execute("/system-manager-profile/bin/activate")
|
||||
node1.wait_for_unit("system-manager.target")
|
||||
node1.execute("/system-manager-profile/bin/activate")
|
||||
node1.wait_for_unit("system-manager.target")
|
||||
|
||||
node1.wait_for_unit("service-9.service")
|
||||
node1.wait_for_file("/etc/baz/bar/foo2")
|
||||
node1.wait_for_file("/etc/foo.conf")
|
||||
node1.succeed("grep -F 'launch_the_rockets = true' /etc/foo.conf")
|
||||
node1.fail("grep -F 'launch_the_rockets = false' /etc/foo.conf")
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
node1.wait_for_unit("service-9.service")
|
||||
node1.wait_for_file("/etc/baz/bar/foo2")
|
||||
node1.wait_for_file("/etc/foo.conf")
|
||||
node1.succeed("grep -F 'launch_the_rockets = true' /etc/foo.conf")
|
||||
node1.fail("grep -F 'launch_the_rockets = false' /etc/foo.conf")
|
||||
'';
|
||||
})
|
||||
];
|
||||
})
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue