From 62f857e35f94e98b3205502e410f0d727fa5ecc5 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 30 Nov 2026 17:56:39 +0000 Subject: enstate: --stage, a submission for the next generation Plans against --schema, stores the snapshot under it, and puts no views in place and runs no reactions: the running generation goes on as it is, keeping what it has no slot for, and the switch (--migrate) brings the new views. The way to fill a required slot a generation adds before switching to it, and to bring a host's first state: with the new system's enstate, schema and configuration. Tests, and a subtest of the VM test that does so. --- nix/test.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'nix/test.nix') diff --git a/nix/test.nix b/nix/test.nix index f2739eb..d2f69d9 100644 --- a/nix/test.nix +++ b/nix/test.nix @@ -52,6 +52,11 @@ pkgs.testers.runNixOSTest { systemd.services.consumer = credential 50 config "retiolum.key"; }; + # Adds a required slot: a submission for it is staged before switching. + specialisation.added.configuration = { + enstate.channels.secrets.slots."extra.key" = key; + }; + specialisation.retyped.configuration = { enstate.channels.secrets.slots = lib.mkForce { "tinc.key" = key // { @@ -110,6 +115,26 @@ pkgs.testers.runNixOSTest { machine.fail("/run/booted-system/specialisation/retyped/bin/switch-to-configuration test") machine.succeed("enstate --status | grep -q 'filled tinc.key'") + with subtest("a generation that adds a required slot: staged with its own enstate, then switched to"): + new = "/run/booted-system/specialisation/added" + machine.fail(f"{new}/bin/switch-to-configuration test") + machine.succeed( + "mkdir -p /root/added", + "printf X > /root/added/key", + """echo '{"channel": "secrets", "items": {"extra.key": {"source": {"file": "key"}}}}' """ + "> /root/added/sources.json", + f"{new}/sw/bin/enstate --pack /root/added/sources.json --out /root/added/submission", + f"{new}/sw/bin/enstate --plan /root/added/submission --schema {new}/etc/enstate/schema.json --config {new}/etc/enstate/config.json", + f"{new}/sw/bin/enstate --stage /root/added/submission --schema {new}/etc/enstate/schema.json --config {new}/etc/enstate/config.json", + ) + machine.fail("test -e /run/enstate/views/secrets.extra.key") + seen("tinc.key L") + machine.succeed(f"{new}/bin/switch-to-configuration test") + machine.wait_until_succeeds("grep -qx X /run/enstate/views/secrets.extra.key/extra.key") + seen("tinc.key L") + machine.succeed("/run/booted-system/bin/switch-to-configuration test") + machine.succeed("enstate --status | grep -q 'kept extra.key'") + with subtest("after a reboot, the views are there again"): machine.shutdown() machine.start() -- cgit v1.3.1