From: Aaron Schulz Date: Fri, 11 Dec 2015 01:13:48 +0000 (-0800) Subject: Remove JobQueue::setTestingPrefix() hack X-Git-Tag: 1.31.0-rc.0~8734 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=ec351986e5a235cf4d5a4ed944b18774265bbcc4;p=lhc%2Fweb%2Fwiklou.git Remove JobQueue::setTestingPrefix() hack The tests are only run on dev install and only touch the null queue anyway. Change-Id: I441a2a4605a9e2984142485b022dd524ff819360 --- diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php index 69a3defbc1..89948f46ba 100644 --- a/includes/jobqueue/JobQueue.php +++ b/includes/jobqueue/JobQueue.php @@ -688,17 +688,6 @@ abstract class JobQueue { $stats->updateCount( "jobqueue.{$key}.all", $delta ); $stats->updateCount( "jobqueue.{$key}.{$type}", $delta ); } - - /** - * Namespace the queue with a key to isolate it for testing - * - * @param string $key - * @return void - * @throws MWException - */ - public function setTestingPrefix( $key ) { - throw new MWException( "Queue namespacing not supported for this queue type." ); - } } /** diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php index 109ca01992..07f2c93bdf 100644 --- a/includes/jobqueue/JobQueueFederated.php +++ b/includes/jobqueue/JobQueueFederated.php @@ -497,11 +497,4 @@ class JobQueueFederated extends JobQueue { throw new JobQueueError( 'No queue partitions available.' ); } } - - public function setTestingPrefix( $key ) { - /** @var JobQueue $queue */ - foreach ( $this->partitionQueues as $queue ) { - $queue->setTestingPrefix( $key ); - } - } } diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php index b1efa5b2fd..3e7bdcc588 100644 --- a/includes/jobqueue/JobQueueRedis.php +++ b/includes/jobqueue/JobQueueRedis.php @@ -786,10 +786,6 @@ LUA; */ private function getGlobalKey( $name ) { $parts = array( 'global', 'jobqueue', $name ); - if ( strlen( $this->key ) ) { // namespaced queue (for testing) - $parts[] = $this->key; - } - foreach ( $parts as $part ) { if ( !preg_match( '/[a-zA-Z0-9_-]+/', $part ) ) { throw new InvalidArgumentException( "Key part characters are out of range." ); @@ -807,18 +803,7 @@ LUA; private function getQueueKey( $prop, $type = null ) { $type = is_string( $type ) ? $type : $this->type; list( $db, $prefix ) = wfSplitWikiID( $this->wiki ); - if ( strlen( $this->key ) ) { // namespaced queue (for testing) - return wfForeignMemcKey( $db, $prefix, 'jobqueue', $type, $this->key, $prop ); - } else { - return wfForeignMemcKey( $db, $prefix, 'jobqueue', $type, $prop ); - } - } - /** - * @param string $key - * @return void - */ - public function setTestingPrefix( $key ) { - $this->key = $key; + return wfForeignMemcKey( $db, $prefix, 'jobqueue', $type, $prop ); } } diff --git a/tests/phpunit/includes/jobqueue/JobQueueTest.php b/tests/phpunit/includes/jobqueue/JobQueueTest.php index bb74e95aa2..47277d9676 100644 --- a/tests/phpunit/includes/jobqueue/JobQueueTest.php +++ b/tests/phpunit/includes/jobqueue/JobQueueTest.php @@ -41,9 +41,6 @@ class JobQueueTest extends MediaWikiTestCase { foreach ( $variants as $q => $settings ) { try { $this->$q = JobQueue::factory( $settings + $baseConfig ); - if ( !( $this->$q instanceof JobQueueDB ) ) { - $this->$q->setTestingPrefix( 'unittests-' . wfRandomString( 32 ) ); - } } catch ( MWException $e ) { // unsupported? // @todo What if it was another error? @@ -341,13 +338,18 @@ class JobQueueTest extends MediaWikiTestCase { $this->markTestSkipped(); } - $this->assertArrayEquals( array(), $queue->getServerQueuesWithJobs() ); + $this->assertNotContains( + array( $queue->getType(), $queue->getWiki() ), + $queue->getServerQueuesWithJobs(), + "Null queue not in listing" + ); $queue->push( $this->newJob( 0 ) ); - $this->assertArrayEquals( - array( array( $queue->getType(), $queue->getWiki() ) ), - $queue->getServerQueuesWithJobs() + $this->assertContains( + array( $queue->getType(), $queue->getWiki() ), + $queue->getServerQueuesWithJobs(), + "Null queue in listing" ); }