nixos/tests/k3s: make more idiomatic

For single-node tests, using machine is more idiomatic from what I
gather, so do that.

I do want multi-node tests, but those should be in different files.
This commit is contained in:
Euan Kemp 2021-10-23 18:21:47 -07:00
parent 3210ce7784
commit f20af9dbfb

View File

@ -35,9 +35,7 @@ in
maintainers = [ euank ];
};
nodes = {
k3s =
{ pkgs, ... }: {
machine = { pkgs, ... }: {
environment.systemPackages = with pkgs; [ k3s gzip ];
# k3s uses enough resources the default vm fails.
@ -58,24 +56,23 @@ in
};
};
};
};
testScript = ''
start_all()
k3s.wait_for_unit("k3s")
k3s.succeed("k3s kubectl cluster-info")
k3s.fail("sudo -u noprivs k3s kubectl cluster-info")
# k3s.succeed("k3s check-config") # fails with the current nixos kernel config, uncomment once this passes
machine.wait_for_unit("k3s")
machine.succeed("k3s kubectl cluster-info")
machine.fail("sudo -u noprivs k3s kubectl cluster-info")
# machine.succeed("k3s check-config") # fails with the current nixos kernel config, uncomment once this passes
k3s.succeed(
machine.succeed(
"zcat ${pauseImage} | k3s ctr image import -"
)
k3s.succeed("k3s kubectl apply -f ${testPodYaml}")
k3s.succeed("k3s kubectl wait --for 'condition=Ready' pod/test")
k3s.succeed("k3s kubectl delete -f ${testPodYaml}")
machine.succeed("k3s kubectl apply -f ${testPodYaml}")
machine.succeed("k3s kubectl wait --for 'condition=Ready' pod/test")
machine.succeed("k3s kubectl delete -f ${testPodYaml}")
k3s.shutdown()
machine.shutdown()
'';
})