Skip to content

Commit 31ffc46

Browse files
committed
MAGE-1226: updated queue tests
1 parent c2403a2 commit 31ffc46

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

Test/Integration/Indexing/Queue/QueueTest.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace Algolia\AlgoliaSearch\Test\Integration\Indexing\Queue;
44

55
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
6-
use Algolia\AlgoliaSearch\Model\Indexer\Product;
76
use Algolia\AlgoliaSearch\Model\Indexer\QueueRunner;
87
use Algolia\AlgoliaSearch\Model\IndicesConfigurator;
98
use Algolia\AlgoliaSearch\Model\Job;
109
use Algolia\AlgoliaSearch\Model\Queue;
1110
use Algolia\AlgoliaSearch\Model\ResourceModel\Job\CollectionFactory as JobsCollectionFactory;
11+
use Algolia\AlgoliaSearch\Service\Product\BatchQueueProcessor as ProductBatchQueueProcessor;
1212
use Algolia\AlgoliaSearch\Test\Integration\TestCase;
1313
use Magento\Framework\App\ResourceConnection;
1414
use Magento\Framework\DB\Adapter\AdapterInterface;
@@ -19,8 +19,6 @@
1919
*/
2020
class QueueTest extends TestCase
2121
{
22-
private const INCOMPLETE_REASON = "Must revisit transaction handling across connections.";
23-
2422
/** @var JobsCollectionFactory */
2523
private $jobsCollectionFactory;
2624

@@ -53,9 +51,8 @@ public function testFill()
5351
$this->setConfig(ConfigHelper::IS_ACTIVE, '1');
5452
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
5553

56-
/** @var Product $indexer */
57-
$indexer = $this->objectManager->get(Product::class);
58-
$indexer->executeFull();
54+
$productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
55+
$productBatchQueueProcessor->processBatch(1);
5956

6057
$rows = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
6158
$this->assertEquals(3, count($rows));
@@ -90,9 +87,8 @@ public function testExecute()
9087
$this->setConfig(ConfigHelper::IS_ACTIVE, '1');
9188
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
9289

93-
/** @var Product $indexer */
94-
$indexer = $this->objectManager->get(Product::class);
95-
$indexer->executeFull();
90+
$productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
91+
$productBatchQueueProcessor->processBatch(1);
9692

9793
/** @var Queue $queue */
9894
$queue = $this->objectManager->get(Queue::class);
@@ -154,11 +150,10 @@ public function testSettings()
154150
$this->connection->query('DELETE FROM algoliasearch_queue');
155151

156152
// Reindex products multiple times
157-
/** @var Product $indexer */
158-
$indexer = $this->objectManager->get(Product::class);
159-
$indexer->executeFull();
160-
$indexer->executeFull();
161-
$indexer->executeFull();
153+
$productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
154+
$productBatchQueueProcessor->processBatch(1);
155+
$productBatchQueueProcessor->processBatch(1);
156+
$productBatchQueueProcessor->processBatch(1);
162157

163158
$rows = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
164159
$this->assertEquals(9, count($rows));
@@ -188,9 +183,8 @@ public function testMergeSettings()
188183

189184
$this->connection->query('DELETE FROM algoliasearch_queue');
190185

191-
/** @var Product $productIndexer */
192-
$productIndexer = $this->objectManager->get(Product::class);
193-
$productIndexer->executeFull();
186+
$productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
187+
$productBatchQueueProcessor->processBatch(1);
194188

195189
$rows = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
196190
$this->assertCount(3, $rows);
@@ -884,9 +878,8 @@ public function testMaxSingleJobsSizeOnProductReindex()
884878

885879
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
886880

887-
/** @var Product $indexer */
888-
$indexer = $this->objectManager->get(Product::class);
889-
$indexer->execute(range(1, 512));
881+
$productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
882+
$productBatchQueueProcessor->processBatch(1, range(1, 512));
890883

891884
$dbJobs = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
892885
$this->assertSame(6, count($dbJobs));

0 commit comments

Comments
 (0)