example fix

This commit is contained in:
GTrunSec 2022-04-02 13:28:07 -07:00
parent 2f2a3be87d
commit 164beed30d
No known key found for this signature in database
GPG key ID: 2368FAFA4ABDD2A0
4 changed files with 74 additions and 56 deletions

View file

@ -39,13 +39,18 @@
in in
lib'.evalModules (lib.recursiveUpdate lib'.evalModules (lib.recursiveUpdate
{ {
inherit modules; modules =
specialArgs = {inherit kubenix;}; modules
args = { ++ [
{
_module.args = {
inherit pkgs; inherit pkgs;
name = "default"; name = "default";
}; };
} }
];
specialArgs = {inherit kubenix;};
}
attrs'); attrs');
in { in {
inherit evalModules; inherit evalModules;
@ -74,9 +79,9 @@
in { in {
# TODO: access "success" derivation with nice testing utils for nice output # TODO: access "success" derivation with nice testing utils for nice output
nginx-example = wasSuccess (mkExamples {}).nginx-deployment.config.testing; nginx-example = wasSuccess (mkExamples {}).nginx-deployment.config.testing;
tests-k8s-1_19 = wasSuccess (mkK8STests {k8sVersion = "1.19";}); #tests-k8s-1_19 = wasSuccess (mkK8STests {k8sVersion = "1.19";});
tests-k8s-1_20 = wasSuccess (mkK8STests {k8sVersion = "1.20";}); # tests-k8s-1_20 = wasSuccess (mkK8STests {k8sVersion = "1.20";});
tests-k8s-1_21 = wasSuccess (mkK8STests {k8sVersion = "1.21";}); # tests-k8s-1_21 = wasSuccess (mkK8STests {k8sVersion = "1.21";});
}; };
} }
)) ))

View file

@ -64,7 +64,8 @@ with lib; let
config = definitions."${ref}".config; config = definitions."${ref}".config;
}); });
submoduleWithMergeOf = ref: mergeKey: types.submodule ({name, ...}: let submoduleWithMergeOf = ref: mergeKey:
types.submodule ({name, ...}: let
convertName = name: convertName = name:
if definitions."${ref}".options.${mergeKey}.type == types.int if definitions."${ref}".options.${mergeKey}.type == types.int
then toInt name then toInt name

View file

@ -1,17 +1,23 @@
{ lib, config, pkgs, ... }: {
lib,
with lib; config,
let pkgs,
...
}:
with lib; let
testing = config.testing; testing = config.testing;
cfg = testing.driver.kubetest; cfg = testing.driver.kubetest;
kubetest = import ./kubetestdrv.nix {inherit pkgs;}; kubetest = import ./kubetestdrv.nix {inherit pkgs;};
pythonEnv = pkgs.python38.withPackages (ps: with ps; [ pythonEnv = pkgs.python38.withPackages (ps:
with ps;
[
pytest pytest
kubetest kubetest
kubernetes kubernetes
] ++ cfg.extraPackages); ]
++ cfg.extraPackages);
toTestScript = t: toTestScript = t:
if isString t.script if isString t.script
@ -31,15 +37,18 @@ let
listLengthPadding = builtins.length ( listLengthPadding = builtins.length (
lib.stringToCharacters ( lib.stringToCharacters (
builtins.toString ( builtins.toString (
builtins.length allEligibleTests))); builtins.length allEligibleTests
op = )
(i: t: { )
);
op = i: t: {
path = toTestScript t; path = toTestScript t;
name = let name = let
prefix = lib.fixedWidthNumber listLengthPadding i; prefix = lib.fixedWidthNumber listLengthPadding i;
in "${prefix}_${t.name}_test.py"; in "${prefix}_${t.name}_test.py";
}); };
in pkgs.linkFarm "${testing.name}-tests" ( in
pkgs.linkFarm "${testing.name}-tests" (
lib.imap0 op allEligibleTests lib.imap0 op allEligibleTests
); );
@ -47,9 +56,7 @@ let
#!/usr/bin/env bash #!/usr/bin/env bash
${pythonEnv}/bin/pytest -p no:cacheprovider ${tests} $@ ${pythonEnv}/bin/pytest -p no:cacheprovider ${tests} $@
''; '';
in {
in
{
options.testing.driver.kubetest = { options.testing.driver.kubetest = {
defaultHeader = mkOption { defaultHeader = mkOption {
type = types.lines; type = types.lines;

View file

@ -29,8 +29,13 @@ with lib; let
# eval without checking # eval without checking
evaled' = kubenix.evalModules { evaled' = kubenix.evalModules {
check = false; modules =
inherit modules; modules
++ [
{
_module.args.check = false;
}
];
}; };
# test configuration # test configuration