Skip to content

Commit

Permalink
Fix flaky test (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz authored May 28, 2024
1 parent 11a97d1 commit aa26503
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/worker/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
from temporalio.api.common.v1 import Payload, Payloads, WorkflowExecution
from temporalio.api.enums.v1 import EventType
from temporalio.api.failure.v1 import Failure
from temporalio.api.update.v1 import UpdateRef
from temporalio.api.workflowservice.v1 import (
GetWorkflowExecutionHistoryRequest,
PollWorkflowExecutionUpdateRequest,
ResetStickyTaskQueueRequest,
)
from temporalio.bridge.proto.workflow_activation import WorkflowActivation
Expand Down Expand Up @@ -4216,11 +4218,36 @@ async def test_workflow_update_before_worker_start(
task_queue=task_queue,
)

async def update_exists() -> bool:
try:
await client.workflow_service.poll_workflow_execution_update(
PollWorkflowExecutionUpdateRequest(
namespace=client.namespace,
update_ref=UpdateRef(
workflow_execution=WorkflowExecution(workflow_id=handle.id),
update_id="my-update",
),
)
)
return True
except RPCError as err:
if err.status != RPCStatusCode.NOT_FOUND:
raise
return False

# Confirm update not there
assert not await update_exists()

# Execute update in background
update_task = asyncio.create_task(
handle.execute_update(ImmediatelyCompleteUpdateAndWorkflow.update)
handle.execute_update(
ImmediatelyCompleteUpdateAndWorkflow.update, id="my-update"
)
)

# Wait until update exists
await assert_eq_eventually(True, update_exists)

# Start no-cache worker on the task queue
async with new_worker(
client,
Expand Down

0 comments on commit aa26503

Please sign in to comment.