Publish curated Unraid-AppOps-Gateway source from 1350d8bf6527e085bbfa950ec0d1ee3e973d618e
This commit is contained in:
1 parent
a0d1a1224a
commit
b47ce43436
7 files changed
+204
-25
No files matched your search
@@ -2461,6 +2461,7 @@ def test_stop_rejects_failed_storage_before_recording_intent_or_stopping(monkeyp
|
||||
|
||||
@pytest.mark.parametrize('native_read_only_graph', [False, True])
|
||||
def test_stop_allows_healthy_storage_and_preserves_intent_before_stop(monkeypatch, native_read_only_graph):
|
||||
monkeypatch.setattr(module, '_cleanup_promotion_host_probe', lambda *a: None)
|
||||
receipt = {'phase': 'prepared'}
|
||||
events = []
|
||||
monkeypatch.setattr(module, '_load_transaction', lambda _: (42, receipt, {}))
|
||||
@@ -3540,6 +3541,7 @@ def test_legacy_receipt_projection_rejects_unsafe_mount_before_docker(compose, d
|
||||
@pytest.mark.parametrize("phase", ["prepared", "stopped", "activated", "verified"])
|
||||
@pytest.mark.parametrize("failure", ["read_only", "full"])
|
||||
def test_forward_stop_rechecks_storage_after_intent_or_on_resume(monkeypatch, phase, failure):
|
||||
monkeypatch.setattr(module, "_cleanup_promotion_host_probe", lambda *a: None)
|
||||
receipt = {"phase": phase, "imageId": IMAGE_ID,
|
||||
"previousRevision": OLD_REVISION, "sourceRevision": REVISION}
|
||||
persisted = phase != "prepared"
|
||||
@@ -3568,6 +3570,69 @@ def test_forward_stop_rechecks_storage_after_intent_or_on_resume(monkeypatch, ph
|
||||
assert events == []
|
||||
|
||||
|
||||
def test_probe_cleanup_failure_precedes_stop_intent_and_controller_stop(monkeypatch):
|
||||
receipt = {"phase": "prepared"}
|
||||
monkeypatch.setattr(module, "_load_transaction", lambda _: (42, receipt, {}))
|
||||
monkeypatch.setattr(module.os, "close", lambda _: None)
|
||||
monkeypatch.setattr(module, "_require_writable_promotion_storage", lambda: None)
|
||||
def reject(*args):
|
||||
raise module.VolumeTransitionError("controller_volume_command_failed")
|
||||
monkeypatch.setattr(module, "_cleanup_promotion_host_probe", reject)
|
||||
monkeypatch.setattr(module, "_set_promotion_phase", lambda *a: pytest.fail("No stop intent"))
|
||||
monkeypatch.setattr(module, "_stop_current_controller", lambda *a, **kw: pytest.fail("No stop"))
|
||||
with pytest.raises(module.VolumeTransitionError, match="controller_volume_command_failed"):
|
||||
module.stop_promotion(Path("/unused-backup"))
|
||||
assert receipt["phase"] == "prepared"
|
||||
|
||||
|
||||
def test_promotion_cleanup_uses_incoming_code_but_only_attested_previous_source(monkeypatch, tmp_path):
|
||||
receipt = {"imageId": IMAGE_ID, "previousRevision": OLD_REVISION,
|
||||
"sourceRevision": REVISION, "sourceTree": "d" * 40}
|
||||
old_source = module._expected_revision_path(OLD_REVISION).as_posix()
|
||||
events = []
|
||||
def inspect(image, **kw):
|
||||
assert image == IMAGE_ID
|
||||
assert kw in ({"require_running": True}, {"expected_source": old_source, "require_running": True})
|
||||
events.append("attest")
|
||||
return {"Id": "c" * 64, "Mounts": [{"Destination": module.EXECUTABLE_TARGET,
|
||||
"Source": old_source}]}
|
||||
monkeypatch.setattr(module, "_controller_image_inspect", inspect)
|
||||
monkeypatch.setattr(module, "_read_tar_tree", lambda _: ({}, {"": 0o755}))
|
||||
monkeypatch.setattr(module, "_release_identity", lambda _: {
|
||||
"sourceRevision": REVISION, "sourceTree": "d" * 40})
|
||||
monkeypatch.setattr(module, "_write_private_tree", lambda *a: None)
|
||||
def run(args, **kw):
|
||||
assert args[0] == "python3"
|
||||
assert Path(args[1]).name == "runner_resource_envelope.py"
|
||||
assert args[2:] == ["--cleanup-stopped-host-probe", IMAGE_ID, old_source]
|
||||
assert kw == {"max_output": 4096}
|
||||
events.append("cleanup")
|
||||
return b""
|
||||
monkeypatch.setattr(module, "_run", run)
|
||||
module._cleanup_promotion_host_probe(receipt, {"controller-after.tar": b"qualified"})
|
||||
assert events == ["attest", "cleanup", "attest"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("present", [False, True])
|
||||
def test_legacy_promotion_allows_only_no_probe_without_adopting_legacy_source(monkeypatch, present):
|
||||
receipt = {"imageId": IMAGE_ID, "previousRevision": OLD_REVISION}
|
||||
monkeypatch.setattr(module, "_controller_image_inspect", lambda *a, **kw: {
|
||||
"Id": "c" * 64, "Mounts": [{"Destination": module.EXECUTABLE_TARGET,
|
||||
"Source": module.CONTROLLER_DIR.as_posix()}]})
|
||||
calls = []
|
||||
def run(args, **kw):
|
||||
calls.append(args)
|
||||
return b"d" * 64 if present else b""
|
||||
monkeypatch.setattr(module, "_run", run)
|
||||
if present:
|
||||
with pytest.raises(module.VolumeTransitionError, match="controller_volume_probe_cleanup_identity_invalid"):
|
||||
module._cleanup_promotion_host_probe(receipt, {})
|
||||
else:
|
||||
module._cleanup_promotion_host_probe(receipt, {})
|
||||
assert calls == [["docker", "ps", "-a", "--no-trunc", "--filter",
|
||||
"name=^itworx-runner-cgroup-probe$", "--format", "{{.ID}}"]]
|
||||
|
||||
|
||||
def test_resumed_forward_stop_of_stopped_controller_needs_no_storage(monkeypatch):
|
||||
receipt = {"phase": "stopped", "imageId": IMAGE_ID,
|
||||
"previousRevision": OLD_REVISION, "sourceRevision": REVISION}
|
||||
|
||||
Reference in new issue
Block a user