@@ -331,10 +331,14 @@ async def test_workflow_history_info(
331331 # because just a query will have a stale representation of history
332332 # counts, but signal forces a new WFT.
333333 await handle .signal (HistoryInfoWorkflow .bunch_of_events , 1 )
334- new_info = await handle .query (HistoryInfoWorkflow .get_history_info )
335- assert new_info .history_length > continue_as_new_suggest_history_count
336- assert new_info .history_size > orig_info .history_size
337- assert new_info .continue_as_new_suggested
334+
335+ async def history_info_updated () -> None :
336+ new_info = await handle .query (HistoryInfoWorkflow .get_history_info )
337+ assert new_info .history_length > continue_as_new_suggest_history_count
338+ assert new_info .history_size > orig_info .history_size
339+ assert new_info .continue_as_new_suggested
340+
341+ await assert_eventually (history_info_updated )
338342
339343
340344@workflow .defn
@@ -5317,7 +5321,11 @@ async def any_task_completed(handle: WorkflowHandle) -> bool:
53175321 # because we should have timer-done poll completions every 100ms
53185322 worker .client = other_env .client
53195323 # Now confirm the other workflow has started
5320- await assert_eq_eventually (True , lambda : any_task_completed (handle2 ))
5324+ await assert_eq_eventually (
5325+ True ,
5326+ lambda : any_task_completed (handle2 ),
5327+ timeout = timedelta (seconds = 30 ),
5328+ )
53215329 # Terminate both
53225330 await handle1 .terminate ()
53235331 await handle2 .terminate ()
@@ -8047,8 +8055,10 @@ async def test_quick_activity_swallows_cancellation(client: Client):
80478055 activities = [short_activity_async ],
80488056 activity_executor = concurrent .futures .ThreadPoolExecutor (max_workers = 1 ),
80498057 ) as worker :
8050- for i in range (10 ):
8051- wf_duration = random .uniform (5.0 , 15.0 )
8058+ # Keep this deterministic and bounded. The original randomized 10-iteration
8059+ # version could exceed the per-test timeout on slower CI hosts if
8060+ # cancellation was delayed a few times in a row.
8061+ for i , wf_duration in enumerate ((5.0 , 7.5 , 10.0 )):
80528062 wf_handle = await client .start_workflow (
80538063 QuickActivityWorkflow .run ,
80548064 id = f"short_activity_wf_id-{ i } " ,
@@ -8537,39 +8547,29 @@ def emit(self, record: logging.LogRecord) -> None:
85378547async def test_disable_logger_sandbox (
85388548 client : Client ,
85398549):
8540- logger = workflow .logger .logger
8541- handler = CustomLogHandler ()
8542- with LogHandler .apply (logger , handler ):
8550+ async def execute_with_new_worker (* , disable_sandbox : bool ) -> None :
8551+ workflow .logger .unsafe_disable_sandbox (disable_sandbox )
85438552 async with new_worker (
85448553 client ,
85458554 DisableLoggerSandbox ,
85468555 activities = [],
85478556 ) as worker :
8548- with pytest .raises (WorkflowFailureError ):
8549- await client .execute_workflow (
8550- DisableLoggerSandbox .run ,
8551- id = f"workflow-{ uuid .uuid4 ()} " ,
8552- task_queue = worker .task_queue ,
8553- run_timeout = timedelta (seconds = 1 ),
8554- retry_policy = RetryPolicy (maximum_attempts = 1 ),
8555- )
8556- workflow .logger .unsafe_disable_sandbox ()
85578557 await client .execute_workflow (
85588558 DisableLoggerSandbox .run ,
85598559 id = f"workflow-{ uuid .uuid4 ()} " ,
85608560 task_queue = worker .task_queue ,
85618561 run_timeout = timedelta (seconds = 1 ),
85628562 retry_policy = RetryPolicy (maximum_attempts = 1 ),
85638563 )
8564- workflow . logger . unsafe_disable_sandbox ( False )
8565- with pytest . raises ( WorkflowFailureError ):
8566- await client . execute_workflow (
8567- DisableLoggerSandbox . run ,
8568- id = f"workflow- { uuid . uuid4 () } " ,
8569- task_queue = worker . task_queue ,
8570- run_timeout = timedelta ( seconds = 1 ),
8571- retry_policy = RetryPolicy ( maximum_attempts = 1 ),
8572- )
8564+
8565+ logger = workflow . logger . logger
8566+ handler = CustomLogHandler ()
8567+ with LogHandler . apply ( logger , handler ):
8568+ with pytest . raises ( WorkflowFailureError ):
8569+ await execute_with_new_worker ( disable_sandbox = False )
8570+ await execute_with_new_worker ( disable_sandbox = True )
8571+ with pytest . raises ( WorkflowFailureError ):
8572+ await execute_with_new_worker ( disable_sandbox = False )
85738573
85748574
85758575@workflow .defn
0 commit comments