Skip to content

Commit 1b5c7c0

Browse files
authored
chore: Fix flaky test_actor_handles_migrating_event_correctly (#704)
### Description: Do run run persist state event every 500 ms to prevent flakiness. It is enough to check the persist state event we send manually and the Crawler final one. ### Issues: Closes: #703
1 parent 1b37dbf commit 1b5c7c0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tests/unit/actor/test_actor_lifecycle.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ async def test_actor_handles_migrating_event_correctly(monkeypatch: pytest.Monke
220220
"""Test that Actor handles MIGRATING events correctly by emitting PERSIST_STATE."""
221221
# This should test whether when you get a MIGRATING event,
222222
# the Actor automatically emits the PERSIST_STATE event with data `{'isMigrating': True}`
223-
monkeypatch.setenv(ApifyEnvVars.PERSIST_STATE_INTERVAL_MILLIS, '500')
224223
monkeypatch.setenv(ApifyEnvVars.IS_AT_HOME, '1')
225224
monkeypatch.setenv(ActorEnvVars.RUN_ID, 'asdf')
226225

@@ -285,9 +284,8 @@ async def handler(websocket: websockets.asyncio.server.ServerConnection) -> None
285284

286285
await asyncio.sleep(1)
287286

288-
assert len(persist_state_events_data) >= 3
289-
290-
print(persist_state_events_data)
287+
# It is enough to check the persist state event we send manually and the crawler final one.
288+
assert len(persist_state_events_data) >= 2
291289

292290
# Expect last event to be is_migrating=False (persistence event on exiting EventManager)
293291
assert persist_state_events_data.pop() == EventPersistStateData(is_migrating=False)

0 commit comments

Comments
 (0)