File tree Expand file tree Collapse file tree 5 files changed +85
-10
lines changed
dev/tests/integration/testsuite/Magento/Elasticsearch
Catalog/Model/Indexer/Category/Product/Action Expand file tree Collapse file tree 5 files changed +85
-10
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ class RowsTest extends \PHPUnit\Framework\TestCase
5454 */
5555 private $ fulltextSearchCollectionFactory ;
5656
57+ /**
58+ * Elasticsearch7 engine configuration is also compatible with OpenSearch 1
59+ */
60+ private const ENGINE_SUPPORTED_VERSIONS = [
61+ 7 => 'elasticsearch7 ' ,
62+ 1 => 'elasticsearch7 ' ,
63+ ];
64+
5765 /**
5866 * @inheritdoc
5967 */
@@ -71,7 +79,14 @@ protected function setUp(): void
7179 protected function assertPreConditions (): void
7280 {
7381 $ currentEngine = $ this ->objectManager ->get (EngineResolverInterface::class)->getCurrentSearchEngine ();
74- $ this ->assertEquals ($ this ->getInstalledSearchEngine (), $ currentEngine );
82+ $ this ->assertEquals (
83+ $ this ->getInstalledSearchEngine (),
84+ $ currentEngine ,
85+ sprintf (
86+ 'Search engine configuration "%s" is not compatible with the installed version ' ,
87+ $ currentEngine
88+ )
89+ );
7590 }
7691
7792 /**
@@ -84,7 +99,7 @@ private function getInstalledSearchEngine(): string
8499 if (!$ this ->searchEngine ) {
85100 // phpstan:ignore "Class Magento\TestModuleCatalogSearch\Model\ElasticsearchVersionChecker not found."
86101 $ version = $ this ->objectManager ->get (ElasticsearchVersionChecker::class)->getVersion ();
87- $ this ->searchEngine = 'elasticsearch ' . $ version ;
102+ $ this ->searchEngine = self :: ENGINE_SUPPORTED_VERSIONS [ $ version ] ?? 'elasticsearch ' . $ version ;
88103 }
89104
90105 return $ this ->searchEngine ;
Original file line number Diff line number Diff line change @@ -58,6 +58,14 @@ class ElasticsearchTest extends \PHPUnit\Framework\TestCase
5858 */
5959 private $ productRepository ;
6060
61+ /**
62+ * Elasticsearch7 engine configuration is also compatible with OpenSearch 1
63+ */
64+ private const ENGINE_SUPPORTED_VERSIONS = [
65+ 7 => 'elasticsearch7 ' ,
66+ 1 => 'elasticsearch7 ' ,
67+ ];
68+
6169 protected function setUp (): void
6270 {
6371 $ objectManager = Bootstrap::getObjectManager ();
@@ -78,7 +86,14 @@ protected function setUp(): void
7886 protected function assertPreConditions (): void
7987 {
8088 $ currentEngine = Bootstrap::getObjectManager ()->get (EngineResolverInterface::class)->getCurrentSearchEngine ();
81- $ this ->assertEquals ($ this ->getInstalledSearchEngine (), $ currentEngine );
89+ $ this ->assertEquals (
90+ $ this ->getInstalledSearchEngine (),
91+ $ currentEngine ,
92+ sprintf (
93+ 'Search engine configuration "%s" is not compatible with the installed version ' ,
94+ $ currentEngine
95+ )
96+ );
8297 }
8398
8499 /**
@@ -169,7 +184,7 @@ private function getInstalledSearchEngine()
169184 if (!$ this ->searchEngine ) {
170185 // phpstan:ignore "Class Magento\TestModuleCatalogSearch\Model\ElasticsearchVersionChecker not found."
171186 $ version = Bootstrap::getObjectManager ()->get (ElasticsearchVersionChecker::class)->getVersion ();
172- $ this ->searchEngine = 'elasticsearch ' . $ version ;
187+ $ this ->searchEngine = self :: ENGINE_SUPPORTED_VERSIONS [ $ version ] ?? 'elasticsearch ' . $ version ;
173188 }
174189 return $ this ->searchEngine ;
175190 }
Original file line number Diff line number Diff line change @@ -72,6 +72,14 @@ class IndexHandlerTest extends TestCase
7272 */
7373 private $ searchIndexNameResolver ;
7474
75+ /**
76+ * Elasticsearch7 engine configuration is also compatible with OpenSearch 1
77+ */
78+ private const ENGINE_SUPPORTED_VERSIONS = [
79+ 7 => 'elasticsearch7 ' ,
80+ 1 => 'elasticsearch7 ' ,
81+ ];
82+
7583 /**
7684 * {@inheritdoc}
7785 */
@@ -100,7 +108,14 @@ protected function setUp(): void
100108 protected function assertPreConditions (): void
101109 {
102110 $ currentEngine = Bootstrap::getObjectManager ()->get (EngineResolverInterface::class)->getCurrentSearchEngine ();
103- $ this ->assertEquals ($ this ->getInstalledSearchEngine (), $ currentEngine );
111+ $ this ->assertEquals (
112+ $ this ->getInstalledSearchEngine (),
113+ $ currentEngine ,
114+ sprintf (
115+ 'Search engine configuration "%s" is not compatible with the installed version ' ,
116+ $ currentEngine
117+ )
118+ );
104119 }
105120
106121 /**
@@ -306,7 +321,7 @@ private function getInstalledSearchEngine()
306321 if (!$ this ->searchEngine ) {
307322 // phpstan:ignore "Class Magento\TestModuleCatalogSearch\Model\ElasticsearchVersionChecker not found."
308323 $ version = Bootstrap::getObjectManager ()->get (ElasticsearchVersionChecker::class)->getVersion ();
309- $ this ->searchEngine = 'elasticsearch ' . $ version ;
324+ $ this ->searchEngine = self :: ENGINE_SUPPORTED_VERSIONS [ $ version ] ?? 'elasticsearch ' . $ version ;
310325 }
311326 return $ this ->searchEngine ;
312327 }
Original file line number Diff line number Diff line change @@ -63,6 +63,14 @@ class ReindexAllTest extends \PHPUnit\Framework\TestCase
6363 */
6464 private $ productRepository ;
6565
66+ /**
67+ * Elasticsearch7 engine configuration is also compatible with OpenSearch 1
68+ */
69+ private const ENGINE_SUPPORTED_VERSIONS = [
70+ 7 => 'elasticsearch7 ' ,
71+ 1 => 'elasticsearch7 ' ,
72+ ];
73+
6674 protected function setUp (): void
6775 {
6876 $ this ->connectionManager = Bootstrap::getObjectManager ()->create (ConnectionManager::class);
@@ -79,7 +87,14 @@ protected function setUp(): void
7987 protected function assertPreConditions (): void
8088 {
8189 $ currentEngine = Bootstrap::getObjectManager ()->get (EngineResolverInterface::class)->getCurrentSearchEngine ();
82- $ this ->assertEquals ($ this ->getInstalledSearchEngine (), $ currentEngine );
90+ $ this ->assertEquals (
91+ $ this ->getInstalledSearchEngine (),
92+ $ currentEngine ,
93+ sprintf (
94+ 'Search engine configuration "%s" is not compatible with the installed version ' ,
95+ $ currentEngine
96+ )
97+ );
8398 }
8499
85100 /**
@@ -279,7 +294,7 @@ private function getInstalledSearchEngine()
279294 if (!$ this ->searchEngine ) {
280295 // phpstan:ignore "Class Magento\TestModuleCatalogSearch\Model\ElasticsearchVersionChecker not found."
281296 $ version = Bootstrap::getObjectManager ()->get (ElasticsearchVersionChecker::class)->getVersion ();
282- $ this ->searchEngine = 'elasticsearch ' . $ version ;
297+ $ this ->searchEngine = self :: ENGINE_SUPPORTED_VERSIONS [ $ version ] ?? 'elasticsearch ' . $ version ;
283298 }
284299 return $ this ->searchEngine ;
285300 }
Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ class AdapterTest extends \PHPUnit\Framework\TestCase
5050 */
5151 private $ searchEngine ;
5252
53+ /**
54+ * Elasticsearch7 engine configuration is also compatible with OpenSearch 1
55+ */
56+ private const ENGINE_SUPPORTED_VERSIONS = [
57+ 7 => 'elasticsearch7 ' ,
58+ 1 => 'elasticsearch7 ' ,
59+ ];
60+
5361 /**
5462 * @inheritdoc
5563 */
@@ -104,7 +112,14 @@ protected function createAdapter()
104112 protected function assertPreConditions (): void
105113 {
106114 $ currentEngine = $ this ->objectManager ->get (EngineResolverInterface::class)->getCurrentSearchEngine ();
107- $ this ->assertEquals ($ this ->getInstalledSearchEngine (), $ currentEngine );
115+ $ this ->assertEquals (
116+ $ this ->getInstalledSearchEngine (),
117+ $ currentEngine ,
118+ sprintf (
119+ 'Search engine configuration "%s" is not compatible with the installed version ' ,
120+ $ currentEngine
121+ )
122+ );
108123 }
109124
110125 /**
@@ -737,7 +752,7 @@ private function getInstalledSearchEngine()
737752 if (!$ this ->searchEngine ) {
738753 // phpstan:ignore "Class Magento\TestModuleCatalogSearch\Model\ElasticsearchVersionChecker not found."
739754 $ version = $ this ->objectManager ->get (ElasticsearchVersionChecker::class)->getVersion ();
740- $ this ->searchEngine = 'elasticsearch ' . $ version ;
755+ $ this ->searchEngine = self :: ENGINE_SUPPORTED_VERSIONS [ $ version ] ?? 'elasticsearch ' . $ version ;
741756 }
742757 return $ this ->searchEngine ;
743758 }
You can’t perform that action at this time.
0 commit comments