Skip to content

Commit 9f594ec

Browse files
committed
Merge remote-tracking branch 'origin/MC-20710' into MC-19282-web-setup
2 parents cabf0c9 + 9cfadcf commit 9f594ec

File tree

7 files changed

+13
-70
lines changed

7 files changed

+13
-70
lines changed

app/code/Magento/Elasticsearch/Setup/InstallConfig.php

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,13 @@ public function configure(array $inputOptions)
6363
$configKey = $this->searchConfigMapping[$inputKey];
6464
$this->configWriter->save(self::CATALOG_SEARCH . $configKey, $inputValue);
6565
}
66-
67-
if ($this->doValidation($inputOptions)) {
68-
if (!$this->validator->validate($inputOptions[SearchConfigOptionsList::INPUT_KEY_SEARCH_ENGINE])) {
69-
throw new InputException(
70-
__(
71-
'Connection to Elasticsearch cannot be established. '
72-
. 'Please check the configuration and try again.'
73-
)
74-
);
75-
}
76-
}
77-
}
78-
79-
/**
80-
* Check if elasticsearch validation should be performed
81-
*
82-
* @param array $inputOptions
83-
* @return bool
84-
*/
85-
private function doValidation(array $inputOptions): bool
86-
{
87-
if (isset($inputOptions[SearchConfigOptionsList::INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION])) {
88-
return !$inputOptions[SearchConfigOptionsList::INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION];
66+
if (!$this->validator->validate($inputOptions[SearchConfigOptionsList::INPUT_KEY_SEARCH_ENGINE])) {
67+
throw new InputException(
68+
__(
69+
'Connection to Elasticsearch cannot be established. '
70+
. 'Please check the configuration and try again.'
71+
)
72+
);
8973
}
90-
return true;
9174
}
9275
}

app/code/Magento/Elasticsearch/Test/Unit/Setup/InstallConfigTest.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,4 @@ public function testConfigureValidateFail()
112112

113113
$this->installConfig->configure($inputOptions);
114114
}
115-
116-
public function testConfigureWithSkipValidation()
117-
{
118-
$inputOptions = [
119-
'search-engine' => 'elasticsearch5',
120-
'elasticsearch-host' => 'localhost',
121-
'elasticsearch-port' => '9200',
122-
'skip-elasticsearch-validation' => true
123-
];
124-
125-
$this->configWriterMock
126-
->expects($this->at(0))
127-
->method('save')
128-
->with('catalog/search/engine', 'elasticsearch5');
129-
$this->configWriterMock
130-
->expects($this->at(1))
131-
->method('save')
132-
->with('catalog/search/elasticsearch5_server_hostname', 'localhost');
133-
$this->configWriterMock
134-
->expects($this->at(2))
135-
->method('save')
136-
->with('catalog/search/elasticsearch5_server_port', '9200');
137-
$this->validatorMock->expects($this->never())->method('validate');
138-
139-
$this->installConfig->configure($inputOptions);
140-
}
141115
}

app/code/Magento/Search/Setup/CompositeInstallConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function configure(array $inputOptions)
3535
$searchEngine = $inputOptions['search-engine'];
3636

3737
if (!isset($this->installConfigList[$searchEngine])) {
38-
throw new InputException(__('Unable to configure search engine: ' . $searchEngine));
38+
throw new InputException(__('Unable to configure search engine: %1', $searchEngine));
3939
}
4040
$installConfig = $this->installConfigList[$searchEngine];
4141

