mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
fixups
This commit is contained in:
parent
bbc5e3d477
commit
1bd3fe4d4e
22 changed files with 49 additions and 609 deletions
|
|
@ -6,7 +6,7 @@ let
|
|||
cfg = config.testing;
|
||||
|
||||
testModule = {
|
||||
imports = [ ./test.nix ];
|
||||
imports = [ ./evalTest.nix ];
|
||||
|
||||
# passthru testing configuration
|
||||
config._module.args = {
|
||||
|
|
@ -86,12 +86,14 @@ in {
|
|||
};
|
||||
|
||||
success = mkOption {
|
||||
internal = true; # read only property
|
||||
description = "Whether testing was a success";
|
||||
type = types.bool;
|
||||
default = all (test: test.success) cfg.tests;
|
||||
};
|
||||
|
||||
testScript = mkOption {
|
||||
internal = true; # set by test driver
|
||||
type = types.package;
|
||||
description = "Script to run e2e tests";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ let
|
|||
${cfg.defaultHeader}
|
||||
${t.script}
|
||||
''
|
||||
else p.script;
|
||||
else t.script;
|
||||
|
||||
tests = pkgs.linkFarm "${testing.name}-tests" (map (t: {
|
||||
tests = builtins.trace testing pkgs.linkFarm "${testing.name}-tests" (map (t: {
|
||||
path = toTestScript t;
|
||||
name = "${t.name}_test.py";
|
||||
}) testing.tests);
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.kubetest;
|
||||
|
||||
in {
|
||||
options.test.kubetest = {
|
||||
enable = mkOption {
|
||||
description = "Whether to use kubetest test driver";
|
||||
type = types.bool;
|
||||
default = cfg.testScript != "";
|
||||
};
|
||||
|
||||
testScript = mkOption {
|
||||
type = types.lines;
|
||||
description = "Test script to use for kubetest";
|
||||
default = "";
|
||||
};
|
||||
|
||||
extraPackages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
description = "List of extra packages to use for kubetest";
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.testing.kubetest = {
|
||||
defaultHeader = mkOption {
|
||||
description = "Default test header";
|
||||
type = types.lines;
|
||||
default = ''
|
||||
import pytest
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -55,29 +55,7 @@ let
|
|||
then evaled' else null;
|
||||
|
||||
in {
|
||||
imports = [
|
||||
./driver/kubetest.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
name = mkOption {
|
||||
description = "test name";
|
||||
type = types.str;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
description = mkOption {
|
||||
description = "test description";
|
||||
type = types.str;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
enable = mkOption {
|
||||
description = "Whether to enable test";
|
||||
type = types.bool;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
module = mkOption {
|
||||
description = "Module defining kubenix test";
|
||||
type = types.unspecified;
|
||||
|
|
@ -96,6 +74,25 @@ in {
|
|||
default = false;
|
||||
};
|
||||
|
||||
# transparently forwarded from the test's `test` attribute for ease of access
|
||||
name = mkOption {
|
||||
description = "test name";
|
||||
type = types.str;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
description = mkOption {
|
||||
description = "test description";
|
||||
type = types.str;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
enable = mkOption {
|
||||
description = "Whether to enable test";
|
||||
type = types.bool;
|
||||
internal = true;
|
||||
};
|
||||
|
||||
assertions = mkOption {
|
||||
description = "Test result";
|
||||
type = types.unspecified;
|
||||
|
|
@ -109,26 +106,20 @@ in {
|
|||
internal = true;
|
||||
};
|
||||
|
||||
driver = mkOption {
|
||||
description = "Name of the driver to use for testing";
|
||||
type = types.str;
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
inherit evaled;
|
||||
inherit (testConfig) name description enable driver;
|
||||
inherit (testConfig) name description enable;
|
||||
}
|
||||
|
||||
# if test is evaled check assertions
|
||||
(mkIf (config.evaled != null) {
|
||||
inherit (evaled.config.test) assertions;
|
||||
inherit (evaled.config.test) assertions script;
|
||||
|
||||
# if all assertions are true, test is successfull
|
||||
success = all (el: el.assertion) config.assertions;
|
||||
script = evaled.config.test.script;
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
@ -61,6 +61,17 @@ let
|
|||
};
|
||||
|
||||
systemd.extraConfig = "DefaultLimitNOFILE=1048576";
|
||||
|
||||
systemd.services.copy-certs = {
|
||||
description = "Share k8s certificates with host";
|
||||
script = "cp -rf /var/lib/kubernetes/secrets /tmp/xchg/";
|
||||
after = [ "kubernetes.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# configuration only applied on master nodes
|
||||
|
|
|
|||
|
|
@ -52,21 +52,5 @@ in {
|
|||
type = types.nullOr (types.either types.lines types.path);
|
||||
};
|
||||
|
||||
testScript = mkOption {
|
||||
description = "Script to run as part of testing";
|
||||
type = types.nullOr types.lines;
|
||||
default = null;
|
||||
};
|
||||
|
||||
distro = mkOption {
|
||||
description = "Kubernetes distro to run the test with. Defaults to 'nixos', other option is 'k3s'";
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
driver = mkOption {
|
||||
description = "Name of the driver to use for testing";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue