Skip to content

Commit

Permalink
Fix flakiness in tests/core/test_sync_monitor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Feb 22, 2023
1 parent ea7e9aa commit 7b9c126
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/core/test_sync_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ async def test_sync_confined_children_after_rename(

# Create a workspace
wid = await alice_core.user_fs.workspace_create(EntryName("w"))

# Wait for the sync monitor to sync the new workspace
async with frozen_clock.real_clock_timeout():
await alice_core.wait_idle_monitors()

alice_w = alice_core.user_fs.get_workspace(wid)

# Set a filter
Expand Down Expand Up @@ -661,7 +666,12 @@ async def test_sync_timeout_and_rejected_by_sequester_service(
monkeypatch.setattr("parsec.utils.BALLPARK_ALWAYS_OK", True)

async def _wait_sync_is_done():
assert not alice_core.are_monitors_idle()
# In theory here we should have `alice_core.are_monitors_idle() is True`,
# however given monitors runs in concurrency (and time is mocked to runs very
# fast !), they could have already finished they work.
# Hence we rely on the fact we are guaranteed the monitors have switched their state
# to waked up synchronously with the change event, and so idle monitor here means
# "the change have been processed" and not "the change have not been seen yet".
async with frozen_clock.real_clock_timeout():
await alice_core.wait_idle_monitors()

Expand Down Expand Up @@ -707,7 +717,7 @@ async def _mocked_http_request(**kwargs):
# The trick is the parent folder will force a minimal sync of the file, so we must
# make sure minimal sync and sync of the file lead to the same result.
# Otherwise (e.g. if we use `write_bytes` with non-empty content instead of `touch`)
# we will endup with 1 or 2 versions of the manifest synced depending of if a minimal
# we will end up with 1 or 2 versions of the manifest synced depending of if a minimal
# sync was achieved before the actual sync.
await alice_workspace.touch("/test.txt")
await _wait_sync_is_done()
Expand Down

0 comments on commit 7b9c126

Please sign in to comment.