Remove JobQueue::setTestingPrefix() hack
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 11 Dec 2015 01:13:48 +0000 (17:13 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 11 Dec 2015 01:20:10 +0000 (17:20 -0800)
The tests are only run on dev install and only touch the
null queue anyway.

Change-Id: I441a2a4605a9e2984142485b022dd524ff819360

includes/jobqueue/JobQueue.php
includes/jobqueue/JobQueueFederated.php
includes/jobqueue/JobQueueRedis.php
tests/phpunit/includes/jobqueue/JobQueueTest.php

index 69a3def..89948f4 100644 (file)
@@ -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." );
-       }
 }
 
 /**
index 109ca01..07f2c93 100644 (file)
@@ -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 );
-               }
-       }
 }
index b1efa5b..3e7bdcc 100644 (file)
@@ -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 );
        }
 }
index bb74e95..47277d9 100644 (file)
@@ -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"
                );
        }