diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-01-08 11:05:41 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2020-01-08 11:05:41 +0300 |
commit | 3c2b5f714f85457796e3e190781d3e592822ebf7 (patch) | |
tree | 5e7049fd0bac597481bfe70f972602af5c0220b9 /tests/PHPUnit | |
parent | 18b0815a78d158b45afbd752c7e21581321acb4c (diff) |
Do not proceed with archiving if a valid archive exists for the parameter combination. (#14937)
* Do not proceed with archiving if a valid archive exists for the parameter combination.
* test manually and get to work
* Apply some review feedback.
* apply more review feedback
* Do not abort archiving if archive found for non-day period so segments will still archive.
* Apply more review feedback.
* Make new optimization aware of whole periods.
* update submodule
* In CronArchive modify lastN date parameter to use oldest invalidated archive.
* Move date changing logic to method and unit test.
* Fix test.
Diffstat (limited to 'tests/PHPUnit')
-rw-r--r-- | tests/PHPUnit/Integration/CronArchiveTest.php | 14 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/Archiver/RequestTest.php | 47 |
2 files changed, 54 insertions, 7 deletions
diff --git a/tests/PHPUnit/Integration/CronArchiveTest.php b/tests/PHPUnit/Integration/CronArchiveTest.php index 4f4f2f9588..74f0dc561b 100644 --- a/tests/PHPUnit/Integration/CronArchiveTest.php +++ b/tests/PHPUnit/Integration/CronArchiveTest.php @@ -151,22 +151,22 @@ Starting Matomo reports archiving... Will pre-process for website id = 1, period = day, date = last%s - pre-processing all visits - skipping segment archiving for 'actions>=4'. -- pre-processing segment 1/1 actions>=2 +- pre-processing segment 1/1 actions>=2 [date = last52] Archived website id = 1, period = day, 1 segments, 1 visits in last %s days, 1 visits today, Time elapsed: %s +- skipping segment archiving for 'actions>=4'. Will pre-process for website id = 1, period = week, date = last%s - pre-processing all visits -- skipping segment archiving for 'actions>=4'. -- pre-processing segment 1/1 actions>=2 +- pre-processing segment 1/1 actions>=2 [date = last260] Archived website id = 1, period = week, 1 segments, 1 visits in last %s weeks, 1 visits this week, Time elapsed: %s +- skipping segment archiving for 'actions>=4'. Will pre-process for website id = 1, period = month, date = last%s - pre-processing all visits -- skipping segment archiving for 'actions>=4'. -- pre-processing segment 1/1 actions>=2 +- pre-processing segment 1/1 actions>=2 [date = last52] Archived website id = 1, period = month, 1 segments, 1 visits in last %s months, 1 visits this month, Time elapsed: %s +- skipping segment archiving for 'actions>=4'. Will pre-process for website id = 1, period = year, date = last%s - pre-processing all visits -- skipping segment archiving for 'actions>=4'. -- pre-processing segment 1/1 actions>=2 +- pre-processing segment 1/1 actions>=2 [date = last7] Archived website id = 1, period = year, 1 segments, 1 visits in last %s years, 1 visits this year, Time elapsed: %s Archived website id = 1, %s API requests, Time elapsed: %s [1/1 done] Done archiving! diff --git a/tests/PHPUnit/Unit/Archiver/RequestTest.php b/tests/PHPUnit/Unit/Archiver/RequestTest.php new file mode 100644 index 0000000000..ae168023c2 --- /dev/null +++ b/tests/PHPUnit/Unit/Archiver/RequestTest.php @@ -0,0 +1,47 @@ +<?php +/** + * Piwik - 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\Unit\Archiver; + + +use Piwik\Archiver\Request; + +class RequestTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTestDataForChangeDate + */ + public function test_changeDate_replacesDateProperly($url, $newDate, $expectedNewUrl) + { + $request = new Request($url); + $request->changeDate($newDate); + $this->assertEquals($expectedNewUrl, $request->getUrl()); + } + + public function getTestDataForChangeDate() + { + return [ + [ + 'http://abc.com/index.php?trigger=archivephp&method=API.get&date=2012-03-04', + 'last12', + 'http://abc.com/index.php?trigger=archivephp&method=API.get&date=last12', + ], + [ + 'http://abc.com/index.php?trigger=archivephp&method=API.get&date=2012-03-04,2013-02-4&period=day', + 'previous18', + 'http://abc.com/index.php?trigger=archivephp&method=API.get&date=previous18&period=day', + ], + [ + 'http://abc.com/index.php?date=lastN&period=day', + '2013-10-12,2013-11-19', + 'http://abc.com/index.php?date=2013-10-12,2013-11-19&period=day', + ], + ]; + } +}
\ No newline at end of file |