diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-04-22 10:49:55 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-04-22 14:11:26 +0200 |
commit | 3e1dc647376c998f5e7752e8e7b39582144e1398 (patch) | |
tree | 8608b60bed8a3e747dd5b39344324885196a949e /tests | |
parent | 27d6852b3ead63454d3cf0f3c79372af6852f9ac (diff) | |
download | nextcloud-server-3e1dc647376c998f5e7752e8e7b39582144e1398.tar.gz nextcloud-server-3e1dc647376c998f5e7752e8e7b39582144e1398.zip |
Change the sort order of background jobs to be DESC instead of ASC
In theory, if your instance ever creates more jobs then your system cron can
handle, the default background jobs get never executed anymore. Because
everytime when the joblist returns the next job it looks for the next ID,
however there is always a new next ID, so it will never wrap back to execute
the low IDs. But when we change the sort order to be DESC, we make sure that
these low IDs are always executed, before the system jumps back up to
execute the new IDs.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/backgroundjob/joblist.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/lib/backgroundjob/joblist.php b/tests/lib/backgroundjob/joblist.php index c0796d8253a..fcc3c440818 100644 --- a/tests/lib/backgroundjob/joblist.php +++ b/tests/lib/backgroundjob/joblist.php @@ -9,6 +9,7 @@ namespace Test\BackgroundJob; use OCP\BackgroundJob\IJob; +use OCP\IDBConnection; use Test\TestCase; /** @@ -28,10 +29,17 @@ class JobList extends TestCase { parent::setUp(); $connection = \OC::$server->getDatabaseConnection(); + $this->clearJobsList($connection); $this->config = $this->getMock('\OCP\IConfig'); $this->instance = new \OC\BackgroundJob\JobList($connection, $this->config); } + protected function clearJobsList(IDBConnection $connection) { + $query = $connection->getQueryBuilder(); + $query->delete('jobs'); + $query->execute(); + } + protected function getAllSorted() { $jobs = $this->instance->getAll(); @@ -149,11 +157,11 @@ class JobList extends TestCase { $this->config->expects($this->once()) ->method('getAppValue') ->with('backgroundjob', 'lastjob', 0) - ->will($this->returnValue($savedJob1->getId())); + ->will($this->returnValue($savedJob2->getId())); $nextJob = $this->instance->getNext(); - $this->assertEquals($savedJob2, $nextJob); + $this->assertEquals($savedJob1, $nextJob); $this->instance->remove($job, 1); $this->instance->remove($job, 2); @@ -166,16 +174,17 @@ class JobList extends TestCase { $jobs = $this->getAllSorted(); + $savedJob1 = $jobs[count($jobs) - 2]; $savedJob2 = $jobs[count($jobs) - 1]; $this->config->expects($this->once()) ->method('getAppValue') ->with('backgroundjob', 'lastjob', 0) - ->will($this->returnValue($savedJob2->getId())); + ->will($this->returnValue($savedJob1->getId())); $nextJob = $this->instance->getNext(); - $this->assertEquals($jobs[0], $nextJob); + $this->assertEquals($savedJob2, $nextJob); $this->instance->remove($job, 1); $this->instance->remove($job, 2); |