Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2020-12-08 05:04:04 +0300
committerGitHub <noreply@github.com>2020-12-08 05:04:04 +0300
commit85e665e70d9fd38acda2c70767d25b800dc97a45 (patch)
treeba9ed780e5fc834cb926aab0ab9b8c58348fb462 /tests
parenteedca2e2b753f46eac6dbd7a19c8ba7b4c031cb2 (diff)
Only invalidate in past for segments that belong to the site … (#16896)
* Only invalidate in past for segments that belong to the site and only process an invalidation if it is for a site + we can load the segment * apply pr fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php32
-rw-r--r--tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php30
2 files changed, 45 insertions, 17 deletions
diff --git a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php
index 677498b18e..7e2dedc857 100644
--- a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php
+++ b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php
@@ -12,6 +12,7 @@ namespace Piwik\Tests\Integration\CronArchive;
use Piwik\ArchiveProcessor\Rules;
use Piwik\CliMulti\RequestParser;
use Piwik\Common;
+use Piwik\Plugins\CustomDimensions;
use Piwik\Container\StaticContainer;
use Piwik\CronArchive;
use Piwik\CronArchive\FixedSiteIds;
@@ -38,8 +39,10 @@ class QueueConsumerTest extends IntegrationTestCase
Fixture::createWebsite('2020-04-06');
Fixture::createWebsite('2010-04-06');
+ CustomDimensions\API::getInstance()->configureNewCustomDimension(1, 'custom 1', 'visit', true);
+
Rules::setBrowserTriggerArchiving(false);
- API::getInstance()->add('testegment', 'browserCode==IE', false, true);
+ API::getInstance()->add('testegment', 'browserCode==IE;dimension1==val', 1, true);
API::getInstance()->add('testegment2', 'browserCode==ff', false);
Rules::setBrowserTriggerArchiving(true);
@@ -66,7 +69,7 @@ class QueueConsumerTest extends IntegrationTestCase
$archiveFilter
);
- $segmentHash = (new Segment('browserCode==IE', [1]))->getHash();
+ $segmentHash = (new Segment('browserCode==IE;dimension1==val', [1]))->getHash();
$segmentHash2 = (new Segment('browserCode==ff', [1]))->getHash();
$invalidations = [
@@ -92,6 +95,7 @@ class QueueConsumerTest extends IntegrationTestCase
['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null],
['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null],
['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null],
+ ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 2, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null],
['idarchive' => 1, 'name' => 'done' . $segmentHash2, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null],
// invalid plugin
@@ -177,10 +181,10 @@ class QueueConsumerTest extends IntegrationTestCase
'date1' => '2018-03-08',
'date2' => '2018-03-08',
'period' => '1',
- 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428',
'report' => NULL,
'plugin' => NULL,
- 'segment' => 'browserCode==IE',
+ 'segment' => 'browserCode==IE;dimension1==val',
),
array (
'idarchive' => '1',
@@ -188,10 +192,10 @@ class QueueConsumerTest extends IntegrationTestCase
'date1' => '2018-03-07',
'date2' => '2018-03-07',
'period' => '1',
- 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428',
'report' => NULL,
'plugin' => NULL,
- 'segment' => 'browserCode==IE',
+ 'segment' => 'browserCode==IE;dimension1==val',
),
array (
'idarchive' => '1',
@@ -212,10 +216,10 @@ class QueueConsumerTest extends IntegrationTestCase
'date1' => '2018-03-06',
'date2' => '2018-03-06',
'period' => '1',
- 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428',
'report' => NULL,
'plugin' => NULL,
- 'segment' => 'browserCode==IE',
+ 'segment' => 'browserCode==IE;dimension1==val',
),
array (
'idarchive' => '1',
@@ -236,10 +240,10 @@ class QueueConsumerTest extends IntegrationTestCase
'date1' => '2018-03-04',
'date2' => '2018-03-04',
'period' => '1',
- 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428',
'report' => NULL,
'plugin' => NULL,
- 'segment' => 'browserCode==IE',
+ 'segment' => 'browserCode==IE;dimension1==val',
),
),
array (
@@ -275,10 +279,10 @@ class QueueConsumerTest extends IntegrationTestCase
'date1' => '2018-03-04',
'date2' => '2018-03-11',
'period' => '2',
- 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428',
'report' => NULL,
'plugin' => NULL,
- 'segment' => 'browserCode==IE',
+ 'segment' => 'browserCode==IE;dimension1==val',
),
),
array (
@@ -314,10 +318,10 @@ class QueueConsumerTest extends IntegrationTestCase
'date1' => '2018-03-01',
'date2' => '2018-03-31',
'period' => '3',
- 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc',
+ 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428',
'report' => NULL,
'plugin' => NULL,
- 'segment' => 'browserCode==IE',
+ 'segment' => 'browserCode==IE;dimension1==val',
),
),
array ( // end of idsite=1
diff --git a/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php b/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php
index 0e579caa90..2eb1790980 100644
--- a/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php
+++ b/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-namespace Piwik\Tests\Unit\CronArchive;
+namespace Piwik\Tests\Integration\CronArchive;
use Piwik\Config;
use Piwik\CronArchive;
@@ -14,6 +14,7 @@ use Piwik\Date;
use Piwik\CronArchive\SegmentArchiving;
use Piwik\Option;
use Piwik\Site;
+use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
/**
@@ -80,6 +81,14 @@ class SegmentArchivingTest extends IntegrationTestCase
),
array(
+ 'ts_created' => '2012-01-01',
+ 'definition' => 'countryCode==br',
+ 'enable_only_idsite' => 2,
+ 'ts_last_edit' => '2011-01-01',
+ 'auto_archive' => 1,
+ ),
+
+ array(
'ts_created' => '2011-01-01',
'definition' => 'countryCode==ca',
'enable_only_idsite' => 0,
@@ -201,6 +210,21 @@ class SegmentArchivingTest extends IntegrationTestCase
],
],
],
+
+ [
+ 'segment_last_edit_time',
+ 2,
+ [
+ [
+ 'date' => '2014-01-01 00:00:00',
+ 'segment' => 'countryCode==ca',
+ ],
+ [
+ 'date' => '2012-01-01 00:00:00',
+ 'segment' => 'countryCode==br',
+ ],
+ ],
+ ],
];
}
@@ -274,10 +298,10 @@ class SegmentArchivingTest extends IntegrationTestCase
$this->assertEquals($expected, $segments);
}
- private function createUrlProviderToTest($processNewSegmentsFrom)
+ private function createUrlProviderToTest($processNewSegmentsFrom, $mockData = null)
{
$mockSegmentEditorModel = $this->createPartialMock('Piwik\Plugins\SegmentEditor\Model', array('getAllSegmentsAndIgnoreVisibility'));
- $mockSegmentEditorModel->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->will($this->returnValue($this->mockSegmentEntries));
+ $mockSegmentEditorModel->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->will($this->returnValue($mockData ?: $this->mockSegmentEntries));
return new SegmentArchiving($processNewSegmentsFrom, $beginningOfTimeLastN = 7, $mockSegmentEditorModel, null, Date::factory(self::TEST_NOW));
}