Remove JobQueue::setTestingPrefix() hack
The tests are only run on dev install and only touch the null queue anyway. Change-Id: I441a2a4605a9e2984142485b022dd524ff819360
This commit is contained in:
parent
afb86872c0
commit
ec351986e5
4 changed files with 10 additions and 41 deletions
|
|
@ -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." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue