Adjust tests for OpenSearch

This commit is contained in:
Sergei Shitikov
2024-09-01 19:12:46 +02:00
parent ea07a96091
commit 93c9895027
5 changed files with 10 additions and 5 deletions
+1
View File
@@ -14,6 +14,7 @@
<testsuites>
<testsuite name="default">
<directory>tests</directory>
<exclude>tests/Integration/WaitStrategyTest.php</exclude>
</testsuite>
</testsuites>
+1 -2
View File
@@ -12,9 +12,8 @@ class MySQLContainer extends GenericContainer
{
parent::__construct('mysql:' . $version);
$this->withExposedPorts(3306);
$this->withWait(new WaitForLog('ready for connections'));
$this->withEnvironment('MYSQL_ROOT_PASSWORD', $mysqlRootPassword);
$this->withWait(new WaitForLog('ready for connections'));
}
/**
+6 -1
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Testcontainers\Container;
use Testcontainers\Wait\WaitForHttp;
use Testcontainers\Wait\WaitForLog;
class OpenSearchContainer extends GenericContainer
{
@@ -14,7 +15,11 @@ class OpenSearchContainer extends GenericContainer
$this->withExposedPorts(9200);
$this->withEnvironment('discovery.type', 'single-node');
$this->withEnvironment('OPENSEARCH_INITIAL_ADMIN_PASSWORD', 'c3o_ZPHo!');
$this->withWait(WaitForHttp::make(9200));
$this->withWait(new WaitForLog(
'/\]\s+started\?\[/',
true,
30000
));
}
/**
+1 -1
View File
@@ -19,7 +19,7 @@ class MySQLContainerTest extends ContainerTestCase
public function testMySQLContainer(): void
{
$pdo = new \PDO(
sprintf('mysql:host=%s;port=3306', self::$container->getAddress()),
sprintf('mysql:host=%s;port=3306', '127.0.0.1'),
'bar',
'baz',
);
@@ -21,7 +21,7 @@ class OpenSearchContainerTest extends ContainerTestCase
public function testOpenSearch(): void
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, sprintf('http://%s:%d', self::$container->getAddress(), 9200));
curl_setopt($ch, CURLOPT_URL, sprintf('http://%s:%d', '127.0.0.1', 9200));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = (string) curl_exec($ch);