at master 1.8 kB view raw
1{ pkgs, lib, ... }: 2{ 3 name = "containers-reloadable"; 4 meta = { 5 maintainers = with lib.maintainers; [ danbst ]; 6 }; 7 8 nodes = { 9 machine = 10 { lib, ... }: 11 { 12 containers.test1 = { 13 autoStart = true; 14 config.environment.etc.check.text = "client_base"; 15 }; 16 17 # prevent make-test-python.nix to change IP 18 networking.interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [ ]; 19 20 specialisation.c1.configuration = { 21 containers.test1.config = { 22 environment.etc.check.text = lib.mkForce "client_c1"; 23 services.httpd.enable = true; 24 services.httpd.adminAddr = "nixos@example.com"; 25 }; 26 }; 27 28 specialisation.c2.configuration = { 29 containers.test1.config = { 30 environment.etc.check.text = lib.mkForce "client_c2"; 31 services.nginx.enable = true; 32 }; 33 }; 34 }; 35 }; 36 37 testScript = '' 38 machine.start() 39 machine.wait_for_unit("default.target") 40 41 assert "client_base" in machine.succeed("nixos-container run test1 cat /etc/check") 42 43 with subtest("httpd is available after activating config1"): 44 machine.succeed( 45 "/run/booted-system/specialisation/c1/bin/switch-to-configuration test >&2", 46 "[[ $(nixos-container run test1 cat /etc/check) == client_c1 ]] >&2", 47 "systemctl status httpd -M test1 >&2", 48 ) 49 50 with subtest("httpd is not available any longer after switching to config2"): 51 machine.succeed( 52 "/run/booted-system/specialisation/c2/bin/switch-to-configuration test >&2", 53 "[[ $(nixos-container run test1 cat /etc/check) == client_c2 ]] >&2", 54 "systemctl status nginx -M test1 >&2", 55 ) 56 machine.fail("systemctl status httpd -M test1 >&2") 57 ''; 58 59}