Skip to content
Open
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
18 changes: 12 additions & 6 deletions testing/src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function startTemporalServer(
$this->temporalServerProcess->start();

$deadline = \microtime(true) + $commandTimeout;
while (!$temporalStarted && \microtime(true) < $deadline) {
while ($this->temporalServerProcess->isRunning() && !$temporalStarted && \microtime(true) < $deadline) {
\usleep(10_000);
$check = new Process([
$this->systemInfo->temporalCliExecutable,
Expand Down Expand Up @@ -192,7 +192,7 @@ public function startTemporalTestServer(int $commandTimeout = 10): void
/**
* @param array<string, mixed> $envs
*/
public function startRoadRunner(?string $rrCommand = null, int $commandTimeout = 10, array $envs = [], string $configFile = '.rr.yaml'): void
public function startRoadRunner(string|array|null $rrCommand = null, int $commandTimeout = 10, array $envs = [], string $configFile = '.rr.yaml'): void
{
if (!$this->isTemporalRunning() && !$this->isTemporalTestRunning()) {
$this->io->error([
Expand All @@ -201,8 +201,14 @@ public function startRoadRunner(?string $rrCommand = null, int $commandTimeout =
exit(1);
}

if (is_string($rrCommand)) {
$rrCommand = \explode(' ', $rrCommand);
}

$rrCommand ??= [$this->systemInfo->rrExecutable, 'serve', '-c', $configFile];

$this->roadRunnerProcess = new Process(
command: $rrCommand ? \explode(' ', $rrCommand) : [$this->systemInfo->rrExecutable, 'serve'],
command: $rrCommand,
env: $envs,
);
$this->roadRunnerProcess->setTimeout($commandTimeout);
Expand All @@ -214,16 +220,16 @@ public function startRoadRunner(?string $rrCommand = null, int $commandTimeout =

// wait for roadrunner to start
$deadline = \microtime(true) + $commandTimeout;
while (!$roadRunnerStarted && \microtime(true) < $deadline) {
while ($this->roadRunnerProcess->isRunning() && !$roadRunnerStarted && \microtime(true) < $deadline) {
\usleep(10_000);
$check = new Process([$this->systemInfo->rrExecutable, 'workers', '-c', $configFile]);
$check = new Process(array_map(static fn ($arg) => $arg === 'serve' ? 'workers' : $arg, $rrCommand));
$check->run();
if (\str_contains($check->getOutput(), 'Workers of')) {
$roadRunnerStarted = true;
}
}

if (!$roadRunnerStarted) {
if (!$roadRunnerStarted || !$this->roadRunnerProcess->isRunning()) {
$this->io->error(\sprintf(
'Failed to start until RoadRunner is ready. Status: "%s". Stderr: "%s". Stdout: "%s".',
$this->roadRunnerProcess->getStatus(),
Expand Down
Loading