diff --git a/testing/src/Environment.php b/testing/src/Environment.php index e4391a98f..7ca4de41c 100644 --- a/testing/src/Environment.php +++ b/testing/src/Environment.php @@ -103,14 +103,30 @@ public function startTemporalServer( ], ); $this->temporalServerProcess->setTimeout($commandTimeout); - $this->temporalServerProcess->start(); + $temporalStarted = false; + $this->temporalServerProcess->start(function ($type, $output) use (&$temporalStarted): void { + if ($type === Process::OUT && \str_contains($output, 'Server: ')) { + $check = new Process([$this->systemInfo->temporalCliExecutable, 'operator', 'cluster', 'health']); + $check->run(); + if (\str_contains($check->getOutput(), 'SERVING')) { + $temporalStarted = true; + } + } + }); - $deadline = \microtime(true) + 1.2; - while (!$this->temporalServerProcess->isRunning() && \microtime(true) < $deadline) { - \usleep(10_000); + $deadline = \microtime(true) + $commandTimeout; + while (!$temporalStarted && \microtime(true) < $deadline) { + \usleep(50_000); + if (!$temporalStarted) { + $check = new Process([$this->systemInfo->temporalCliExecutable, 'operator', 'cluster', 'health']); + $check->run(); + if (\str_contains($check->getOutput(), 'SERVING')) { + $temporalStarted = true; + } + } } - if (!$this->temporalServerProcess->isRunning()) { + if (!$temporalStarted || !$this->temporalServerProcess->isRunning()) { $this->output->writeln('error'); $this->output->writeln('Error starting Temporal server: ' . $this->temporalServerProcess->getErrorOutput()); exit(1); diff --git a/tests/Acceptance/App/Runtime/RRStarter.php b/tests/Acceptance/App/Runtime/RRStarter.php index 5169560fc..9ab4688c7 100644 --- a/tests/Acceptance/App/Runtime/RRStarter.php +++ b/tests/Acceptance/App/Runtime/RRStarter.php @@ -16,7 +16,14 @@ public function __construct( private State $runtime, ) { $this->environment = Environment::create(); - \register_shutdown_function(fn() => $this->stop()); + $starter = $this; + \register_shutdown_function(static function () use ($starter): void { + try { + $starter->stop(); + } catch (\Throwable $e) { + echo $e; + } + }); } public function start(): void diff --git a/tests/Acceptance/App/Runtime/TemporalStarter.php b/tests/Acceptance/App/Runtime/TemporalStarter.php index 7ef1a530b..5e3d27118 100644 --- a/tests/Acceptance/App/Runtime/TemporalStarter.php +++ b/tests/Acceptance/App/Runtime/TemporalStarter.php @@ -4,7 +4,6 @@ namespace Temporal\Tests\Acceptance\App\Runtime; -use Symfony\Component\Process\Process; use Temporal\Common\SearchAttributes\ValueType; use Temporal\Testing\Environment; @@ -16,7 +15,14 @@ final class TemporalStarter public function __construct() { $this->environment = Environment::create(); - \register_shutdown_function(fn() => $this->stop()); + $starter = $this; + \register_shutdown_function(static function () use ($starter): void { + try { + $starter->stop(); + } catch (\Throwable $e) { + echo $e; + } + }); } public function start(): void diff --git a/tests/Acceptance/Extra/Versioning/DeploymentTest.php b/tests/Acceptance/Extra/Versioning/DeploymentTest.php index 7662b2231..9060d3ea5 100644 --- a/tests/Acceptance/Extra/Versioning/DeploymentTest.php +++ b/tests/Acceptance/Extra/Versioning/DeploymentTest.php @@ -207,7 +207,7 @@ public static function setCurrentDeployment(TemporalStarter $starter): void '--deployment-name', WorkerFactory::DEPLOYMENT_NAME, '--build-id', WorkerFactory::BUILD_ID, '--yes', - ], timeout: 5); + ], timeout: 6); } } diff --git a/tests/Acceptance/Harness/Signal/PreventCloseTest.php b/tests/Acceptance/Harness/Signal/PreventCloseTest.php index 23128ebd7..aa6d7f826 100644 --- a/tests/Acceptance/Harness/Signal/PreventCloseTest.php +++ b/tests/Acceptance/Harness/Signal/PreventCloseTest.php @@ -36,8 +36,6 @@ public static function checkSignalOutOfExecution( public static function checkPreventClose( #[Stub('Harness_Signal_PreventClose')]WorkflowStubInterface $stub, ): void { - self::markTestSkipped('research a better way'); - $stub->signal('add', 1); // Wait that the first signal is processed diff --git a/tests/Acceptance/Harness/Update/TaskFailureTest.php b/tests/Acceptance/Harness/Update/TaskFailureTest.php index 8db8a912b..5b34accea 100644 --- a/tests/Acceptance/Harness/Update/TaskFailureTest.php +++ b/tests/Acceptance/Harness/Update/TaskFailureTest.php @@ -21,8 +21,6 @@ class TaskFailureTest extends TestCase public static function retryableException( #[Stub('Harness_Update_TaskFailure')] WorkflowStubInterface $stub, ): void { - self::markTestSkipped('Todo: doesnt pass in some cases'); - try { $stub->update('do_update'); throw new \RuntimeException('Expected validation exception'); diff --git a/tests/Functional/bootstrap.php b/tests/Functional/bootstrap.php index 9726420da..5737f134c 100644 --- a/tests/Functional/bootstrap.php +++ b/tests/Functional/bootstrap.php @@ -30,7 +30,13 @@ ]), ])); -\register_shutdown_function(static fn() => $environment->stop()); +\register_shutdown_function(static function () use ($environment): void { + try { + $environment->stop(); + } catch (\Throwable $e) { + echo $e; + } +}); // Default feature flags FeatureFlags::$warnOnWorkflowUnfinishedHandlers = false;