setup/src/Magento/Setup/Model/SearchConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private function validateSearchEngineSelection(array $searchOptions)
6969
{
7070
if (isset($searchOptions[SearchConfigOptionsList::INPUT_KEY_SEARCH_ENGINE])) {
7171
$selectedEngine = $searchOptions[SearchConfigOptionsList::INPUT_KEY_SEARCH_ENGINE];
72-
if (!in_array($selectedEngine, SearchConfigOptionsList::AVAILABLE_SEARCH_ENGINES)) {
72+
$availableEngines = $this->searchConfigOptionsList->getAvailableSearchEngineList();
73+
if (!isset($availableEngines[$selectedEngine])) {
7374
throw new SetupException("Search engine '{$selectedEngine}' is not an available search engine.");
7475
}
7576
}

setup/src/Magento/Setup/Model/SearchConfigOptionsList.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
class SearchConfigOptionsList
1919
{
20-
const AVAILABLE_SEARCH_ENGINES = ['elasticsearch5', 'elasticsearch6', 'elasticsearch7'];
21-
2220
/**
2321
* Input key for the options
2422
*/
@@ -30,7 +28,6 @@ class SearchConfigOptionsList
3028
const INPUT_KEY_ELASTICSEARCH_PASSWORD = 'elasticsearch-password';
3129
const INPUT_KEY_ELASTICSEARCH_INDEX_PREFIX = 'elasticsearch-index-prefix';
3230
const INPUT_KEY_ELASTICSEARCH_TIMEOUT = 'elasticsearch-timeout';
33-
const INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION = 'skip-elasticsearch-validation';
3431

3532
/**
3633
* Default values
@@ -52,9 +49,9 @@ public function getOptionsList(): array
5249
new SelectConfigOption(
5350
self::INPUT_KEY_SEARCH_ENGINE,
5451
SelectConfigOption::FRONTEND_WIZARD_SELECT,
55-
self::AVAILABLE_SEARCH_ENGINES,
52+
array_keys($this->getAvailableSearchEngineList()),
5653
'',
57-
'Search engine.',
54+
'Search engine. Values: ' . implode(', ', array_keys($this->getAvailableSearchEngineList())),
5855
self::DEFAULT_SEARCH_ENGINE
5956
),
6057
new TextConfigOption(
@@ -102,12 +99,6 @@ public function getOptionsList(): array
10299
'',
103100
'Elasticsearch server timeout.',
104101
self::DEFAULT_ELASTICSEARCH_TIMEOUT
105-
),
106-
new FlagConfigOption(
107-
self::INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION,
108-
'',
109-
'Skip Elasticsearch connection validation.',
110-
null
111102
)
112103
];
113104
}

setup/src/Magento/Setup/Test/Unit/Model/SearchConfigOptionsListTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function setup()
3030
public function testGetOptionsList()
3131
{
3232
$optionsList = $this->searchConfigOptionsList->getOptionsList();
33-
$this->assertCount(9, $optionsList);
33+
$this->assertCount(8, $optionsList);
3434

3535
$this->assertArrayHasKey(0, $optionsList);
3636
$this->assertInstanceOf(SelectConfigOption::class, $optionsList[0]);
@@ -67,9 +67,5 @@ public function testGetOptionsList()
6767
$this->assertArrayHasKey(7, $optionsList);
6868
$this->assertInstanceOf(TextConfigOption::class, $optionsList[7]);
6969
$this->assertEquals('elasticsearch-timeout', $optionsList[7]->getName());
70-
71-
$this->assertArrayHasKey(8, $optionsList);
72-
$this->assertInstanceOf(FlagConfigOption::class, $optionsList[8]);
73-
$this->assertEquals('skip-elasticsearch-validation', $optionsList[8]->getName());
7470
}
7571
}

setup/src/Magento/Setup/Test/Unit/Model/SearchConfigTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ public function installInputDataProvider()
112112
'elasticsearch-enable-auth' => false,
113113
'elasticsearch-index-prefix' => 'magento2',
114114
'elasticsearch-timeout' => 15,
115-
'skip-elasticsearch-validation' => false,
116115
'no-interaction' => false,
117116
],
118117
'search' => [
@@ -122,7 +121,6 @@ public function installInputDataProvider()
122121
'elasticsearch-enable-auth' => false,
123122
'elasticsearch-index-prefix' => 'magento2',
124123
'elasticsearch-timeout' => 15,
125-
'skip-elasticsearch-validation' => false,
126124
]
127125
]
128126
];

0 commit comments

Comments
 (0)