Skip to content

Commit e283499

Browse files
Queue::fake the two cancel/terminate-while-waiting-on-activity tests
Same bucket A pattern as d042ea9: tests that wait for the workflow to park on an activity were racing the real testbench queue workers. Activity-wait variants weren't covered by d042ea9 (which only handled timer-wait variants). Conversion uses runReadyTaskForRun(Workflow) before the waitFor instead of drainReadyTasks because draining further would also run the dispatched activity task and complete the activity before the test could cancel. After the cancel, drainReadyTasks finishes the cancellation workflow task chain. Clears 2 CI-only MySQL failures under #399: * testWorkflowCanBeCancelledWithReasonWhileWaitingOnActivity * testWorkflowCanBeTerminatedWithReasonWhileWaitingOnActivity Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 543c0ec commit e283499

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/Feature/V2/V2WorkflowTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7731,18 +7731,24 @@ public function testRepairReturnsAcceptedNoOpForRowOnlyOpenChildFallback(): void
77317731

77327732
public function testWorkflowCanBeCancelledWithReasonWhileWaitingOnActivity(): void
77337733
{
7734+
Queue::fake();
7735+
77347736
$workflow = WorkflowStub::make(TestHeartbeatWorkflow::class, 'cancel-activity-wait');
77357737
$workflow->start();
77367738

77377739
$runId = $workflow->runId();
77387740

77397741
$this->assertNotNull($runId);
77407742

7743+
$this->runReadyTaskForRun($runId, TaskType::Workflow);
7744+
77417745
$this->waitFor(static fn (): bool => $workflow->refresh()->status() === 'waiting'
77427746
&& $workflow->summary()?->wait_kind === 'activity');
77437747

77447748
$result = $workflow->cancel('Customer requested cancellation');
77457749

7750+
$this->drainReadyTasks();
7751+
77467752
$this->assertTrue($result->accepted());
77477753
$this->assertSame('cancel', $result->type());
77487754
$this->assertSame('cancelled', $result->outcome());
@@ -7815,18 +7821,24 @@ public function testWorkflowCanBeCancelledWithReasonWhileWaitingOnActivity(): vo
78157821

78167822
public function testWorkflowCanBeTerminatedWithReasonWhileWaitingOnActivity(): void
78177823
{
7824+
Queue::fake();
7825+
78187826
$workflow = WorkflowStub::make(TestHeartbeatWorkflow::class, 'terminate-activity-wait');
78197827
$workflow->start();
78207828

78217829
$runId = $workflow->runId();
78227830

78237831
$this->assertNotNull($runId);
78247832

7833+
$this->runReadyTaskForRun($runId, TaskType::Workflow);
7834+
78257835
$this->waitFor(static fn (): bool => $workflow->refresh()->status() === 'waiting'
78267836
&& $workflow->summary()?->wait_kind === 'activity');
78277837

78287838
$result = $workflow->terminate('Operator emergency shutdown');
78297839

7840+
$this->drainReadyTasks();
7841+
78307842
$this->assertTrue($result->accepted());
78317843
$this->assertSame('terminate', $result->type());
78327844
$this->assertSame('terminated', $result->outcome());

0 commit comments

Comments
 (0)