2021-02-26 15:03:49 +00:00
|
|
|
import ./make-test-python.nix (
|
|
|
|
{ pkgs, lib, ... }:
|
2024-09-08 12:20:52 +00:00
|
|
|
{
|
2020-08-23 09:00:54 +00:00
|
|
|
name = "containers-reloadable";
|
2024-09-08 12:20:52 +00:00
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ danbst ];
|
|
|
|
};
|
2017-08-23 09:43:07 +00:00
|
|
|
|
|
|
|
nodes = {
|
2024-09-08 12:20:52 +00:00
|
|
|
machine =
|
|
|
|
{ lib, ... }:
|
2024-12-10 19:26:33 +00:00
|
|
|
{
|
2024-09-08 12:20:52 +00:00
|
|
|
containers.test1 = {
|
|
|
|
autoStart = true;
|
|
|
|
config.environment.etc.check.text = "client_base";
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
|
2024-09-08 12:20:52 +00:00
|
|
|
# prevent make-test-python.nix to change IP
|
|
|
|
networking.interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [ ];
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2024-09-08 12:20:52 +00:00
|
|
|
specialisation.c1.configuration = {
|
|
|
|
containers.test1.config = {
|
|
|
|
environment.etc.check.text = lib.mkForce "client_c1";
|
|
|
|
services.httpd.enable = true;
|
|
|
|
services.httpd.adminAddr = "nixos@example.com";
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-08 12:20:52 +00:00
|
|
|
specialisation.c2.configuration = {
|
|
|
|
containers.test1.config = {
|
|
|
|
environment.etc.check.text = lib.mkForce "client_c2";
|
|
|
|
services.nginx.enable = true;
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
};
|
2024-09-08 12:20:52 +00:00
|
|
|
};
|
2017-08-23 09:43:07 +00:00
|
|
|
};
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2024-09-08 12:20:52 +00:00
|
|
|
testScript = ''
|
|
|
|
machine.start()
|
|
|
|
machine.wait_for_unit("default.target")
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2024-09-08 12:20:52 +00:00
|
|
|
assert "client_base" in machine.succeed("nixos-container run test1 cat /etc/check")
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-25 20:58:02 +00:00
|
|
|
with subtest("httpd is available after activating config1"):
|
2024-09-08 12:20:52 +00:00
|
|
|
machine.succeed(
|
|
|
|
"/run/booted-system/specialisation/c1/bin/switch-to-configuration test >&2",
|
2019-11-25 20:58:02 +00:00
|
|
|
"[[ $(nixos-container run test1 cat /etc/check) == client_c1 ]] >&2",
|
|
|
|
"systemctl status httpd -M test1 >&2",
|
|
|
|
)
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-25 20:58:02 +00:00
|
|
|
with subtest("httpd is not available any longer after switching to config2"):
|
2024-09-08 12:20:52 +00:00
|
|
|
machine.succeed(
|
|
|
|
"/run/booted-system/specialisation/c2/bin/switch-to-configuration test >&2",
|
2019-11-25 20:58:02 +00:00
|
|
|
"[[ $(nixos-container run test1 cat /etc/check) == client_c2 ]] >&2",
|
|
|
|
"systemctl status nginx -M test1 >&2",
|
|
|
|
)
|
2024-09-08 12:20:52 +00:00
|
|
|
machine.fail("systemctl status httpd -M test1 >&2")
|
2017-08-23 09:43:07 +00:00
|
|
|
'';
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2017-08-23 09:43:07 +00:00
|
|
|
}
|
|
|
|
)
|