|
38 | 38 | from temporalio.api.common.v1 import Payload, Payloads, WorkflowExecution
|
39 | 39 | from temporalio.api.enums.v1 import EventType
|
40 | 40 | from temporalio.api.failure.v1 import Failure
|
| 41 | +from temporalio.api.update.v1 import UpdateRef |
41 | 42 | from temporalio.api.workflowservice.v1 import (
|
42 | 43 | GetWorkflowExecutionHistoryRequest,
|
| 44 | + PollWorkflowExecutionUpdateRequest, |
43 | 45 | ResetStickyTaskQueueRequest,
|
44 | 46 | )
|
45 | 47 | from temporalio.bridge.proto.workflow_activation import WorkflowActivation
|
@@ -4216,11 +4218,36 @@ async def test_workflow_update_before_worker_start(
|
4216 | 4218 | task_queue=task_queue,
|
4217 | 4219 | )
|
4218 | 4220 |
|
| 4221 | + async def update_exists() -> bool: |
| 4222 | + try: |
| 4223 | + await client.workflow_service.poll_workflow_execution_update( |
| 4224 | + PollWorkflowExecutionUpdateRequest( |
| 4225 | + namespace=client.namespace, |
| 4226 | + update_ref=UpdateRef( |
| 4227 | + workflow_execution=WorkflowExecution(workflow_id=handle.id), |
| 4228 | + update_id="my-update", |
| 4229 | + ), |
| 4230 | + ) |
| 4231 | + ) |
| 4232 | + return True |
| 4233 | + except RPCError as err: |
| 4234 | + if err.status != RPCStatusCode.NOT_FOUND: |
| 4235 | + raise |
| 4236 | + return False |
| 4237 | + |
| 4238 | + # Confirm update not there |
| 4239 | + assert not await update_exists() |
| 4240 | + |
4219 | 4241 | # Execute update in background
|
4220 | 4242 | update_task = asyncio.create_task(
|
4221 |
| - handle.execute_update(ImmediatelyCompleteUpdateAndWorkflow.update) |
| 4243 | + handle.execute_update( |
| 4244 | + ImmediatelyCompleteUpdateAndWorkflow.update, id="my-update" |
| 4245 | + ) |
4222 | 4246 | )
|
4223 | 4247 |
|
| 4248 | + # Wait until update exists |
| 4249 | + await assert_eq_eventually(True, update_exists) |
| 4250 | + |
4224 | 4251 | # Start no-cache worker on the task queue
|
4225 | 4252 | async with new_worker(
|
4226 | 4253 | client,
|
|
0 commit comments