Skip to content

Commit aa26503

Browse files
authored
Fix flaky test (#534)
1 parent 11a97d1 commit aa26503

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/worker/test_workflow.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
from temporalio.api.common.v1 import Payload, Payloads, WorkflowExecution
3939
from temporalio.api.enums.v1 import EventType
4040
from temporalio.api.failure.v1 import Failure
41+
from temporalio.api.update.v1 import UpdateRef
4142
from temporalio.api.workflowservice.v1 import (
4243
GetWorkflowExecutionHistoryRequest,
44+
PollWorkflowExecutionUpdateRequest,
4345
ResetStickyTaskQueueRequest,
4446
)
4547
from temporalio.bridge.proto.workflow_activation import WorkflowActivation
@@ -4216,11 +4218,36 @@ async def test_workflow_update_before_worker_start(
42164218
task_queue=task_queue,
42174219
)
42184220

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+
42194241
# Execute update in background
42204242
update_task = asyncio.create_task(
4221-
handle.execute_update(ImmediatelyCompleteUpdateAndWorkflow.update)
4243+
handle.execute_update(
4244+
ImmediatelyCompleteUpdateAndWorkflow.update, id="my-update"
4245+
)
42224246
)
42234247

4248+
# Wait until update exists
4249+
await assert_eq_eventually(True, update_exists)
4250+
42244251
# Start no-cache worker on the task queue
42254252
async with new_worker(
42264253
client,

0 commit comments

Comments
 (0)