fix(k1): stabilize live recovery and media admission
This commit is contained in:
@@ -1817,7 +1817,7 @@ def test_same_path_positive_reducer_observation_resets_technical_failure_streak(
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_unrelated_supervisor_revisions_do_not_reset_technical_failure_streak() -> None:
|
||||
def test_unrelated_supervisor_revisions_preserve_exact_configured_route() -> None:
|
||||
async def scenario() -> None:
|
||||
supervisor, epoch = _configured_unverified_supervisor()
|
||||
path = _available_path()
|
||||
@@ -1836,8 +1836,12 @@ def test_unrelated_supervisor_revisions_do_not_reset_technical_failure_streak()
|
||||
async def host_probe(_target: EndpointTarget) -> HostPathProbeResult:
|
||||
return technical_timeout
|
||||
|
||||
tcp_calls = 0
|
||||
|
||||
async def tcp_probe(_target: EndpointTarget) -> bool:
|
||||
raise AssertionError("technical failure must skip TCP")
|
||||
nonlocal tcp_calls
|
||||
tcp_calls += 1
|
||||
return True
|
||||
|
||||
monitor = ReadOnlyConnectionMonitor(
|
||||
supervisor,
|
||||
@@ -1847,8 +1851,10 @@ def test_unrelated_supervisor_revisions_do_not_reset_technical_failure_streak()
|
||||
)
|
||||
|
||||
first = await monitor.poll_once()
|
||||
assert first.revision == initial.revision
|
||||
assert first.host_path is initial.host_path
|
||||
assert first.host_path.available is True
|
||||
assert first.host_path.epoch == initial.host_path.epoch
|
||||
assert first.endpoint.tcp_state == "reachable"
|
||||
assert first.authority.control_allowed is False
|
||||
assert supervisor.observe_endpoint(
|
||||
target=TARGET,
|
||||
intent_id="bridge-1",
|
||||
@@ -1857,11 +1863,14 @@ def test_unrelated_supervisor_revisions_do_not_reset_technical_failure_streak()
|
||||
)
|
||||
endpoint_refresh = supervisor.snapshot()
|
||||
assert endpoint_refresh.revision > first.revision
|
||||
assert endpoint_refresh.host_path is initial.host_path
|
||||
assert endpoint_refresh.host_path.epoch == initial.host_path.epoch
|
||||
assert endpoint_refresh.host_path.fingerprint == initial.host_path.fingerprint
|
||||
|
||||
second = await monitor.poll_once()
|
||||
assert second.revision == endpoint_refresh.revision
|
||||
assert second.host_path is initial.host_path
|
||||
assert second.host_path.available is True
|
||||
assert second.host_path.epoch == initial.host_path.epoch
|
||||
assert second.endpoint.tcp_state == "reachable"
|
||||
assert second.authority.control_allowed is False
|
||||
assert supervisor.observe_endpoint(
|
||||
target=TARGET,
|
||||
intent_id="bridge-1",
|
||||
@@ -1870,15 +1879,17 @@ def test_unrelated_supervisor_revisions_do_not_reset_technical_failure_streak()
|
||||
)
|
||||
|
||||
confirmed = await monitor.poll_once()
|
||||
assert confirmed.host_path.available is False
|
||||
assert confirmed.host_path.reason_code == "host-wifi-operation-timeout"
|
||||
assert confirmed.host_path.available is True
|
||||
assert confirmed.host_path.epoch == initial.host_path.epoch
|
||||
assert confirmed.endpoint.tcp_state == "reachable"
|
||||
assert confirmed.authority.control_allowed is False
|
||||
assert tcp_calls == 3
|
||||
await monitor.close()
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_inflight_third_timeout_cannot_overwrite_a_concurrent_positive_observation() -> None:
|
||||
def test_inflight_timeout_cannot_overwrite_a_concurrent_positive_observation() -> None:
|
||||
async def scenario() -> None:
|
||||
supervisor, initial_epoch = _configured_unverified_supervisor()
|
||||
path = _available_path()
|
||||
@@ -1892,20 +1903,20 @@ def test_inflight_third_timeout_cannot_overwrite_a_concurrent_positive_observati
|
||||
observation_failure_class="association-observer",
|
||||
kernel_route_fingerprint=path.kernel_route_fingerprint,
|
||||
)
|
||||
third_probe_entered = asyncio.Event()
|
||||
release_third_probe = asyncio.Event()
|
||||
timeout_probe_entered = asyncio.Event()
|
||||
release_timeout_probe = asyncio.Event()
|
||||
host_calls = 0
|
||||
|
||||
async def host_probe(_target: EndpointTarget) -> HostPathProbeResult:
|
||||
nonlocal host_calls
|
||||
host_calls += 1
|
||||
if host_calls == 3:
|
||||
third_probe_entered.set()
|
||||
await release_third_probe.wait()
|
||||
if host_calls == 1:
|
||||
timeout_probe_entered.set()
|
||||
await release_timeout_probe.wait()
|
||||
return technical_timeout
|
||||
|
||||
async def tcp_probe(_target: EndpointTarget) -> bool:
|
||||
raise AssertionError("technical failure must skip TCP")
|
||||
return True
|
||||
|
||||
monitor = ReadOnlyConnectionMonitor(
|
||||
supervisor,
|
||||
@@ -1913,32 +1924,20 @@ def test_inflight_third_timeout_cannot_overwrite_a_concurrent_positive_observati
|
||||
tcp_probe=tcp_probe,
|
||||
target_provider=lambda: TARGET,
|
||||
)
|
||||
first = await monitor.poll_once()
|
||||
second = await monitor.poll_once()
|
||||
assert first.authority.control_allowed is False
|
||||
assert second.authority.control_allowed is False
|
||||
|
||||
inflight_third = asyncio.create_task(monitor.poll_once())
|
||||
await third_probe_entered.wait()
|
||||
inflight_timeout = asyncio.create_task(monitor.poll_once())
|
||||
await timeout_probe_entered.wait()
|
||||
refreshed_epoch = supervisor.observe_host_path(path)
|
||||
assert refreshed_epoch == initial_epoch
|
||||
external_positive = supervisor.snapshot()
|
||||
release_third_probe.set()
|
||||
raced_timeout = await inflight_third
|
||||
release_timeout_probe.set()
|
||||
raced_timeout = await inflight_timeout
|
||||
|
||||
assert raced_timeout.revision == external_positive.revision
|
||||
assert raced_timeout.host_path is external_positive.host_path
|
||||
assert raced_timeout.revision >= external_positive.revision
|
||||
assert raced_timeout.host_path.available is True
|
||||
assert raced_timeout.host_path.epoch == external_positive.host_path.epoch
|
||||
assert raced_timeout.host_path.fingerprint == external_positive.host_path.fingerprint
|
||||
assert raced_timeout.endpoint.tcp_state == "reachable"
|
||||
assert raced_timeout.authority.control_allowed is False
|
||||
|
||||
second_after_positive = await monitor.poll_once()
|
||||
assert second_after_positive.revision == external_positive.revision
|
||||
assert second_after_positive.host_path is external_positive.host_path
|
||||
assert second_after_positive.authority.control_allowed is False
|
||||
|
||||
confirmed = await monitor.poll_once()
|
||||
assert confirmed.host_path.available is False
|
||||
assert confirmed.host_path.reason_code == "host-wifi-operation-timeout"
|
||||
assert confirmed.authority.control_allowed is False
|
||||
await monitor.close()
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
Reference in New Issue
Block a user