diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2021-06-10 05:48:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-10 05:48:22 +0300 |
commit | 3a1467fc8378b3bebce1c11d161384e3d239d263 (patch) | |
tree | b93901315894f7b8bdb576d0843242a63828bb09 /tests | |
parent | 23cb53d35ead2312b8afc9a6ec91a5fe8f78723e (diff) |
Remove archive status locking since it is not needed anymore (#17657)
* Remove archive status locking since it is not needed with the status and ts_started columns in the archive_invalidation table.
* fix some tests
Diffstat (limited to 'tests')
5 files changed, 83 insertions, 129 deletions
diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php deleted file mode 100644 index daa156ce23..0000000000 --- a/tests/PHPUnit/Integration/ArchiveProcessor/ArchivingStatusTest.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - */ - -namespace Piwik\Tests\Integration\ArchiveProcessor; - -use Piwik\ArchiveProcessor\ArchivingStatus; -use Piwik\ArchiveProcessor\Parameters; -use Piwik\Common; -use Piwik\Container\StaticContainer; -use Piwik\Db; -use Piwik\Period\Factory; -use Piwik\Segment; -use Piwik\Site; -use Piwik\Tests\Framework\Fixture; -use Piwik\Tests\Framework\TestCase\IntegrationTestCase; - -class ArchivingStatusTest extends IntegrationTestCase -{ - public function setUp(): void - { - parent::setUp(); - - Fixture::createWebsite('2010-02-03 00:00:00'); - Fixture::createWebsite('2010-02-03 00:00:00'); - } - - public function test_archiveStartedAndArchiveFinished_workflow() - { - /** @var ArchivingStatus $archivingStatus */ - $archivingStatus = StaticContainer::get(ArchivingStatus::class); - - $params = new Parameters(new Site(1), Factory::build('month', '2012-02-04'), new Segment('', [1])); - $archivingStatus->archiveStarted($params); - - $lock = $archivingStatus->getCurrentArchivingLock(); - $this->assertNotEmpty($lock); - $this->assertTrue($lock->isLocked()); - - $this->assertEquals([ - [ - 'key' => 'Archiving.1.368dfa07fd4c27385c87c819538ef078', - 'expiry_time' => time() + ArchivingStatus::DEFAULT_ARCHIVING_TTL, - ], - ], $this->getLockKeysAndTtls()); - - $archivingStatus->archiveFinished(); - - $this->assertEquals([], $this->getLockKeysAndTtls()); - } - - public function test_getSitesCurrentlyArchiving_returnsAllSitesArchiving() - { - /** @var ArchivingStatus $archivingStatus */ - $archivingStatus = StaticContainer::get(ArchivingStatus::class); - - $params = new Parameters(new Site(1), Factory::build('month', '2012-02-04'), new Segment('', [1])); - $archivingStatus->archiveStarted($params); - - $params = new Parameters(new Site(1), Factory::build('month', '2012-02-04'), new Segment('browserCode==ff', [1])); - $archivingStatus->archiveStarted($params); - - $params = new Parameters(new Site(2), Factory::build('month', '2012-02-04'), new Segment('', [1])); - $archivingStatus->archiveStarted($params); - - $this->assertEquals([ - 1, 2, - ], $archivingStatus->getSitesCurrentlyArchiving()); - - $archivingStatus->archiveFinished(); - $archivingStatus->archiveFinished(); - - $this->assertEquals([ - 1, - ], $archivingStatus->getSitesCurrentlyArchiving()); - } - - private function getLockKeysAndTtls() - { - return Db::fetchAll("SELECT `key`, expiry_time FROM `" . Common::prefixTable('locks') . '`'); - } -}
\ No newline at end of file diff --git a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php index 0dc721661f..f2da035ae7 100644 --- a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php +++ b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php @@ -161,6 +161,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), array ( 'idarchive' => '1', @@ -172,6 +174,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), array ( 'idarchive' => '1', @@ -183,6 +187,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -196,6 +202,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE;dimension1==val', + 'ts_started' => null, + 'status' => '0', ), array ( 'idarchive' => '1', @@ -207,6 +215,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE;dimension1==val', + 'ts_started' => null, + 'status' => '0', ), array ( 'idarchive' => '1', @@ -218,6 +228,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => 'testReport', 'plugin' => 'Actions', 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -231,6 +243,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE;dimension1==val', + 'ts_started' => null, + 'status' => '0', ), array ( 'idarchive' => '1', @@ -242,6 +256,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -255,6 +271,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE;dimension1==val', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -268,6 +286,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -281,6 +301,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => 'testReport', 'plugin' => 'Actions', 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -294,6 +316,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE;dimension1==val', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -307,6 +331,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -320,6 +346,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => 'testReport', 'plugin' => 'Actions', 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -333,6 +361,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE;dimension1==val', + 'ts_started' => null, + 'status' => '0', ), ), array ( // end of idsite=1 @@ -348,6 +378,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => 'testReport', 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), ), array ( // end of idsite=2 @@ -455,6 +487,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => '', + 'ts_started' => null, + 'status' => '0', ), array ( 'idarchive' => '1', @@ -466,6 +500,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE', + 'ts_started' => null, + 'status' => '0', ), ), array ( @@ -480,6 +516,8 @@ class QueueConsumerTest extends IntegrationTestCase 'report' => NULL, 'plugin' => NULL, 'segment' => 'browserCode==IE', + 'ts_started' => null, + 'status' => '0', ), ), array (// end of idsite=1 diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php index afb3a1b086..079727eca6 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php @@ -8,11 +8,9 @@ namespace Piwik\Tests\Integration\DataAccess; -use Piwik\ArchiveProcessor\ArchivingStatus; use Piwik\ArchiveProcessor\Rules; use Piwik\Common; use Piwik\Config; -use Piwik\Container\StaticContainer; use Piwik\CronArchive\ReArchiveList; use Piwik\DataAccess\ArchiveTableCreator; use Piwik\DataAccess\ArchiveWriter; @@ -21,7 +19,6 @@ use Piwik\Date; use Piwik\Db; use Piwik\Option; use Piwik\Piwik; -use Piwik\Plugins\CoreAdminHome\Tasks\ArchivesToPurgeDistributedList; use Piwik\Plugins\PrivacyManager\PrivacyManager; use Piwik\Plugins\SegmentEditor\API; use Piwik\Tests\Framework\Fixture; @@ -81,7 +78,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase { parent::setUp(); - $this->invalidator = new ArchiveInvalidator(new Model(), StaticContainer::get(ArchivingStatus::class), new NullLogger()); + $this->invalidator = new ArchiveInvalidator(new Model(), new NullLogger()); } public function test_markArchivesAsInvalidated_doesNotInvalidatePartialArchives() diff --git a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php index 1929352479..aedb995fa8 100644 --- a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php @@ -8,19 +8,15 @@ namespace Piwik\Tests\Integration\DataAccess; -use Piwik\ArchiveProcessor\ArchivingStatus; use Piwik\ArchiveProcessor\Parameters; use Piwik\Config; use Piwik\Common; -use Piwik\Container\StaticContainer; use Piwik\DataAccess\LogAggregator; use Piwik\Date; -use Piwik\Db; use Piwik\Period; use Piwik\Segment; use Piwik\Site; use Piwik\Tests\Fixtures\OneVisitorTwoVisits; -use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; use Piwik\Updater\Migration\Db as DbMigration; @@ -291,40 +287,6 @@ class LogAggregatorTest extends IntegrationTestCase ]; $this->assertEquals($expected, $result); } - - public function test_logAggregatorUpdatesArchiveStatusExpireTime() - { - $t = Fixture::getTracker(self::$fixture->idSite, '2010-03-06 14:22:33'); - $t->setUrl('http://example.com/here/we/go'); - $t->doTrackPageView('here we go'); - - Date::$now = strtotime('2015-03-04 00:08:04'); - - $params = new Parameters(new Site(self::$fixture->idSite), Period\Factory::build('day', self::$fixture->dateTime), new Segment('', [self::$fixture->idSite])); - $archiveStatus = StaticContainer::get(ArchivingStatus::class); - $archiveStatus->archiveStarted($params); - - $locks = $this->getAllLocks(); - $this->assertCount(1, $locks); - $expireTime = $locks[0]['expiry_time']; - - sleep(1); - - Date::$now = strtotime('2015-03-04 10:08:04'); - - $this->logAggregator->queryVisitsByDimension(['visit_total_time']); - - $locks = $this->getAllLocks(); - $this->assertCount(1, $locks); - $expireTimeNew = $locks[0]['expiry_time']; - - $this->assertGreaterThan($expireTime, $expireTimeNew); - } - - private function getAllLocks() - { - return Db::fetchAll("SELECT `key`, expiry_time FROM `" . Common::prefixTable('locks') . '`'); - } } LogAggregatorTest::$fixture = new OneVisitorTwoVisits(); diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php index 5d01db8250..e713f8b4e1 100644 --- a/tests/PHPUnit/Integration/DataAccess/ModelTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php @@ -380,6 +380,8 @@ class ModelTest extends IntegrationTestCase 'period' => '5', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '12', @@ -390,6 +392,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '13', @@ -400,6 +404,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done764644a7142bdcbedaab92f9dedef5e5', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '19', @@ -410,6 +416,8 @@ class ModelTest extends IntegrationTestCase 'period' => '2', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '5', @@ -420,6 +428,8 @@ class ModelTest extends IntegrationTestCase 'period' => '2', 'name' => 'done764644a7142bdcbedaab92f9dedef5e5', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '15', @@ -430,6 +440,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '8', @@ -440,6 +452,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '14', @@ -450,6 +464,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '20', @@ -460,6 +476,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '3', @@ -470,6 +488,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done67564f109e3f4bba6b185a5343ff2bb0', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '2', @@ -480,6 +500,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '10', @@ -490,6 +512,8 @@ class ModelTest extends IntegrationTestCase 'period' => '3', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '17', @@ -500,6 +524,8 @@ class ModelTest extends IntegrationTestCase 'period' => '3', 'name' => 'done67564f109e3f4bba6b185a5343ff2bb0', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '22', @@ -510,6 +536,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '7', @@ -520,6 +548,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '1', @@ -530,6 +560,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done0bb102ea2ac682a578480dd184736607', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '16', @@ -540,6 +572,8 @@ class ModelTest extends IntegrationTestCase 'period' => '2', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '6', @@ -550,6 +584,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '9', @@ -560,6 +596,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'doneb321434abb5a139c17dadf08c9d2e315', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '18', @@ -570,6 +608,8 @@ class ModelTest extends IntegrationTestCase 'period' => '1', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '21', @@ -580,6 +620,8 @@ class ModelTest extends IntegrationTestCase 'period' => '3', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), array ( 'idinvalidation' => '4', @@ -590,6 +632,8 @@ class ModelTest extends IntegrationTestCase 'period' => '4', 'name' => 'done', 'report' => null, + 'ts_started' => null, + 'status' => 0, ), ); |