Skip to content

Commit 00f906b

Browse files
author
Andrei Neagu
committed
attempt to avoid flaky test
1 parent e2fc69b commit 00f906b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

services/web/server/tests/integration/01/test_garbage_collection.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from simcore_service_webserver.socketio.plugin import setup_socketio
5757
from simcore_service_webserver.users.plugin import setup_users
5858
from sqlalchemy import func, select
59+
from tenacity import AsyncRetrying, stop_after_delay, wait_fixed
5960

6061
log = logging.getLogger(__name__)
6162

@@ -344,9 +345,16 @@ async def disconnect_user_from_socketio(
344345
await sio.disconnect()
345346
assert not sio.sid
346347
await asyncio.sleep(0) # just to ensure there is a context switch
347-
assert not await socket_registry.find_keys(("socket_id", sio.get_sid()))
348-
assert sid not in await socket_registry.find_resources(resource_key, "socket_id")
349-
assert not await socket_registry.find_resources(resource_key, "socket_id")
348+
349+
async for attempt in AsyncRetrying(
350+
wait=wait_fixed(0.1), stop=stop_after_delay(5), reraise=True
351+
):
352+
with attempt:
353+
assert not await socket_registry.find_keys(("socket_id", sio.get_sid()))
354+
assert sid not in await socket_registry.find_resources(
355+
resource_key, "socket_id"
356+
)
357+
assert not await socket_registry.find_resources(resource_key, "socket_id")
350358

351359

352360
async def assert_users_count(
@@ -477,7 +485,6 @@ async def test_t1_while_guest_is_connected_no_resources_are_removed(
477485
await assert_project_in_db(aiopg_engine, empty_guest_user_project)
478486

479487

480-
@pytest.mark.flaky(max_runs=3)
481488
async def test_t2_cleanup_resources_after_browser_is_closed(
482489
disable_garbage_collector_task: None,
483490
client: TestClient,

0 commit comments

Comments
 (0)