2021-04-25 23:36:48 +00:00
|
|
|
{ lib, deploy }:
|
2021-03-14 07:10:51 +00:00
|
|
|
let
|
2021-04-25 23:36:48 +00:00
|
|
|
mkChecks = { pkgs, hosts, nodes, homes ? { } }:
|
2021-04-10 17:59:10 +00:00
|
|
|
let
|
|
|
|
deployHosts = lib.filterAttrs
|
2021-04-25 23:36:48 +00:00
|
|
|
(n: _: hosts.${n}.config.nixpkgs.system == pkgs.system)
|
2021-04-10 17:59:10 +00:00
|
|
|
nodes;
|
2021-04-25 23:36:48 +00:00
|
|
|
deployChecks = deploy.lib.${pkgs.system}.deployChecks { nodes = deployHosts; };
|
2021-04-10 17:59:10 +00:00
|
|
|
tests =
|
2021-04-24 01:13:03 +00:00
|
|
|
lib.optionalAttrs (deployHosts != { })
|
|
|
|
{
|
2021-04-25 23:36:48 +00:00
|
|
|
profilesTest = profilesTest {
|
|
|
|
inherit pkgs;
|
|
|
|
host = hosts.${(builtins.head (builtins.attrNames deployHosts))};
|
|
|
|
};
|
2021-04-24 01:13:03 +00:00
|
|
|
} // lib.mapAttrs (n: v: v.activationPackage) homes;
|
2021-04-10 17:59:10 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
lib.recursiveUpdate tests deployChecks;
|
2021-03-14 07:10:51 +00:00
|
|
|
|
2021-04-25 23:36:48 +00:00
|
|
|
mkTest = { pkgs, host }:
|
2021-03-14 07:10:51 +00:00
|
|
|
let
|
|
|
|
nixosTesting =
|
2021-04-25 23:36:48 +00:00
|
|
|
(import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
|
|
|
|
inherit (pkgs) system;
|
2021-04-10 17:59:10 +00:00
|
|
|
inherit (host.config.lib) specialArgs;
|
2021-03-14 07:10:51 +00:00
|
|
|
inherit pkgs;
|
|
|
|
extraConfigurations = [
|
2021-04-10 17:59:10 +00:00
|
|
|
host.config.lib.testModule
|
2021-03-14 07:10:51 +00:00
|
|
|
];
|
|
|
|
});
|
|
|
|
in
|
|
|
|
test:
|
|
|
|
let
|
|
|
|
loadedTest =
|
|
|
|
if builtins.typeOf test == "path"
|
|
|
|
then import test
|
|
|
|
else test;
|
|
|
|
calledTest =
|
|
|
|
if pkgs.lib.isFunction loadedTest
|
|
|
|
then pkgs.callPackage loadedTest { }
|
|
|
|
else loadedTest;
|
|
|
|
in
|
|
|
|
nixosTesting.makeTest calledTest;
|
2021-04-10 17:59:10 +00:00
|
|
|
|
2021-04-25 23:36:48 +00:00
|
|
|
profilesTest = args@{ host, ... }: mkTest args {
|
2021-03-15 02:14:51 +00:00
|
|
|
name = "profiles";
|
2021-03-14 07:10:51 +00:00
|
|
|
|
2021-03-15 02:14:51 +00:00
|
|
|
machine = { suites, ... }: {
|
2021-04-25 23:36:48 +00:00
|
|
|
imports = suites.allProfiles;
|
2021-03-14 07:10:51 +00:00
|
|
|
};
|
|
|
|
|
2021-03-15 02:14:51 +00:00
|
|
|
testScript = ''
|
2021-04-25 23:36:48 +00:00
|
|
|
${host.config.networking.hostName}.systemctl("is-system-running --wait")
|
2021-03-14 07:10:51 +00:00
|
|
|
'';
|
|
|
|
};
|
2021-04-10 17:59:10 +00:00
|
|
|
in
|
2021-04-18 00:30:55 +00:00
|
|
|
{ inherit mkTest profilesTest mkChecks; }
|