/**
  * @test
  */
 public function doBenchmark()
 {
     $dataset = $this->benchmarkRunner->getDefaultDataset();
     $datasetFixture = Title::newFromText('Lorem ipsum');
     $this->benchmarkRunner->addMessage("\n" . '==========================================================================================');
     $this->benchmarkRunner->addMessage('JobQueue benchmarks');
     $this->benchmarkRunner->addMessage('------------------------------------------------------------------------------------------');
     $this->benchmarkRunner->addMessage("- Dataset: " . $dataset);
     $this->benchmarkRunner->addMessage("- MediaWiki: " . $this->benchmarkRunner->getMediaWikiVersion());
     $this->benchmarkRunner->addMessage("- Store: " . $this->benchmarkRunner->getQueryEngine());
     $this->benchmarkRunner->addMessage("- ShowMemoryUsage: " . var_export($this->showMemoryUsage, true));
     $this->benchmarkRunner->addMessage("- ReuseDatasets: " . var_export($this->reuseDatasets, true));
     $this->benchmarkRunner->addMessage("- PageCopyThreshold: " . $this->pageCopyThreshold);
     $this->benchmarkRunner->addMessage("- RepetitionExecutionThreshold: " . $this->repetitionExecutionThreshold);
     $this->benchmarkRunner->addMessage('------------------------------------------------------------------------------------------');
     if (!$this->reuseDatasets) {
         $this->benchmarkRunner->addMessage("\n" . 'Data preparation benchmarks');
         $this->benchmarkRunner->doImportDataset($dataset);
         $this->benchmarkRunner->copyPageContent($datasetFixture, $this->pageCopyThreshold);
     }
     $this->assertTrue($datasetFixture->exists());
     $refreshJob = new RefreshJob(Title::newFromText(__METHOD__));
     $refreshJob->insert();
     $this->createJobQueueBenchmarks('SMW\\RefreshJob');
     $this->createJobQueueBenchmarks('SMW\\UpdateJob');
     $this->benchmarkRunner->addMessage('==========================================================================================');
     $this->benchmarkRunner->printMessages();
 }
Example #2
0
 /**
  * @dataProvider parameterDataProvider
  */
 public function testRunJobOnMockStore($parameters, $expected)
 {
     $title = Title::newFromText(__METHOD__);
     $expectedToRun = $expected['spos'] === null ? $this->never() : $this->once();
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->setMethods(array('refreshData'))->getMockForAbstractClass();
     $store->expects($expectedToRun)->method('refreshData')->will($this->returnCallback(array($this, 'refreshDataCallback')));
     $this->applicationFactory->registerObject('Store', $store);
     $instance = new RefreshJob($title, $parameters);
     $instance->setJobQueueEnabledState(false);
     $this->assertTrue($instance->run());
     $this->assertEquals($expected['progress'], $instance->getProgress(), "Asserts that the getProgress() returns {$expected['progress']}");
     $this->assertEquals($expected['spos'], $this->controlRefreshDataIndex, "Asserts that the refreshData() received a spos {$expected['spos']}");
     unset($this->controlRefreshDataIndex);
 }
 /**
  * @dataProvider parameterDataProvider
  */
 public function testRunJobOnMockStore($parameters, $expected)
 {
     $title = Title::newFromText(__METHOD__);
     $expectedToRun = $expected['spos'] === null ? $this->once() : $this->once();
     $byIdDataRebuildDispatcher = $this->getMockBuilder('\\SMW\\SQLStore\\ByIdDataRebuildDispatcher')->disableOriginalConstructor()->getMock();
     $byIdDataRebuildDispatcher->expects($this->any())->method('dispatchRebuildFor')->will($this->returnValue($parameters['spos']));
     $store = $this->getMockBuilder('\\SMW\\Store')->setMethods(array('refreshData'))->getMockForAbstractClass();
     $store->expects($expectedToRun)->method('refreshData')->will($this->returnValue($byIdDataRebuildDispatcher));
     $this->applicationFactory->registerObject('Store', $store);
     $instance = new RefreshJob($title, $parameters);
     $instance->setJobQueueEnabledState(false);
     $this->assertTrue($instance->run());
     $this->assertEquals($expected['progress'], $instance->getProgress(), "Asserts that the getProgress() returns {$expected['progress']}");
 }
 protected function doRefreshStore($refreshjob)
 {
     if ($GLOBALS['smwgAdminRefreshStore']) {
         $sure = $GLOBALS['wgRequest']->getText('rfsure');
         $title = SpecialPage::getTitleFor('SMWAdmin');
         if ($sure == 'yes') {
             if (is_null($refreshjob)) {
                 // careful, there might be race conditions here
                 $newjob = new RefreshJob($title, array('spos' => 1, 'prog' => 0, 'rc' => 2));
                 $newjob->insert();
                 // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength.MaxExceeded
                 $this->getOutput()->addHTML('<p>' . wfMessage('smw_smwadmin_updatestarted', '<a href="' . htmlspecialchars($title->getFullURL()) . '">Special:SMWAdmin</a>')->text() . '</p>');
                 // @codingStandardsIgnoreEnd
             } else {
                 // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength.MaxExceeded
                 $this->getOutput()->addHTML('<p>' . wfMessage('smw_smwadmin_updatenotstarted', '<a href="' . htmlspecialchars($title->getFullURL()) . '">Special:SMWAdmin</a>')->text() . '</p>');
                 // @codingStandardsIgnoreEnd
             }
         } elseif ($sure == 'stop') {
             // FIXME See above comments !!
             $dbw = wfGetDB(DB_MASTER);
             // delete (all) existing iteration jobs
             $dbw->delete('job', array('job_cmd' => 'SMW\\RefreshJob'), __METHOD__);
             // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength.MaxExceeded
             $this->getOutput()->addHTML('<p>' . wfMessage('smw_smwadmin_updatestopped', '<a href="' . htmlspecialchars($title->getFullURL()) . '">Special:SMWAdmin</a>')->text() . '</p>');
             // @codingStandardsIgnoreEnd
         } else {
             // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength.MaxExceeded
             $this->getOutput()->addHTML('<p>' . wfMessage('smw_smwadmin_updatenotstopped', '<a href="' . htmlspecialchars($title->getFullURL()) . '">Special:SMWAdmin</a>')->text() . '</p>');
             // @codingStandardsIgnoreEnd
         }
     }
 }