$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." );
- }
}
/**
throw new JobQueueError( 'No queue partitions available.' );
}
}
-
- public function setTestingPrefix( $key ) {
- /** @var JobQueue $queue */
- foreach ( $this->partitionQueues as $queue ) {
- $queue->setTestingPrefix( $key );
- }
- }
}
*/
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." );
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 );
}
}
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?
$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"
);
}