Skip to content

Commit 51b0991

Browse files
committed
Merge branch 'develop' into AC-3208-symfony-upgrade
2 parents 8d41746 + b1e9cd1 commit 51b0991

File tree

3 files changed

+84
-6
lines changed

3 files changed

+84
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/ece-tools",
33
"description": "Provides tools to build and deploy Magento 2 Enterprise Edition",
44
"type": "magento2-component",
5-
"version": "2002.1.10",
5+
"version": "2002.1.11",
66
"license": "OSL-3.0",
77
"repositories": {
88
"repo.magento.com": {

src/Config/Validator/Deploy/ElasticSuiteIntegrity.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\MagentoCloud\Config\ValidatorException;
1616
use Magento\MagentoCloud\Config\ValidatorInterface;
1717
use Magento\MagentoCloud\Service\ElasticSearch;
18+
use Magento\MagentoCloud\Service\OpenSearch;
1819

1920
/**
2021
* Validates different aspects of ElasticSuite's configuration.
@@ -31,6 +32,11 @@ class ElasticSuiteIntegrity implements ValidatorInterface
3132
*/
3233
private $elasticSearch;
3334

35+
/**
36+
* @var OpenSearch
37+
*/
38+
private $openSearch;
39+
3440
/**
3541
* @var Validator\ResultFactory
3642
*/
@@ -44,24 +50,27 @@ class ElasticSuiteIntegrity implements ValidatorInterface
4450
/**
4551
* @param ElasticSuite $elasticSuite
4652
* @param ElasticSearch $elasticSearch
53+
* @param OpenSearch $openSearch
4754
* @param Validator\ResultFactory $resultFactory
4855
* @param DeployInterface $config
4956
*/
5057
public function __construct(
5158
ElasticSuite $elasticSuite,
5259
ElasticSearch $elasticSearch,
60+
OpenSearch $openSearch,
5361
Validator\ResultFactory $resultFactory,
5462
DeployInterface $config
5563
) {
5664
$this->elasticSuite = $elasticSuite;
5765
$this->elasticSearch = $elasticSearch;
66+
$this->openSearch = $openSearch;
5867
$this->resultFactory = $resultFactory;
5968
$this->config = $config;
6069
}
6170

6271
/**
6372
* If ElasticSuite is absent - skip validation.
64-
* If ElasticSuite is present and no ElasticSearch connection - fail validation.
73+
* If ElasticSuite is present and no ElasticSearch or OpenSearch connection - fail validation.
6574
* If search engine is manually set to non-ElasticSuite it will fail after deploy - fail validation.
6675
*
6776
* Otherwise - validation is successful.
@@ -76,9 +85,9 @@ public function validate(): Validator\ResultInterface
7685
return $this->resultFactory->success();
7786
}
7887

79-
if (!$this->elasticSearch->isInstalled()) {
88+
if (!$this->elasticSearch->isInstalled() && !$this->openSearch->isInstalled()) {
8089
return $this->resultFactory->error(
81-
'ElasticSuite is installed without available ElasticSearch service.',
90+
'ElasticSuite is installed without available ElasticSearch or OpenSearch service.',
8291
'',
8392
Error::DEPLOY_ELASTIC_SUITE_WITHOUT_ES
8493
);

src/Test/Unit/Config/Validator/Deploy/ElasticSuiteIntegrityTest.php

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\MagentoCloud\Config\Validator\Result\Success;
1616
use Magento\MagentoCloud\Config\Validator\ResultFactory;
1717
use Magento\MagentoCloud\Service\ElasticSearch;
18+
use Magento\MagentoCloud\Service\OpenSearch;
1819
use PHPUnit\Framework\MockObject\MockObject;
1920
use PHPUnit\Framework\TestCase;
2021

@@ -38,6 +39,11 @@ class ElasticSuiteIntegrityTest extends TestCase
3839
*/
3940
private $elasticSearchMock;
4041

42+
/**
43+
* @var OpenSearch|MockObject
44+
*/
45+
private $openSearchMock;
46+
4147
/**
4248
* @var ResultFactory|MockObject
4349
*/
@@ -55,12 +61,14 @@ protected function setUp(): void
5561
{
5662
$this->elasticSuiteMock = $this->createMock(ElasticSuite::class);
5763
$this->elasticSearchMock = $this->createMock(ElasticSearch::class);
64+
$this->openSearchMock = $this->createMock(OpenSearch::class);
5865
$this->resultFactoryMock = $this->createMock(ResultFactory::class);
5966
$this->stageConfigMock = $this->createMock(DeployInterface::class);
6067

6168
$this->validator = new ElasticSuiteIntegrity(
6269
$this->elasticSuiteMock,
6370
$this->elasticSearchMock,
71+
$this->openSearchMock,
6472
$this->resultFactoryMock,
6573
$this->stageConfigMock
6674
);
@@ -71,25 +79,82 @@ public function testValidate()
7179
$this->elasticSuiteMock->expects($this->once())
7280
->method('isInstalled')
7381
->willReturn(false);
82+
$this->elasticSearchMock->expects($this->never())
83+
->method('isInstalled');
84+
$this->openSearchMock->expects($this->never())
85+
->method('isInstalled');
86+
$this->resultFactoryMock->expects($this->once())
87+
->method('success')
88+
->willReturn(new Success());
89+
90+
$this->assertInstanceOf(Success::class, $this->validator->validate());
91+
}
92+
93+
public function testValidateEsOs()
94+
{
95+
$this->elasticSuiteMock->expects($this->once())
96+
->method('isInstalled')
97+
->willReturn(true);
98+
$this->openSearchMock->expects($this->once())
99+
->method('isInstalled')
100+
->willReturn(true);
101+
$this->resultFactoryMock->expects($this->once())
102+
->method('success')
103+
->willReturn(new Success());
104+
105+
$this->assertInstanceOf(Success::class, $this->validator->validate());
106+
}
107+
108+
public function testValidateEs()
109+
{
110+
$this->elasticSuiteMock->expects($this->once())
111+
->method('isInstalled')
112+
->willReturn(true);
113+
$this->elasticSearchMock->expects($this->once())
114+
->method('isInstalled')
115+
->willReturn(true);
116+
$this->openSearchMock->expects($this->never())
117+
->method('isInstalled');
118+
$this->resultFactoryMock->expects($this->once())
119+
->method('success')
120+
->willReturn(new Success());
121+
122+
$this->assertInstanceOf(Success::class, $this->validator->validate());
123+
}
124+
125+
public function testValidateOs()
126+
{
127+
$this->elasticSuiteMock->expects($this->once())
128+
->method('isInstalled')
129+
->willReturn(true);
130+
$this->elasticSearchMock->expects($this->once())
131+
->method('isInstalled')
132+
->willReturn(false);
133+
$this->openSearchMock->expects($this->once())
134+
->method('isInstalled')
135+
->willReturn(true);
74136
$this->resultFactoryMock->expects($this->once())
75137
->method('success')
76138
->willReturn(new Success());
77139

78140
$this->assertInstanceOf(Success::class, $this->validator->validate());
79141
}
80142

81-
public function testValidateNoESInstalled()
143+
public function testValidateNoESandOSInstalled()
82144
{
83145
$this->elasticSuiteMock->expects($this->once())
84146
->method('isInstalled')
85147
->willReturn(true);
86148
$this->elasticSearchMock->expects($this->once())
87149
->method('isInstalled')
88150
->willReturn(false);
151+
$this->openSearchMock->expects($this->once())
152+
->method('isInstalled')
153+
->willReturn(false);
89154
$this->resultFactoryMock->expects($this->once())
90155
->method('error')
91156
->with(
92-
'ElasticSuite is installed without available ElasticSearch service.',
157+
'ElasticSuite is installed without available ElasticSearch or OpenSearch service.',
93158
'',
94159
AppError::DEPLOY_ELASTIC_SUITE_WITHOUT_ES
95160
)
@@ -106,6 +171,8 @@ public function testValidateSearchEngineIsMysql()
106171
$this->elasticSearchMock->expects($this->once())
107172
->method('isInstalled')
108173
->willReturn(true);
174+
$this->openSearchMock->expects($this->never())
175+
->method('isInstalled');
109176
$this->stageConfigMock->expects($this->once())
110177
->method('get')
111178
->with(DeployInterface::VAR_SEARCH_CONFIGURATION)
@@ -130,6 +197,8 @@ public function testValidateNoErrors()
130197
$this->elasticSearchMock->expects($this->once())
131198
->method('isInstalled')
132199
->willReturn(true);
200+
$this->openSearchMock->expects($this->never())
201+
->method('isInstalled');
133202
$this->stageConfigMock->expects($this->once())
134203
->method('get')
135204
->with(DeployInterface::VAR_SEARCH_CONFIGURATION)

0 commit comments

Comments
 (0)