mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-11-07 16:02:38 +00:00
Fixes in WaitForHealthCheck params and legacy tests
This commit is contained in:
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Testcontainers\Container;
|
||||
|
||||
use Testcontainers\Utils\PortGenerator\FixedPortGenerator;
|
||||
|
||||
/**
|
||||
* Added for backward compatibility.
|
||||
* @deprecated Use GenericContainer instead.
|
||||
@@ -52,6 +54,7 @@ class Container extends GenericContainer
|
||||
*/
|
||||
public function withPort(string $localPort, string $containerPort): self
|
||||
{
|
||||
$this->withPortGenerator(new FixedPortGenerator([(int)$localPort]));
|
||||
return $this->withExposedPorts($containerPort);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,12 +123,19 @@ class GenericContainer implements TestContainer
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withHealthCheckCommand(string $command, int $healthCheckIntervalInMS = 1000): static
|
||||
{
|
||||
$this->healthConfig = new HealthConfig([
|
||||
'Test' => ['CMD', $command],
|
||||
'Interval' => $healthCheckIntervalInMS,
|
||||
]);
|
||||
public function withHealthCheckCommand(
|
||||
string $command,
|
||||
int $intervalInMilliseconds = 1000,
|
||||
int $timeoutInMilliseconds = 3000,
|
||||
int $retries = 3,
|
||||
int $startPeriodInMilliseconds = 0
|
||||
): static {
|
||||
$this->healthConfig = new HealthConfig();
|
||||
$this->healthConfig->setTest(['CMD-SHELL', $command]);
|
||||
$this->healthConfig->setInterval($intervalInMilliseconds * 1_000_000);
|
||||
$this->healthConfig->setTimeout($timeoutInMilliseconds * 1_000_000);
|
||||
$this->healthConfig->setRetries($retries);
|
||||
$this->healthConfig->setStartPeriod($startPeriodInMilliseconds * 1_000_000);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user