From fe2e151092cb26e403b469c3ecb331da391c9890 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Tue, 9 Apr 2024 19:43:49 +0400 Subject: [PATCH] Fix test --- .../Client/UntypedWorkflowStubTestCase.php | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/Functional/Client/UntypedWorkflowStubTestCase.php b/tests/Functional/Client/UntypedWorkflowStubTestCase.php index dd91ec0a..dd6b5d20 100644 --- a/tests/Functional/Client/UntypedWorkflowStubTestCase.php +++ b/tests/Functional/Client/UntypedWorkflowStubTestCase.php @@ -218,24 +218,38 @@ public function testDescribe(): void $client = $this->createClient(); $simple = $client->newUntypedWorkflowStub('SimpleSignalledWorkflowWithSleep'); - $e = $client->start($simple, -1); + $run = $client->start($simple, -1); + $startAt = \microtime(true); - $stubDescription = $simple->describe(); - $runDescription = $e->describe(); + do { + $stubDescription = $simple->describe(); + // 5 seconds limit + if (\microtime(true) - $startAt > 5) { + throw new InvalidArgumentException('Workflow execution not started'); + } + // wait for workflow was started on a worker + } while ($stubDescription->info->historyLength < 5); + + $runDescription = $run->describe(); self::assertEquals($stubDescription, $runDescription); self::assertSame(WorkflowExecutionStatus::Running, $runDescription->info->status); $simple->terminate('user triggered'); - // Wait a little bit for the workflow to terminate - \usleep(1000); + try { + // Wait for termination + $simple->getResult(); + } catch (WorkflowFailedException $e) { + $this->assertInstanceOf(TerminatedFailure::class, $e->getPrevious()); + } $stubDescription = $simple->describe(); - $runDescription = $e->describe(); + $runDescription = $run->describe(); // After termination self::assertEquals($stubDescription, $runDescription); self::assertSame(WorkflowExecutionStatus::Terminated, $runDescription->info->status); + self::assertSame(WorkflowExecutionStatus::Terminated, $stubDescription->info->status); } public function testSignalRunningWorkflowWithInheritedSignal()