Skip to content

Commit

Permalink
[tests/scenarios] adding a try catch in admin_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
khoaguin committed Sep 27, 2024
1 parent bb13be4 commit 3a2a0ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tests/scenariosv2/l0_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,25 @@ async def admin_sync(
to_ = to_client.metadata.server_side_type

while not ctx.events.is_set(exit_after):
await asyncio.sleep(random.uniform(5, 10))
try:
await asyncio.sleep(random.uniform(3, 5))

ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Checking")
result = sy.sync(from_client, to_client)
if isinstance(result, sy.SyftSuccess):
continue

ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Checking")
result = sy.sync(from_client, to_client)
if isinstance(result, sy.SyftSuccess):
continue
ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Result={result}")
result._share_all()
result._sync_all()

ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Result={result}")
result._share_all()
result._sync_all()
ctx.events.trigger(trigger)
ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Synced")

ctx.events.trigger(trigger)
ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Synced")
except Exception as e:
ctx.logger.error(f"Admin {from_}: Sync {from_}->{to_} - Error: {str(e)}")
ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Waiting a bit..")
await asyncio.sleep(random.uniform(2, 4))

ctx.logger.info(f"Admin {from_}: Sync {from_}->{to_} - Closed")

Expand Down
1 change: 1 addition & 0 deletions tests/scenariosv2/sim/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ async def wrapper(ctx: SimulatorContext, *args, **kwargs):

if _trigger:
ctx.events.trigger(_trigger)
ctx.logger.info(f"Triggering event: {_trigger.name}")

return result
except Exception as e:
Expand Down

0 comments on commit 3a2a0ca

Please sign in to comment.