nixos/containers-reloadable: Port test to python

This commit is contained in:
Jacek Galowicz 2019-11-25 21:58:02 +01:00
parent e4abed35be
commit da39d2be5a

View file

@ -1,7 +1,7 @@
import ./make-test.nix ({ pkgs, lib, ...} :
import ./make-test-python.nix ({ pkgs, lib, ...} :
let
client_base = {
containers.test1 = {
autoStart = true;
config = {
@ -48,18 +48,25 @@ in {
c1System = nodes.client_c1.config.system.build.toplevel;
c2System = nodes.client_c2.config.system.build.toplevel;
in ''
$client->start();
$client->waitForUnit("default.target");
$client->succeed("[[ \$(nixos-container run test1 cat /etc/check) == client_base ]] >&2");
client.start()
client.wait_for_unit("default.target")
$client->succeed("${c1System}/bin/switch-to-configuration test >&2");
$client->succeed("[[ \$(nixos-container run test1 cat /etc/check) == client_c1 ]] >&2");
$client->succeed("systemctl status httpd -M test1 >&2");
assert "client_base" in client.succeed("nixos-container run test1 cat /etc/check")
$client->succeed("${c2System}/bin/switch-to-configuration test >&2");
$client->succeed("[[ \$(nixos-container run test1 cat /etc/check) == client_c2 ]] >&2");
$client->fail("systemctl status httpd -M test1 >&2");
$client->succeed("systemctl status nginx -M test1 >&2");
with subtest("httpd is available after activating config1"):
client.succeed(
"${c1System}/bin/switch-to-configuration test >&2",
"[[ $(nixos-container run test1 cat /etc/check) == client_c1 ]] >&2",
"systemctl status httpd -M test1 >&2",
)
with subtest("httpd is not available any longer after switching to config2"):
client.succeed(
"${c2System}/bin/switch-to-configuration test >&2",
"[[ $(nixos-container run test1 cat /etc/check) == client_c2 ]] >&2",
"systemctl status nginx -M test1 >&2",
)
client.fail("systemctl status httpd -M test1 >&2")
'';
})