Skip to content

Commit 8777db6

Browse files
committed
fix integration test
Signed-off-by: Tim Li <ltim@uber.com>
1 parent 4cbff53 commit 8777db6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

tests/cadence/_internal/activity/test_activity_executor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,9 @@ def activity_fn():
358358
executor = ActivityExecutor(client, "task_list", "identity", 1, reg.get_activity)
359359

360360
await executor.execute(fake_task("activity_type", ""))
361-
# Allow the event loop to process the heartbeat scheduled from the thread
362-
await asyncio.sleep(0)
361+
# run_coroutine_threadsafe schedules the heartbeat from a thread;
362+
# the coroutine needs multiple event-loop iterations to complete.
363+
await asyncio.sleep(0.1)
363364

364365
worker_stub.RespondActivityTaskCompleted.assert_called_once()
365366
worker_stub.RecordActivityTaskHeartbeat.assert_called_once_with(

tests/integration_tests/workflow/test_heartbeat.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,23 @@ async def test_activity_without_heartbeat_times_out(helper: CadenceHelper):
8484
execution_start_to_close_timeout=timedelta(seconds=30),
8585
)
8686

87+
# Wait for the workflow to close (activity timeout will cause workflow failure)
88+
await worker.client.workflow_stub.GetWorkflowExecutionHistory(
89+
GetWorkflowExecutionHistoryRequest(
90+
domain=DOMAIN_NAME,
91+
workflow_execution=execution,
92+
wait_for_new_event=True,
93+
history_event_filter_type=EventFilterType.EVENT_FILTER_TYPE_CLOSE_EVENT,
94+
skip_archival=True,
95+
)
96+
)
97+
98+
# Fetch the full history to verify the activity timed out due to missing heartbeat
8799
response: GetWorkflowExecutionHistoryResponse = (
88100
await worker.client.workflow_stub.GetWorkflowExecutionHistory(
89101
GetWorkflowExecutionHistoryRequest(
90102
domain=DOMAIN_NAME,
91103
workflow_execution=execution,
92-
wait_for_new_event=True,
93104
skip_archival=True,
94105
)
95106
)

0 commit comments

Comments
 (0)