Skip to content

Commit c7f9510

Browse files
authored
MAGE-870 Integration tests (#1528)
* try to re-add integration tests to circleci * update tests config * update tests config * update tests config * test with another image * test with another image * test with another image * revert changes on circleci * improve QueueTests * MAGE-870: remove comments
1 parent 27a936e commit c7f9510

File tree

9 files changed

+79
-82
lines changed

9 files changed

+79
-82
lines changed

Setup/Patch/Schema/ConfigPatch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ConfigPatch implements SchemaPatchInterface
8181

8282
'algoliasearch_synonyms/synonyms_group/enable_synonyms' => '0',
8383

84-
'algoliasearch_advanced/advanced/number_of_element_by_page' => '300',
84+
'algoliasearch_advanced/queue/number_of_element_by_page' => '300',
8585
'algoliasearch_advanced/advanced/remove_words_if_no_result' => 'allOptional',
8686
'algoliasearch_advanced/advanced/partial_update' => '0',
8787
'algoliasearch_advanced/advanced/customer_groups_enable' => '0',
@@ -92,7 +92,7 @@ class ConfigPatch implements SchemaPatchInterface
9292
'algoliasearch_advanced/advanced/prevent_backend_rendering' => '0',
9393
'algoliasearch_advanced/advanced/prevent_backend_rendering_display_mode' => 'all',
9494
'algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents' => "Googlebot\nBingbot",
95-
'algoliasearch_advanced/advanced/archive_clear_limit' => '30',
95+
'algoliasearch_advanced/queue/archive_clear_limit' => '30',
9696
];
9797

9898
/**

Test/Integration/AssertValues/Magento_2_3.php renamed to Test/Integration/AssertValues/Magento23.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Test\Integration\AssertValues;
44

5-
class Magento_2_3
5+
class Magento23
66
{
77
public $productsOnStockCount = 186;
88
public $productsOutOfStockCount = 187;

Test/Integration/AssertValues/Magento244.php renamed to Test/Integration/AssertValues/Magento24.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Algolia\AlgoliaSearch\Test\Integration\AssertValues;
44

5-
class Magento244
5+
class Magento24
66
{
77
public $productsOnStockCount = 180;
8-
public $productsOutOfStockCount = 183;
8+
public $productsOutOfStockCount = 181;
99
public $lastJobDataSize = 13;
10-
public $expectedCategory = 17;
10+
public $expectedCategory = 16;
1111
public $attributesForFaceting = 5;
1212
public $automaticalSetOfCategoryAttributesForFaceting = 4;
13-
public $expectedPages = 9;
14-
public $expectedExcludePages = 7;
13+
public $expectedPages = 6;
14+
public $expectedExcludePages = 4;
1515
}

Test/Integration/AssertValues/Magento_2_01.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

Test/Integration/AssertValues/Magento_2_2.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

Test/Integration/PagesIndexingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class PagesIndexingTest extends IndexingTestCase
1010
{
11-
public function testOnlyOnStockProducts()
11+
public function testNoExcludedPages()
1212
{
1313
$this->setConfig(
1414
'algoliasearch_autocomplete/autocomplete/excluded_pages',

Test/Integration/QueueTest.php

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,35 @@
1313

1414
class QueueTest extends TestCase
1515
{
16+
private const INCOMPLETE_REASON = "Must revisit transaction handling across connections.";
17+
1618
/** @var JobsCollectionFactory */
1719
private $jobsCollectionFactory;
1820

1921
/** @var AdapterInterface */
2022
private $connection;
2123

24+
/** @var Queue */
25+
private $queue;
26+
2227
public function setUp(): void
2328
{
2429
parent::setUp();
2530

2631
$this->jobsCollectionFactory = $this->getObjectManager()->create(JobsCollectionFactory::class);
2732

28-
/** @var ResourceConnection $resouce */
29-
$resouce = $this->getObjectManager()->create(ResourceConnection::class);
30-
$this->connection = $resouce->getConnection();
33+
/** @var ResourceConnection $resource */
34+
$resource = $this->getObjectManager()->create(ResourceConnection::class);
35+
$this->connection = $resource->getConnection();
36+
37+
$this->queue = $this->getObjectManager()->create(Queue::class);
3138
}
3239

