2021-05-28 17:39:22 -05:00
|
|
|
{ config, pkgs, lib, kubenix, ... }:
|
2020-04-05 21:25:34 +07:00
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
let
|
|
|
|
|
cfg = config.testing;
|
|
|
|
|
|
|
|
|
|
testModule = {
|
2021-05-06 16:07:24 -04:00
|
|
|
imports = [ ./evalTest.nix ];
|
2020-04-05 21:25:34 +07:00
|
|
|
|
|
|
|
|
# passthru testing configuration
|
|
|
|
|
config._module.args = {
|
|
|
|
|
inherit pkgs kubenix;
|
|
|
|
|
testing = cfg;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
isTestEnabled = test:
|
|
|
|
|
(cfg.enabledTests == null || elem test.name cfg.enabledTests) && test.enable;
|
|
|
|
|
|
2021-05-13 17:27:08 -04:00
|
|
|
in
|
|
|
|
|
{
|
2020-04-05 21:25:34 +07:00
|
|
|
imports = [
|
|
|
|
|
./docker.nix
|
|
|
|
|
./driver/kubetest.nix
|
|
|
|
|
./runtime/local.nix
|
2021-05-13 20:35:56 -04:00
|
|
|
./runtime/nixos-k8s.nix
|
2020-04-05 21:25:34 +07:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
options.testing = {
|
|
|
|
|
name = mkOption {
|
|
|
|
|
description = "Testing suite name";
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "default";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
throwError = mkOption {
|
|
|
|
|
description = "Whether to throw error";
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-31 22:31:37 -05:00
|
|
|
common = mkOption {
|
|
|
|
|
description = "List of common options to apply to tests";
|
2021-05-13 17:27:08 -04:00
|
|
|
type = types.listOf (types.submodule ({ config, ... }: {
|
2020-04-05 21:25:34 +07:00
|
|
|
options = {
|
|
|
|
|
features = mkOption {
|
2021-05-31 22:31:37 -05:00
|
|
|
description = "List of features that test has to have to apply options";
|
2020-04-05 21:25:34 +07:00
|
|
|
type = types.listOf types.str;
|
2021-05-13 17:27:08 -04:00
|
|
|
default = [ ];
|
2020-04-05 21:25:34 +07:00
|
|
|
};
|
|
|
|
|
|
2021-05-31 22:31:37 -05:00
|
|
|
options = mkOption {
|
|
|
|
|
description = "Options to apply to test";
|
2020-04-05 21:25:34 +07:00
|
|
|
type = types.unspecified;
|
2021-05-13 17:27:08 -04:00
|
|
|
default = { };
|
2021-05-31 22:31:37 -05:00
|
|
|
apply = default: { _file = "testing.common"; } // default;
|
2020-04-05 21:25:34 +07:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}));
|
2021-05-13 17:27:08 -04:00
|
|
|
default = [ ];
|
2020-04-05 21:25:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tests = mkOption {
|
|
|
|
|
description = "List of test cases";
|
2021-05-13 17:27:08 -04:00
|
|
|
default = [ ];
|
|
|
|
|
type = types.listOf (types.coercedTo types.path
|
|
|
|
|
(module: {
|
|
|
|
|
inherit module;
|
|
|
|
|
})
|
|
|
|
|
(types.submodule testModule));
|
2020-04-05 21:25:34 +07:00
|
|
|
apply = tests: filter isTestEnabled tests;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
testsByName = mkOption {
|
|
|
|
|
description = "Tests by name";
|
|
|
|
|
type = types.attrsOf types.attrs;
|
|
|
|
|
default = listToAttrs (map (test: nameValuePair test.name test) cfg.tests);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enabledTests = mkOption {
|
|
|
|
|
description = "List of enabled tests (by default all tests are enabled)";
|
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
|
default = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
args = mkOption {
|
|
|
|
|
description = "Attribute set of extra args passed to tests";
|
|
|
|
|
type = types.attrs;
|
2021-05-13 17:27:08 -04:00
|
|
|
default = { };
|
2020-04-05 21:25:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
success = mkOption {
|
2021-05-06 16:07:24 -04:00
|
|
|
internal = true; # read only property
|
2020-04-05 21:25:34 +07:00
|
|
|
description = "Whether testing was a success";
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = all (test: test.success) cfg.tests;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
testScript = mkOption {
|
2021-05-06 16:07:24 -04:00
|
|
|
internal = true; # set by test driver
|
2020-04-05 21:25:34 +07:00
|
|
|
type = types.package;
|
|
|
|
|
description = "Script to run e2e tests";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|