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"}
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
17
flake.nix
17
flake.nix
|
|
@ -186,16 +186,23 @@
|
||||||
}).shellHook;
|
}).shellHook;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = {
|
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
|
inherit
|
||||||
# Build the crate as part of `nix flake check` for convenience
|
# Build the crate as part of `nix flake check` for convenience
|
||||||
system-manager
|
system-manager
|
||||||
system-manager-clippy
|
system-manager-clippy
|
||||||
system-manager-test;
|
system-manager-test;
|
||||||
basicTest = import ./test/nix/modules {
|
} //
|
||||||
|
pkgs.lib.optionalAttrs enableVmTests (import ./test/nix/modules {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
inherit (pkgs) lib;
|
||||||
system-manager = self;
|
system-manager = self;
|
||||||
};
|
});
|
||||||
};
|
})
|
||||||
}));
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
52
nix/lib.nix
52
nix/lib.nix
|
|
@ -175,17 +175,51 @@ in
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
images = {
|
# TODO: put these in an external JSON file that we can automatically update
|
||||||
|
images.ubuntu = {
|
||||||
|
x86_64-linux = {
|
||||||
ubuntu_22_10_cloudimg = {
|
ubuntu_22_10_cloudimg = {
|
||||||
name = "ubuntu-22.10-server-cloudimg-amd64.img";
|
name = "kinetic-server-cloudimg-amd64.img";
|
||||||
release = "20230302";
|
releaseName = "kinetic";
|
||||||
hash = "sha256-9hjGjlUQoXZfAYTwsEjHE3Zawd6qqrVc6VXshthNS44=";
|
releaseTimeStamp = "20230424";
|
||||||
|
hash = "sha256-54LucfgXtNAxKKQKmvHCk8EzPRlULGq/IfUjAvUaOXk=";
|
||||||
|
};
|
||||||
|
|
||||||
|
ubuntu_22_04_cloudimg = {
|
||||||
|
name = "jammy-server-cloudimg-amd64.img";
|
||||||
|
releaseName = "jammy";
|
||||||
|
releaseTimeStamp = "20230427";
|
||||||
|
hash = "sha256-m76TZOKYnBzOLBZpt6kcK70TkFKHaoyBzVLA+q77ZHQ=";
|
||||||
};
|
};
|
||||||
|
|
||||||
ubuntu_20_04_cloudimg = {
|
ubuntu_20_04_cloudimg = {
|
||||||
name = "ubuntu-20.04-server-cloudimg-amd64.img";
|
name = "focal-server-cloudimg-amd64.img";
|
||||||
release = "";
|
releaseName = "focal";
|
||||||
hash = "";
|
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]
|
[Service]
|
||||||
Type = oneshot
|
Type = oneshot
|
||||||
ExecStart = mkdir -p /nix/.ro-store
|
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 = mkdir -p -m 0755 /nix/.rw-store/ /nix/store
|
||||||
ExecStart = mount -t tmpfs tmpfs /nix/.rw-store
|
ExecStart = mount -t tmpfs tmpfs /nix/.rw-store
|
||||||
ExecStart = mkdir -p -m 0755 /nix/.rw-store/store /nix/.rw-store/work
|
ExecStart = mkdir -p -m 0755 /nix/.rw-store/store /nix/.rw-store/work
|
||||||
|
|
@ -258,7 +292,7 @@ in
|
||||||
|
|
||||||
img = pkgs.fetchurl {
|
img = pkgs.fetchurl {
|
||||||
inherit (image) hash;
|
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
|
in
|
||||||
pkgs.runCommand "configure-vm" { } ''
|
pkgs.runCommand "configure-vm" { } ''
|
||||||
|
|
|
||||||
|
|
@ -1,85 +1,11 @@
|
||||||
{ system-manager
|
{ lib
|
||||||
|
, system-manager
|
||||||
, system
|
, system
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
lib.flip lib.mapAttrs' system-manager.lib.images.ubuntu.${system} (imgName: image:
|
||||||
testConfig = { lib, pkgs, ... }: {
|
lib.nameValuePair "example-${imgName}"
|
||||||
config = {
|
(system-manager.lib.make-vm-test {
|
||||||
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"}
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
system-manager.lib.make-vm-test {
|
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
modules = [
|
||||||
({ config, ... }:
|
({ config, ... }:
|
||||||
|
|
@ -90,13 +16,12 @@ system-manager.lib.make-vm-test {
|
||||||
nodes = {
|
nodes = {
|
||||||
node1 = { config, ... }: {
|
node1 = { config, ... }: {
|
||||||
modules = [
|
modules = [
|
||||||
testConfig
|
../../../examples/example.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
virtualisation.rootImage = system-manager.lib.prepareUbuntuImage {
|
virtualisation.rootImage = system-manager.lib.prepareUbuntuImage {
|
||||||
inherit hostPkgs;
|
inherit hostPkgs image;
|
||||||
nodeConfig = config;
|
nodeConfig = config;
|
||||||
image = system-manager.lib.images.ubuntu_22_10_cloudimg;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -118,4 +43,5 @@ system-manager.lib.make-vm-test {
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
})
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue