fix(k1): refresh stale endpoint before start
This commit is contained in:
@@ -13169,6 +13169,81 @@ def test_start_stale_endpoint_fails_before_receiver_or_device_checkpoint(
|
||||
assert control.start_projects == []
|
||||
|
||||
|
||||
def test_start_refreshes_ttl_expired_endpoint_after_project_prepare(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
service, runtime = service_with_fake_runtime(tmp_path)
|
||||
monotonic_now = [100.0]
|
||||
suspend_aware_now = [1_000.0]
|
||||
supervisor = service._connection_supervisor # noqa: SLF001
|
||||
supervisor._monotonic_clock = lambda: monotonic_now[0] # noqa: SLF001
|
||||
supervisor._suspend_aware_clock = lambda: suspend_aware_now[0] # noqa: SLF001
|
||||
supervisor._observation_ttl_seconds = 15.0 # noqa: SLF001
|
||||
control, binding, ready = _install_binding_validating_ready_control(service)
|
||||
stable_path = _direct_host_path(binding.target_ipv4)
|
||||
monkeypatch.setattr(service, "_sample_host_path", lambda *_args, **_kwargs: stable_path)
|
||||
workspace = service.enter_application_workspace(
|
||||
EnterApplicationWorkspaceRequest(
|
||||
operator_confirmed=True,
|
||||
expected_session_generation=ready["application_control_session"][
|
||||
"session_generation"
|
||||
],
|
||||
expected_state_revision=ready["application_control_session"]["state_revision"],
|
||||
)
|
||||
)
|
||||
prepared = service.prepare_acquisition(
|
||||
_prepare_request(
|
||||
project_name=PROJECT_NAME,
|
||||
host=binding.target_ipv4,
|
||||
compatibility_attestation=ATTESTATION,
|
||||
expected_control_session_generation=workspace["application_control_session"][
|
||||
"session_generation"
|
||||
],
|
||||
expected_control_state_revision=workspace["application_control_session"][
|
||||
"state_revision"
|
||||
],
|
||||
)
|
||||
)
|
||||
monotonic_now[0] += 15.01
|
||||
suspend_aware_now[0] += 15.01
|
||||
assert control.verified_control is not None
|
||||
control.verified_control = {
|
||||
**control.verified_control,
|
||||
"control_proof_revision": 3,
|
||||
}
|
||||
tcp_samples: list[str] = []
|
||||
monkeypatch.setattr(
|
||||
facade_module,
|
||||
"_probe_control_endpoint_socket",
|
||||
lambda target: (
|
||||
tcp_samples.append(target)
|
||||
or facade_module.TcpReachabilityProbeResult(reachable=True)
|
||||
),
|
||||
)
|
||||
|
||||
started = service.start_acquisition(
|
||||
_start_request(
|
||||
acquisition_id=prepared["acquisition"]["acquisition_id"],
|
||||
physical_acceptance=PHYSICAL_ACCEPTANCE,
|
||||
expected_control_session_generation=prepared["application_control_session"][
|
||||
"session_generation"
|
||||
],
|
||||
expected_control_state_revision=prepared["application_control_session"][
|
||||
"state_revision"
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
assert started["acquisition"]["state"] == "starting"
|
||||
assert tcp_samples == [binding.target_ipv4]
|
||||
assert supervisor.snapshot().host_path.epoch == binding.host_path_epoch
|
||||
assert supervisor.snapshot().endpoint.tcp_state == "reachable"
|
||||
assert supervisor.snapshot().authority.acquisition_start_allowed is True
|
||||
assert len(runtime.start_calls) == 1
|
||||
assert control.start_projects == [PROJECT_NAME]
|
||||
|
||||
|
||||
def test_start_stale_control_proof_fails_before_receiver_or_device_checkpoint(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
|
||||
Reference in New Issue
Block a user