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