@@ -4425,6 +4425,46 @@ async def test_workflow_update_task_fails(client: Client, env: WorkflowEnvironme
44254425 assert bad_validator_fail_ct == 2
44264426
44274427
4428+ @workflow .defn
4429+ class UpdateContinueAsNewWorkflow :
4430+ def __init__ (self ) -> None :
4431+ self .counter = 0
4432+
4433+ @workflow .run
4434+ async def run (self ) -> None :
4435+ while True :
4436+ current_value = self .counter
4437+ await workflow .wait_condition (lambda : self .counter > current_value )
4438+ workflow .continue_as_new ()
4439+
4440+ @workflow .update
4441+ async def update (self ) -> None :
4442+ self .counter += 1
4443+
4444+
4445+ async def test_workflow_update_handle_contains_latest_run_id (
4446+ client : Client , env : WorkflowEnvironment
4447+ ):
4448+ # The update triggers a CAN, so the first update handle returned should have the
4449+ # original run ID but the second should have the post-CAN run ID.
4450+ async with new_worker (client , UpdateContinueAsNewWorkflow ) as worker :
4451+ wf_handle = await client .start_workflow (
4452+ UpdateContinueAsNewWorkflow .run ,
4453+ id = f"update-continue-as-new-workflow-{ uuid .uuid4 ()} " ,
4454+ task_queue = worker .task_queue ,
4455+ )
4456+ upd_handle = await wf_handle .start_update (
4457+ UpdateContinueAsNewWorkflow .update ,
4458+ wait_for_stage = WorkflowUpdateStage .ACCEPTED ,
4459+ )
4460+ assert upd_handle .workflow_run_id == wf_handle .result_run_id
4461+ # upd_handle = await wf_handle.start_update(
4462+ # UpdateContinueAsNewWorkflow.update,
4463+ # wait_for_stage=WorkflowUpdateStage.ACCEPTED,
4464+ # )
4465+ # assert upd_handle.workflow_run_id != wf_handle.result_run_id
4466+
4467+
44284468@workflow .defn
44294469class ImmediatelyCompleteUpdateAndWorkflow :
44304470 def __init__ (self ) -> None :
0 commit comments