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