Skip to content

Commit af874ed

Browse files
committed
linting, reduce heartbeat timeouts for faster test
1 parent da47810 commit af874ed

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tests/helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ async def check_unpaused() -> bool:
276276
info = await assert_pending_activity_exists_eventually(handle, activity_id)
277277
return not info.paused
278278

279-
await assert_eventually(check_unpaused)
279+
await assert_eventually(check_unpaused)

tests/worker/test_workflow.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7438,7 +7438,7 @@ async def heartbeat_activity(
74387438
# If we are on the second attempt, we have retried due to pause/unpause.
74397439
if activity.info().attempt > 1:
74407440
return activity.cancellation_details()
7441-
await asyncio.sleep(1)
7441+
await asyncio.sleep(0.1)
74427442
except (CancelledError, asyncio.CancelledError) as err:
74437443
if not catch_err:
74447444
raise err
@@ -7455,7 +7455,7 @@ def sync_heartbeat_activity(
74557455
# If we are on the second attempt, we have retried due to pause/unpause.
74567456
if activity.info().attempt > 1:
74577457
return activity.cancellation_details()
7458-
time.sleep(1)
7458+
time.sleep(0.1)
74597459
except (CancelledError, asyncio.CancelledError) as err:
74607460
if not catch_err:
74617461
raise err
@@ -7550,7 +7550,7 @@ async def run(
75507550
False,
75517551
activity_id=activity_id,
75527552
start_to_close_timeout=timedelta(seconds=10),
7553-
heartbeat_timeout=timedelta(seconds=2),
7553+
heartbeat_timeout=timedelta(seconds=1),
75547554
retry_policy=RetryPolicy(maximum_attempts=2),
75557555
)
75567556
)
@@ -7560,7 +7560,7 @@ async def run(
75607560
False,
75617561
activity_id=f"{activity_id}-2",
75627562
start_to_close_timeout=timedelta(seconds=10),
7563-
heartbeat_timeout=timedelta(seconds=2),
7563+
heartbeat_timeout=timedelta(seconds=1),
75647564
retry_policy=RetryPolicy(maximum_attempts=2),
75657565
)
75667566
)
@@ -7575,6 +7575,8 @@ async def test_activity_pause_unpause(client: Client):
75757575
workflows=[ActivityHeartbeatPauseUnpauseWorkflow],
75767576
activities=[heartbeat_activity, sync_heartbeat_activity],
75777577
activity_executor=executor,
7578+
max_heartbeat_throttle_interval=timedelta(milliseconds=300),
7579+
default_heartbeat_throttle_interval=timedelta(milliseconds=300),
75787580
) as worker:
75797581
test_activity_id = f"heartbeat-activity-{uuid.uuid4()}"
75807582

@@ -7596,8 +7598,7 @@ async def test_activity_pause_unpause(client: Client):
75967598

75977599
# Wait for next heartbeat to propagate the cancellation. Unpausing before the heartbeat
75987600
# will show activity as unpaused to core. Consequently, it will *not* issue an activity cancel.
7599-
time.sleep(2)
7600-
7601+
time.sleep(0.3)
76017602
# Unpause activity
76027603
await unpause_and_assert(client, handle, activity_info_1.activity_id)
76037604
# Expect second activity to have started now
@@ -7609,7 +7610,7 @@ async def test_activity_pause_unpause(client: Client):
76097610
# Pause activity then assert it is paused
76107611
await pause_and_assert(client, handle, activity_info_2.activity_id)
76117612
# Wait for next heartbeat to propagate the cancellation.
7612-
time.sleep(2)
7613+
time.sleep(0.3)
76137614
# Unpause activity
76147615
await unpause_and_assert(client, handle, activity_info_2.activity_id)
76157616

0 commit comments

Comments
 (0)