vm-tests: migrate status reports the state gate's answers
This commit is contained in:
parent
5779bc5719
commit
049d8fbfe3
1 changed files with 20 additions and 0 deletions
|
|
@ -1127,6 +1127,14 @@ pkgs.testers.runNixOSTest {
|
|||
|
||||
GATE_REFUSAL = f"{STT}: state volume has not been migrated: run `swarmctl migrate {STT}`, or set services.hyperhive.deploy.stt.k8s.freshState for a fresh install"
|
||||
|
||||
def migrate_step(step: str, service: str = STT) -> dict[str, str]:
|
||||
"""The `step` of `service` in `swarmctl migrate status --json`, which
|
||||
reads the gate's answer from the pod's status and creates no pod."""
|
||||
report = json.loads(machine.succeed("swarmctl migrate status --json"))
|
||||
found = [s for s in report["steps"] if s["service"] == service and s["step"] == step]
|
||||
assert len(found) == 1, (step, report["steps"])
|
||||
return found[0]
|
||||
|
||||
def helper(name: str, script: str, claim: str | None = None, setup: str | None = None, image: str = HELPER, fresh: str | None = None) -> tuple[str, str]:
|
||||
"""Runs `script` in a pod of the helper image with the volume of
|
||||
`claim` (an empty one if None) at /state as the pod user, and returns
|
||||
|
|
@ -1206,6 +1214,12 @@ pkgs.testers.runNixOSTest {
|
|||
assert [c["state"].get("waiting", {}).get("reason") for c in refused["status"]["containerStatuses"]] == ["PodInitializing"], refused["status"]
|
||||
assert not is_ready(refused)
|
||||
assert GATE_REFUSAL in machine.succeed(f"kubectl -n {NS} logs {refused_pod} -c state-gate")
|
||||
# `swarmctl migrate status` reports the same refusal, and not as a marker.
|
||||
pods_before = machine.succeed(f"kubectl -n {NS} get pods -o name").split()
|
||||
copy = migrate_step("copy")
|
||||
assert copy["status"] == "not_done" and GATE_REFUSAL in copy["detail"], copy
|
||||
assert migrate_step("ready")["status"] == "not_done"
|
||||
assert machine.succeed(f"kubectl -n {NS} get pods -o name").split() == pods_before, "status created or deleted a pod"
|
||||
assert host_state(STT_HOST_UNIT) == "inactive", host_state(STT_HOST_UNIT)
|
||||
assert machine.execute("machinectl list --no-legend | grep -q swarm-stt")[0] != 0
|
||||
# The control: the claim the pod mounts is bound, and its volume is empty.
|
||||
|
|
@ -1220,6 +1234,10 @@ pkgs.testers.runNixOSTest {
|
|||
started = wait_pod_ready(STT, timeout=420)
|
||||
assert started == refused_pod, (started, refused_pod)
|
||||
assert "state volume is migrated" in machine.succeed(f"kubectl -n {NS} logs {started} -c state-gate")
|
||||
copy = migrate_step("copy")
|
||||
assert copy["status"] == "done" and started in copy["detail"], copy
|
||||
assert migrate_step("ready")["status"] == "done", migrate_step("ready")
|
||||
assert migrate_step("runtime")["status"] == "done", migrate_step("runtime")
|
||||
assert host_state(STT_HOST_UNIT) == "inactive", host_state(STT_HOST_UNIT)
|
||||
|
||||
with subtest("a volume that holds files and no marker is refused, and the refusal says the copy may be cut off"):
|
||||
|
|
@ -1230,5 +1248,7 @@ pkgs.testers.runNixOSTest {
|
|||
half_pod = service_pods(STT)[0].removeprefix("pod/")
|
||||
machine.wait_until_succeeds(f"kubectl -n {NS} get pod {half_pod} -o jsonpath='{reason}' | grep -qF 'holds files and no .hyperhive-migrated marker'", timeout=300)
|
||||
assert not is_ready(pod(machine, half_pod))
|
||||
copy = migrate_step("copy")
|
||||
assert copy["status"] == "not_done" and "cut off" in copy["detail"], copy
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue