Skip to content

Commit 06a392d

Browse files
committed
MCLOUD-9951: MCD uses wrong OpenSearch version for Magento 2.4.6
1 parent c278b58 commit 06a392d

File tree

17 files changed

+778
-4
lines changed

17 files changed

+778
-4
lines changed

src/Compose/ProductionBuilder/Service/OpenSearch.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@
1818
*/
1919
class OpenSearch implements ServiceBuilderInterface
2020
{
21+
/**
22+
* The list of installed plugins by default
23+
*/
2124
private const INSTALLED_PLUGINS = ['analysis-icu', 'analysis-phonetic'];
2225

26+
/**
27+
* The default OpenSearch version, which will be used if config has only major version
28+
*/
29+
private const DEFAULT_VERSION = '2.4';
30+
2331
/**
2432
* @var ServiceFactory
2533
*/
@@ -75,7 +83,7 @@ public function getConfig(Config $config): array
7583

7684
return $this->serviceFactory->create(
7785
$this->getServiceName(),
78-
$config->getServiceVersion($this->getServiceName()),
86+
$this->getVersion($config),
7987
!empty($osEnvVars) ? ['environment' => $osEnvVars] : [],
8088
$config->getServiceImage($this->getServiceName()),
8189
$config->getCustomRegistry(),
@@ -98,4 +106,18 @@ public function getDependsOn(Config $config): array
98106
{
99107
return [];
100108
}
109+
110+
/**
111+
* If config has only major version 2 - returns default OpenSearch version for MCD
112+
* @see OpenSearch::DEFAULT_VERSION
113+
*
114+
* @param Config $config
115+
* @return string
116+
* @throws \Magento\CloudDocker\App\ConfigurationMismatchException
117+
*/
118+
private function getVersion(Config $config): string
119+
{
120+
$version = $config->getServiceVersion($this->getServiceName());
121+
return $version == '2' ? self::DEFAULT_VERSION : $version;
122+
}
101123
}

src/Test/Integration/BuildComposeTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ public function buildDataProvider(): array
8282
[CliSource::OPTION_WITH_MARIADB_CONF, true]
8383
]
8484
],
85+
'cloud-base-os-2-cli' => [
86+
__DIR__ . '/_files/cloud_base_os_2_cli',
87+
[
88+
[CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION],
89+
[CliSource::OPTION_WITH_ENTRYPOINT, true],
90+
[CliSource::OPTION_WITH_MARIADB_CONF, true],
91+
[CliSource::OPTION_OS, '2'],
92+
]
93+
],
94+
'cloud-base-os-2.3-cli' => [
95+
__DIR__ . '/_files/cloud_base_os_2.3_cli',
96+
[
97+
[CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION],
98+
[CliSource::OPTION_WITH_ENTRYPOINT, true],
99+
[CliSource::OPTION_WITH_MARIADB_CONF, true],
100+
[CliSource::OPTION_OS, '2.3'],
101+
]
102+
],
85103
'custom_registry' => [
86104
__DIR__ . '/_files/custom_registry',
87105
[

src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ return [
3030
[
3131
'host' => 'opensearch',
3232
'port' => '9200',
33-
'type' => 'opensearch:1.1'
33+
'type' => 'opensearch:2'
3434
]
3535
]
3636
])),

src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ elasticsearch:
1414
- plugin_2
1515

1616
opensearch:
17-
type: opensearchsearch:1.1
17+
type: opensearchsearch:2
1818
disk: 512
1919
configuration:
2020
plugins:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ services:
6565
- elasticsearch.magento2.docker
6666
opensearch:
6767
hostname: opensearch.magento2.docker
68-
image: 'magento/magento-cloud-docker-opensearch:1.1-1.2.0'
68+
image: 'magento/magento-cloud-docker-opensearch:2.4-1.2.0'
6969
ulimits:
7070
memlock:
7171
soft: -1

src/Test/Integration/_files/cloud_base_os_2.3_cli/.docker/.gitignore

Whitespace-only changes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
return [
4+
'MAGENTO_CLOUD_RELATIONSHIPS' => base64_encode(json_encode([
5+
'database' => [
6+
[
7+
'host' => 'db',
8+
'path' => 'magento2',
9+
'password' => 'magento2',
10+
'username' => 'magento2',
11+
'port' => '3306',
12+
'type' => 'mysql:10.2'
13+
]
14+
],
15+
'redis' => [
16+
[
17+
'host' => 'redis',
18+
'port' => '6379',
19+
'type' => 'redis:5.0'
20+
]
21+
],
22+
'elasticsearch' => [
23+
[
24+
'host' => 'elasticsearch',
25+
'port' => '9200',
26+
'type' => 'elasticsearch:6.5'
27+
]
28+
],
29+
'opensearch' => [
30+
[
31+
'host' => 'opensearch',
32+
'port' => '9200',
33+
'type' => 'opensearch:2.3'
34+
]
35+
]
36+
])),
37+
'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([
38+
'http://magento2.docker/' => [
39+
'type' => 'upstream',
40+
'original_url' => 'http://{default}'
41+
],
42+
'https://magento2.docker/' => [
43+
'type' => 'upstream',
44+
'original_url' => 'https://{default}'
45+
]
46+
])),
47+
'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([
48+
'ADMIN_EMAIL' => '[email protected]',
49+
'ADMIN_PASSWORD' => '123123q',
50+
'ADMIN_URL' => 'admin'
51+
])),
52+
'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([
53+
'hooks' => [
54+
55+
],
56+
'mounts' => [
57+
'var' => [
58+
'path' => 'var',
59+
'orig' => 'shared:files/var'
60+
],
61+
'app/etc' => [
62+
'path' => 'app/etc',
63+
'orig' => 'shared:files/etc'
64+
],
65+
'pub/media' => [
66+
'path' => 'pub/media',
67+
'orig' => 'shared:files/media'
68+
],
69+
'pub/static' => [
70+
'path' => 'pub/static',
71+
'orig' => 'shared:files/static'
72+
]
73+
]
74+
])),
75+
];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: magento
2+
3+
type: php:7.3
4+
build:
5+
flavor: composer
6+
7+
runtime:
8+
extensions:
9+
- redis
10+
- xsl
11+
- json
12+
- newrelic
13+
- sodium
14+
15+
relationships:
16+
database: "mysql:mysql"
17+
redis: "redis:redis"
18+
elasticsearch: "elasticsearch:elasticsearch"
19+
opensearch: "opensearch:opensearch"
20+
21+
mounts:
22+
"var": "shared:files/var"
23+
"app/etc": "shared:files/etc"
24+
"pub/media": "shared:files/media"
25+
"pub/static": "shared:files/static"
26+
27+
crons:
28+
cronrun:
29+
spec: "* * * * *"
30+
cmd: "php bin/magento cron:run"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
mysql:
2+
type: mysql:10.2
3+
disk: 2048
4+
5+
redis:
6+
type: redis:5.0
7+
8+
elasticsearch:
9+
type: elasticsearch:6.5
10+
disk: 1024
11+
configuration:
12+
plugins:
13+
- plugin_1
14+
- plugin_2
15+
16+
opensearch:
17+
type: opensearchsearch:1.1
18+
disk: 512
19+
configuration:
20+
plugins:
21+
- plugin_3
22+
- plugin_4
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "magento/project-enterprise-edition",
3+
"description": "Composer file for integration tests",
4+
"type": "project",
5+
"version": "2.2.0"
6+
}

0 commit comments

Comments
 (0)