Skip to content

Commit f730e89

Browse files
authored
MCLOUD-7122: Error in mysqladmin ping command (#4)
1 parent ef2d43c commit f730e89

File tree

8 files changed

+62
-25
lines changed

8 files changed

+62
-25
lines changed

src/Compose/ProductionBuilder/Service/Database/Db.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CloudDocker\Compose\ProductionBuilder\Service\Database;
99

1010
use Magento\CloudDocker\Compose\BuilderInterface;
11+
use Magento\CloudDocker\Compose\ProductionBuilder\Service\Database\Db\HealthCheck;
1112
use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface;
1213
use Magento\CloudDocker\Compose\ProductionBuilder\Volume;
1314
use Magento\CloudDocker\Config\Config;
@@ -28,15 +29,21 @@ class Db implements ServiceBuilderInterface
2829
* @var Volume
2930
*/
3031
private $volume;
32+
/**
33+
* @var HealthCheck
34+
*/
35+
private $healthCheck;
3136

3237
/**
3338
* @param ServiceFactory $serviceFactory
3439
* @param Volume $volume
40+
* @param HealthCheck $healthCheck
3541
*/
36-
public function __construct(ServiceFactory $serviceFactory, Volume $volume)
42+
public function __construct(ServiceFactory $serviceFactory, Volume $volume, HealthCheck $healthCheck)
3743
{
3844
$this->serviceFactory = $serviceFactory;
3945
$this->volume = $volume;
46+
$this->healthCheck = $healthCheck;
4047
}
4148

4249
/**
@@ -64,12 +71,7 @@ public function getConfig(Config $config): array
6471
$dbConfig = [
6572
'ports' => [$port ? "$port:3306" : '3306'],
6673
'volumes' => $this->getMounts($config),
67-
BuilderInterface::SERVICE_HEALTHCHECK => [
68-
'test' => 'mysqladmin ping -h localhost',
69-
'interval' => '30s',
70-
'timeout' => '30s',
71-
'retries' => 3
72-
],
74+
BuilderInterface::SERVICE_HEALTHCHECK => $this->healthCheck->getConfig(),
7375
];
7476

7577
if ($commands = $this->getCommands($config)) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudDocker\Compose\ProductionBuilder\Service\Database\Db;
9+
10+
/**
11+
* Returns health check configuration of database containers
12+
*/
13+
class HealthCheck
14+
{
15+
/**
16+
* Returns health check configuration of database containers
17+
*
18+
* @return array
19+
*/
20+
public function getConfig(): array
21+
{
22+
return [
23+
'test' => 'mysqladmin ping -h localhost -pmagento2',
24+
'interval' => '30s',
25+
'timeout' => '30s',
26+
'retries' => 3
27+
];
28+
}
29+
}

src/Compose/ProductionBuilder/Service/Database/DbQuote.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CloudDocker\Compose\ProductionBuilder\Service\Database;
99

1010
use Magento\CloudDocker\Compose\BuilderInterface;
11+
use Magento\CloudDocker\Compose\ProductionBuilder\Service\Database\Db\HealthCheck;
1112
use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface;
1213
use Magento\CloudDocker\Compose\ProductionBuilder\Volume;
1314
use Magento\CloudDocker\Config\Config;
@@ -29,14 +30,21 @@ class DbQuote implements ServiceBuilderInterface
2930
*/
3031
private $volume;
3132

33+
/**
34+
* @var HealthCheck
35+
*/
36+
private $healthCheck;
37+
3238
/**
3339
* @param ServiceFactory $serviceFactory
3440
* @param Volume $volume
41+
* @param HealthCheck $healthCheck
3542
*/
36-
public function __construct(ServiceFactory $serviceFactory, Volume $volume)
43+
public function __construct(ServiceFactory $serviceFactory, Volume $volume, HealthCheck $healthCheck)
3744
{
3845
$this->serviceFactory = $serviceFactory;
3946
$this->volume = $volume;
47+
$this->healthCheck = $healthCheck;
4048
}
4149

4250
/**
@@ -64,12 +72,7 @@ public function getConfig(Config $config): array
6472
$dbConfig = [
6573
'ports' => [$port ? "$port:3306" : '3306'],
6674
'volumes' => $this->getMounts($config),
67-
BuilderInterface::SERVICE_HEALTHCHECK => [
68-
'test' => 'mysqladmin ping -h localhost',
69-
'interval' => '30s',
70-
'timeout' => '30s',
71-
'retries' => 3
72-
],
75+
BuilderInterface::SERVICE_HEALTHCHECK => $this->healthCheck->getConfig(),
7376
];
7477

7578
return $this->serviceFactory->create(

src/Compose/ProductionBuilder/Service/Database/DbSales.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CloudDocker\Compose\ProductionBuilder\Service\Database;
99

1010
use Magento\CloudDocker\Compose\BuilderInterface;
11+
use Magento\CloudDocker\Compose\ProductionBuilder\Service\Database\Db\HealthCheck;
1112
use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface;
1213
use Magento\CloudDocker\Compose\ProductionBuilder\Volume;
1314
use Magento\CloudDocker\Config\Config;
@@ -29,14 +30,21 @@ class DbSales implements ServiceBuilderInterface
2930
*/
3031
private $volume;
3132

33+
/**
34+
* @var HealthCheck
35+
*/
36+
private $healthCheck;
37+
3238
/**
3339
* @param ServiceFactory $serviceFactory
3440
* @param Volume $volume
41+
* @param HealthCheck $healthCheck
3542
*/
36-
public function __construct(ServiceFactory $serviceFactory, Volume $volume)
43+
public function __construct(ServiceFactory $serviceFactory, Volume $volume, HealthCheck $healthCheck)
3744
{
3845
$this->serviceFactory = $serviceFactory;
3946
$this->volume = $volume;
47+
$this->healthCheck = $healthCheck;
4048
}
4149

4250
/**
@@ -64,12 +72,7 @@ public function getConfig(Config $config): array
6472
$dbConfig = [
6573
'ports' => [$port ? "$port:3306" : '3306'],
6674
'volumes' => $this->getMounts($config),
67-
BuilderInterface::SERVICE_HEALTHCHECK => [
68-
'test' => 'mysqladmin ping -h localhost',
69-
'interval' => '30s',
70-
'timeout' => '30s',
71-
'retries' => 3
72-
],
75+
BuilderInterface::SERVICE_HEALTHCHECK => $this->healthCheck->getConfig(),
7376
];
7477

7578
return $this->serviceFactory->create(

src/Test/Integration/_files/cloud_base/docker-compose.exp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- 'mymagento-magento-db:/var/lib/mysql'
1717
- '.docker/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d'
1818
healthcheck:
19-
test: 'mysqladmin ping -h localhost'
19+
test: 'mysqladmin ping -h localhost -pmagento2'
2020
interval: 30s
2121
timeout: 30s
2222
retries: 3

src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- 'mymagento-magento-db:/var/lib/mysql'
1717
- '.docker/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d'
1818
healthcheck:
19-
test: 'mysqladmin ping -h localhost'
19+
test: 'mysqladmin ping -h localhost -pmagento2'
2020
interval: 30s
2121
timeout: 30s
2222
retries: 3

src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- 'mymagento-magento-db:/var/lib/mysql'
1717
- '.docker/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d'
1818
healthcheck:
19-
test: 'mysqladmin ping -h localhost'
19+
test: 'mysqladmin ping -h localhost -pmagento2'
2020
interval: 30s
2121
timeout: 30s
2222
retries: 3

src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- '.docker/mnt:/mnt:rw,delegated'
1515
- 'magento-magento-db:/var/lib/mysql'
1616
healthcheck:
17-
test: 'mysqladmin ping -h localhost'
17+
test: 'mysqladmin ping -h localhost -pmagento2'
1818
interval: 30s
1919
timeout: 30s
2020
retries: 3

0 commit comments

Comments
 (0)