Skip to content

Commit 9d0c7c5

Browse files
Roman HaninRoman Hanin
authored andcommitted
B2B-1832: Error when reindex Catalog Search index during the snapshot of elasticsearch
- unit test fix
1 parent b92eac4 commit 9d0c7c5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ public function cleanIndex($storeId, $mappedIndexerId)
252252
}
253253
} while ($indexExists);
254254

255-
256255
foreach ($deleteQueue as $indexToDelete) {
257256
// remove index if already exists, wildcard deletion may cause collisions
258257
try {

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/ElasticsearchTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,23 @@ public function testCleanIndex()
336336
{
337337
$this->indexNameResolver->expects($this->any())
338338
->method('getIndexName')
339-
->with(1, 'product', [])
340-
->willReturn('indexName_product_1_v');
339+
->willReturnMap([[1, 'product', [1 => null], '_product_1_v0']]);
341340

342-
$this->client->expects($this->atLeastOnce())
341+
$this->client->expects($this->any())
343342
->method('indexExists')
344-
->willReturn(true);
345-
$this->client->expects($this->once())
343+
->willReturnMap(
344+
[
345+
['_product_1_v1', true],
346+
['_product_1_v2', true],
347+
['_product_1_v3', false],
348+
]
349+
);
350+
$this->client->expects($this->exactly(2))
346351
->method('deleteIndex')
347-
->with('_product_1_v1');
352+
->willReturnMap([
353+
['_product_1_v1'],
354+
['_product_1_v2'],
355+
]);
348356
$this->assertSame(
349357
$this->model,
350358
$this->model->cleanIndex(1, 'product')

0 commit comments

Comments
 (0)