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
diff options
context:
space:
mode:
authorBen Burgess <88810029+bx80@users.noreply.github.com>2022-02-02 02:19:23 +0300
committerGitHub <noreply@github.com>2022-02-02 02:19:23 +0300
commitf20c4cbed3de7f3fcc49810d5721b257d5a56d43 (patch)
treeda362660970e784654bf9f5ec1d4a55755ed1322 /tests/PHPUnit/Unit
parentcbb297de4aed974716dd03acfee8832565ebf133 (diff)
Retry scheduled tasks on failure (#18335)
* Catch and log errors for scheduled tasks * Added retry on exception mechanism for scheduled tasks * Replace error code with custom exception * Fix/workaround for SchedulerTest mock breaking retry list option loading * Log warning instead of info if a task has failed three times * Added basic tests, minor code improvements * Test fix * Fix for test * Added integration test to check that only tasks that throw exceptions are scheduled for retry
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r--tests/PHPUnit/Unit/Scheduler/TimetableTest.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/Scheduler/TimetableTest.php b/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
index 1518d1f833..2d930b0d06 100644
--- a/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
@@ -81,6 +81,21 @@ class TimetableTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(Date::factory('tomorrow')->getTimeStamp(), $timetable->getTimetable()[$task->getName()]);
}
+ public function testRescheduleTaskAndRunInOneHour()
+ {
+ self::stubPiwikOption(serialize([]));
+
+ $timetable = new Timetable();
+ $task = $this->getMockBuilder(Task::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $task->method('getName')->willReturn('taskName');
+
+ $timetable->rescheduleTaskAndRunInOneHour($task);
+
+ $this->assertEquals(Date::factory('now')->addHour(1)->getTimeStamp(), $timetable->getTimetable()[$task->getName()]);
+ }
+
/**
* Dataprovider for testTaskHasBeenScheduledOnce
*/