3340
public function testFill()
3441
{
3542
$this->resetConfigs([
3643
'algoliasearch_queue/queue/number_of_job_to_run',
37-
'algoliasearch_advanced/advanced/number_of_element_by_page',
44+
'algoliasearch_advanced/queue/number_of_element_by_page',
3845
]);
3946

4047
$this->setConfig('algoliasearch_queue/queue/active', '1');
@@ -72,9 +79,14 @@ public function testFill()
7279
}
7380
}
7481

75-
/** @depends testFill */
82+
/**
83+
* @depends testFill
84+
* @magentoDbIsolation disabled
85+
*/
7686
public function testExecute()
7787
{
88+
$this->markTestIncomplete(self::INCOMPLETE_REASON);
89+
7890
$this->setConfig('algoliasearch_queue/queue/active', '1');
7991

8092
/** @var Queue $queue */
@@ -123,11 +135,14 @@ public function testExecute()
123135
$this->assertEquals(0, count($rows)); */
124136
}
125137

138+
/**
139+
* @magentoDbIsolation disabled
140+
*/
126141
public function testSettings()
127142
{
128143
$this->resetConfigs([
129144
'algoliasearch_queue/queue/number_of_job_to_run',
130-
'algoliasearch_advanced/advanced/number_of_element_by_page',
145+
'algoliasearch_advanced/queue/number_of_element_by_page',
131146
'algoliasearch_instant/instant/facets',
132147
'algoliasearch_products/products/product_additional_attributes',
133148
]);
@@ -163,11 +178,14 @@ public function testSettings()
163178
$this->assertFalse(empty($settings['searchableAttributes']), 'SearchableAttributes should be set, but they are not.');
164179
}
165180

181+
/**
182+
* @magentoDbIsolation disabled
183+
*/
166184
public function testMergeSettings()
167185
{
168186
$this->setConfig('algoliasearch_queue/queue/active', '1');
169187
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 1);
170-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 300);
188+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 300);
171189

172190
$this->connection->query('DELETE FROM algoliasearch_queue');
173191

@@ -202,6 +220,9 @@ public function testMergeSettings()
202220
$this->assertEquals(['sku'], $settings['disableTypoToleranceOnAttributes']);
203221
}
204222

223+
/**
224+
* @magentoDbIsolation disabled
225+
*/
205226
public function testMerging()
206227
{
207228
$this->connection->query('DELETE FROM algoliasearch_queue');
@@ -376,6 +397,7 @@ public function testMerging()
376397
],
377398
],
378399
'locked_at' => null,
400+
'debug' => null,
379401
];
380402

381403
/** @var Job $categoryJob */
@@ -404,13 +426,17 @@ public function testMerging()
404426
],
405427
],
406428
'locked_at' => null,
429+
'debug' => null,
407430
];
408431

409432
/** @var Job $productJob */
410433
$productJob = $mergedJobs[3];
411434
$this->assertEquals($expectedProductJob, $productJob->toArray());
412435
}
413436

437+
/**
438+
* @magentoDbIsolation disabled
439+
*/
414440
public function testMergingWithStaticMethods()
415441
{
416442
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
@@ -539,15 +565,12 @@ public function testMergingWithStaticMethods()
539565
],
540566
];
541567

542-
/** @var Queue $queue */
543-
$queue = $this->getObjectManager()->create(Queue::class);
544-
545568
$this->connection->insertMultiple('algoliasearch_queue', $data);
546569

547570
/** @var Job[] $jobs */
548571
$jobs = $this->jobsCollectionFactory->create()->getItems();
549572

550-
$jobs = array_values($this->invokeMethod($queue, 'mergeJobs', [$jobs]));
573+
$jobs = array_values($this->invokeMethod($this->queue, 'mergeJobs', [$jobs]));
551574
$this->assertEquals(12, count($jobs));
552575

553576
$this->assertEquals('rebuildStoreCategoryIndex', $jobs[0]->getMethod());
@@ -564,8 +587,13 @@ public function testMergingWithStaticMethods()
564587
$this->assertEquals('rebuildStoreProductIndex', $jobs[11]->getMethod());
565588
}
566589

590+
/**
591+
* @magentoDbIsolation disabled
592+
*/
567593
public function testGetJobs()
568594
{
595+
$this->markTestIncomplete(self::INCOMPLETE_REASON);
596+
569597
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
570598

571599
$data = [
@@ -706,11 +734,8 @@ public function testGetJobs()
706734

707735
$this->connection->insertMultiple('algoliasearch_queue', $data);
708736

709-
/** @var Queue $queue */
710-
$queue = $this->getObjectManager()->create(Queue::class);
711-
712737
$pid = getmypid();
713-
$jobs = $this->invokeMethod($queue, 'getJobs', ['maxJobs' => 10]);
738+
$jobs = $this->invokeMethod($this->queue, 'getJobs', ['maxJobs' => 10]);
714739
$this->assertEquals(6, count($jobs));
715740

716741
$expectedFirstJob = [
@@ -736,6 +761,7 @@ public function testGetJobs()
736761
],
737762
],
738763
'locked_at' => null,
764+
'debug' => null,
739765
];
740766

741767
$expectedLastJob = [
@@ -760,6 +786,7 @@ public function testGetJobs()
760786
],
761787
],
762788
'locked_at' => null,
789+
'debug' => null,
763790
];
764791

765792
/** @var Job $firstJob */
@@ -780,11 +807,14 @@ public function testGetJobs()
780807
}
781808
}
782809

810+
/**
811+
* @magentoDbIsolation disabled
812+
*/
783813
public function testHugeJob()
784814
{
785815
// Default value - maxBatchSize = 1000
786816
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
787-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
817+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 100);
788818

789819
$productIds = range(1, 5000);
790820
$jsonProductIds = json_encode($productIds);
@@ -794,12 +824,9 @@ public function testHugeJob()
794824
(1, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"1","product_ids":' . $jsonProductIds . '}\', 3, 0, \'\', 5000),
795825
(2, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"2","product_ids":["9","22"]}\', 3, 0, \'\', 2);');
796826

797-
/** @var Queue $queue */
798-
$queue = $this->getObjectManager()->create(Queue::class);
799-
800827
$pid = getmypid();
801828
/** @var Job[] $jobs */
802-
$jobs = $this->invokeMethod($queue, 'getJobs', ['maxJobs' => 10]);
829+
$jobs = $this->invokeMethod($this->queue, 'getJobs', ['maxJobs' => 10]);
803830

804831
$this->assertEquals(1, count($jobs));
805832

@@ -818,11 +845,14 @@ public function testHugeJob()
818845
$this->assertNull($lastJob['pid']);
819846
}
820847

848+
/**
849+
* @magentoDbIsolation disabled
850+
*/
821851
public function testMaxSingleJobSize()
822852
{
823853
// Default value - maxBatchSize = 1000
824854
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
825-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
855+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 100);
826856

827857
$productIds = range(1, 99);
828858
$jsonProductIds = json_encode($productIds);
@@ -832,13 +862,10 @@ public function testMaxSingleJobSize()
832862
(1, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"1","product_ids":' . $jsonProductIds . '}\', 3, 0, \'\', 99),
833863
(2, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"2","product_ids":["9","22"]}\', 3, 0, \'\', 2);');
834864

835-
/** @var Queue $queue */
836-
$queue = $this->getObjectManager()->create(Queue::class);
837-
838865
$pid = getmypid();
839866

840867
/** @var Job[] $jobs */
841-
$jobs = $this->invokeMethod($queue, 'getJobs', ['maxJobs' => 10]);
868+
$jobs = $this->invokeMethod($this->queue, 'getJobs', ['maxJobs' => 10]);
842869

843870
$this->assertEquals(2, count($jobs));
844871

@@ -862,17 +889,20 @@ public function testMaxSingleJobSize()
862889
$this->assertEquals($pid, $lastJob['pid']);
863890
}
864891

892+
/**
893+
* @magentoDbIsolation disabled
894+
*/
865895
public function testMaxSingleJobsSizeOnProductReindex()
866896
{
867897
$this->resetConfigs([
868898
'algoliasearch_queue/queue/number_of_job_to_run',
869-
'algoliasearch_advanced/advanced/number_of_element_by_page',
899+
'algoliasearch_advanced/queue/number_of_element_by_page',
870900
]);
871901

872902
$this->setConfig('algoliasearch_queue/queue/active', '1');
873903

874904
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
875-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
905+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 100);
876906

877907
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
878908

0 commit comments

Comments
 (0)