Skip to content

Commit 5cfc4f2

Browse files
committed
refactor: replace workflow execution polling with direct history inspection in ActivityPausedTest for improved clarity
1 parent 4ce0a67 commit 5cfc4f2

1 file changed

Lines changed: 11 additions & 19 deletions

File tree

tests/Acceptance/Extra/Activity/ActivityPausedTest.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\Test;
88
use Temporal\Activity;
99
use Temporal\Api\Common\V1\WorkflowExecution;
10-
use Temporal\Api\Workflowservice\V1\DescribeWorkflowExecutionRequest;
1110
use Temporal\Api\Workflowservice\V1\PauseActivityRequest;
1211
use Temporal\Client\GRPC\ServiceClientInterface;
1312
use Temporal\Client\WorkflowClientInterface;
@@ -28,27 +27,20 @@ public function simplePause(
2827
WorkflowClientInterface $workflowClient,
2928
): void {
3029
$deadline = \microtime(true) + 10;
31-
$started = false;
32-
while (\microtime(true) < $deadline) {
33-
$response = $serviceClient->DescribeWorkflowExecution(
34-
(new DescribeWorkflowExecutionRequest())
35-
->setNamespace('default')
36-
->setExecution(
37-
(new WorkflowExecution())
38-
->setWorkflowId($stub->getExecution()->getID())
39-
->setRunId($stub->getExecution()->getRunID()),
40-
),
41-
);
42-
foreach ($response->getPendingActivities() as $pending) {
43-
if ($pending->hasLastStartedTime()) {
44-
$started = true;
45-
break 2;
46-
}
30+
find:
31+
$found = false;
32+
foreach ($workflowClient->getWorkflowHistory($stub->getExecution()) as $event) {
33+
if ($event->hasActivityTaskScheduledEventAttributes()) {
34+
$found = true;
35+
break;
4736
}
48-
\usleep(50_000);
4937
}
5038

51-
self::assertTrue($started, 'Activity did not reach STARTED state in pending_activities');
39+
if (!$found && \microtime(true) < $deadline) {
40+
goto find;
41+
}
42+
43+
self::assertTrue($found, '`Activity task started` event not found in workflow history');
5244

5345
$serviceClient->PauseActivity(
5446
(new PauseActivityRequest())

0 commit comments

Comments
 (0)