fix(client): fail closed on polling configuration drift
This commit is contained in:
@@ -121,9 +121,11 @@ class FakeGateway:
|
||||
class FakeConsumer:
|
||||
def __init__(self) -> None:
|
||||
self.claims: list[ClaimedTask] = []
|
||||
self.profiles: list[ProfileSettings] = []
|
||||
|
||||
def accept_claim(self, claimed: ClaimedTask) -> None:
|
||||
def accept_claim(self, claimed: ClaimedTask, profile: ProfileSettings) -> None:
|
||||
self.claims.append(claimed)
|
||||
self.profiles.append(profile)
|
||||
|
||||
|
||||
def wait_until(predicate, timeout_ms: int = 2000) -> None:
|
||||
@@ -339,6 +341,28 @@ class PollingCoordinatorTests(unittest.TestCase):
|
||||
coordinator.stop()
|
||||
wait_until(lambda: not coordinator.operation_in_flight)
|
||||
|
||||
def test_consumer_receives_start_snapshot_even_if_profile_changes_while_claiming(self) -> None:
|
||||
gate = threading.Event()
|
||||
store = FakeStore(snapshot())
|
||||
gateway = FakeGateway([claimed_task()], gate)
|
||||
consumer = FakeConsumer()
|
||||
original = profile(http_timeout=10)
|
||||
coordinator, frozen = self.make_coordinator(
|
||||
store,
|
||||
gateway,
|
||||
consumer,
|
||||
settings=original,
|
||||
)
|
||||
coordinator.start()
|
||||
wait_until(lambda: coordinator.state == PollingState.CLAIMING and gateway.calls == 1)
|
||||
changed = profile(http_timeout=27)
|
||||
coordinator.update_profile_settings(changed)
|
||||
gate.set()
|
||||
wait_until(lambda: coordinator.state == PollingState.ACTIVE)
|
||||
self.assertEqual(frozen, [original])
|
||||
self.assertEqual(consumer.profiles, [original])
|
||||
self.assertIsNot(consumer.profiles[0], changed)
|
||||
|
||||
def test_claim_view_redacts_sentinel_even_if_title_contains_it(self) -> None:
|
||||
wire = claim_wire()
|
||||
wire["task"]["title"] = "标题 " + SENTINEL_TOKEN
|
||||
|
||||
Reference in New Issue
Block a user