Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions testing/src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>error</error>');
$this->output->writeln('Error starting Temporal server: ' . $this->temporalServerProcess->getErrorOutput());
exit(1);
Expand Down
9 changes: 8 additions & 1 deletion tests/Acceptance/App/Runtime/RRStarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions tests/Acceptance/App/Runtime/TemporalStarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Temporal\Tests\Acceptance\App\Runtime;

use Symfony\Component\Process\Process;
use Temporal\Common\SearchAttributes\ValueType;
use Temporal\Testing\Environment;

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Extra/Versioning/DeploymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Acceptance/Harness/Signal/PreventCloseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/Acceptance/Harness/Update/TaskFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 7 additions & 1 deletion tests/Functional/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading