diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-12-14 05:06:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 05:06:11 +0300 |
commit | abf347525a6ce7de1c8bfb3b088c131b14c6fdd5 (patch) | |
tree | 6e9f2799ff51089b9fe557e4d90b8c07b849812b /tests | |
parent | 14f852fcdf4c28e0cc3f93a62dbc9697a9cfdf5c (diff) |
Better detection for end of sharedSiteId queue (#16769)
* Better detection for end of sharedSiteId queue
* simpler solution
* simpler solution
* use timstamp to detect reset
* use timstamp to detect reset
* add debug log message
* cast to int since we do a strict not equals
Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php b/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php index 9e2d60199d..e956aa6775 100644 --- a/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php +++ b/tests/PHPUnit/Integration/CronArchive/SharedSiteIdsTest.php @@ -104,7 +104,7 @@ class SharedSiteIdsTest extends IntegrationTestCase $this->assertEquals(2, $this->sharedSiteIds->getNextSiteId()); // we fake to reset the sharedSiteIds by another process - $this->sharedSiteIds->setSiteIdsToArchive(array(1,2,5,9)); + $this->sharedSiteIds->setQueueWasReset(); // it detects that sites must have been processed by now $this->assertNull($this->sharedSiteIds->getNextSiteId()); @@ -153,4 +153,24 @@ class SharedSiteIdsTest extends IntegrationTestCase $this->assertEquals(4, $this->sharedSiteIds->getNumProcessedWebsites()); $this->assertEquals(array(), $this->sharedSiteIds->getAllSiteIdsToArchive()); } + + public function test_usingMultipleSharedSiteIdsDetectsFinishedAlready() + { + $this->sharedSiteIds = $this->makeSharedSiteIds(array(1), 'test'); + + // should ignore his queue and help processing the existing queue + $this->assertEquals(1, $this->sharedSiteIds->getNumSites()); + + // process the first and only site, the queue should be empty afterwards and will be reset next time + $this->assertEquals(1, $this->sharedSiteIds->getNextSiteId()); + + $second = $this->makeSharedSiteIds(array(1), 'test'); + $this->assertEquals(1, $second->getNumSites()); // now the second will init the sites back + + // should return null as it already processed site 1 before meaning there must have been a "reset" of sites + // within one archive run we do not want to process same siteID twice as we prefer the archiver to exit and then + // the next archiver works on that site again. Otherwise there could be race conditions where a core:archive + // process basically never ends + $this->assertNull($this->sharedSiteIds->getNextSiteId()); + } } |