Watch
0
0
Fork
You've already forked hyperhive
0

swarm-archive vm test: the forget control picks a snapshot to delete and reads the refusal

This commit is contained in:
atlas 2026-11-11 02:32:53 +01:00 • committed by mara
commit 2ef62a3cc8

View file

@ -306,9 +306,13 @@ pkgs.testers.runNixOSTest {
snap = m.succeed(restic("alpha", "alpha", "snapshots --json")).split('"id":"')[1].split('"')[0] snap = m.succeed(restic("alpha", "alpha", "snapshots --json")).split('"id":"')[1].split('"')[0]
# An old snapshot for the prune to drop. The backup is also the presence control: a lock, which a backup creates and removes, is deletable. # An old snapshot for the prune to drop. The backup is also the presence control: a lock, which a backup creates and removes, is deletable.
m.succeed(restic("alpha", "alpha", "backup --host alpha --time '2000-01-01 00:00:00' ${agentRoot}/alpha/state")) m.succeed(restic("alpha", "alpha", "backup --host alpha --time '2000-01-01 00:00:00' ${agentRoot}/alpha/state"))
both = m.succeed(restic("alpha", "alpha", "snapshots --json"))
assert both.count('"id"') == 2 and snap in both, both
assert status(m, "alpha", "alpha", f"snapshots/{snap}", "DELETE") == "403" assert status(m, "alpha", "alpha", f"snapshots/{snap}", "DELETE") == "403"
assert status(m, "alpha", "alpha", "config", "POST") == "403" assert status(m, "alpha", "alpha", "config", "POST") == "403"
m.fail(restic("alpha", "alpha", "forget --keep-last 1 --prune")) # Grouped by host, as the server's prune does: the two snapshots have different paths, and the default grouping keeps the newest of each, so nothing would be forgotten. restic exits 0 when only the removal of a snapshot is refused, so the refusal is read from its output.
_, out = m.execute(restic("alpha", "alpha", "forget --group-by host --keep-last 1 --prune") + " 2>&1")
assert "unable to remove snapshot" in out and "403" in out, out
assert m.succeed(restic("alpha", "alpha", "snapshots --json")).count('"id"') == 2 assert m.succeed(restic("alpha", "alpha", "snapshots --json")).count('"id"') == 2
with subtest(f"{tag}: the server-side prune applies the retention"): with subtest(f"{tag}: the server-side prune applies the retention"):