fix(k1): stabilize repeated acquisition and live viewer recovery
This commit is contained in:
@@ -778,3 +778,36 @@ def test_post_publish_timeout_poisoned_transport_never_retries() -> None:
|
||||
required_response_operation_keys={"bootstrap:1:DeviceInfoRequest"},
|
||||
)
|
||||
assert len(fake.publish_calls) == 1
|
||||
|
||||
|
||||
def test_network_loop_failure_keeps_exact_paho_result_and_phase() -> None:
|
||||
class LoopFailureClient(FakeControlClient):
|
||||
def loop(self, timeout: float) -> mqtt.MQTTErrorCode:
|
||||
if self.publish_calls and not self.events:
|
||||
return mqtt.MQTT_ERR_CONN_LOST
|
||||
return super().loop(timeout)
|
||||
|
||||
fake = LoopFailureClient()
|
||||
transport = ReviewedApplicationMqttTransport(
|
||||
"192.168.1.20",
|
||||
client_factory=lambda: cast(mqtt.Client, fake),
|
||||
)
|
||||
transport.open()
|
||||
|
||||
with pytest.raises(
|
||||
ApplicationCommandOutcomeUnknown,
|
||||
match=r"phase=post-publish-drain, result=7: The connection was lost",
|
||||
):
|
||||
transport.exchange_batch_once(
|
||||
[_envelope()],
|
||||
required_response_operation_keys={"bootstrap:1:DeviceInfoRequest"},
|
||||
)
|
||||
|
||||
snapshot = transport.snapshot().as_dict()
|
||||
assert snapshot["state"] == "poisoned"
|
||||
assert snapshot["last_loop_result_code"] == int(mqtt.MQTT_ERR_CONN_LOST)
|
||||
assert snapshot["last_loop_result_name"] == mqtt.error_string(
|
||||
int(mqtt.MQTT_ERR_CONN_LOST)
|
||||
)
|
||||
assert snapshot["last_loop_phase"] == "post-publish-drain"
|
||||
assert len(fake.publish_calls) == 1
|
||||
|
||||
Reference in New Issue
Block a user