Exemplo n.º 1
0
 /**
  * Run entire test suite of scenarios
  */
 public function run()
 {
     $this->_reportFiles = array();
     $scenarios = $this->_getOptimizedScenarioList();
     foreach ($scenarios as $scenario) {
         /** @var $scenario Magento_Performance_Scenario */
         $this->_application->applyFixtures($scenario->getFixtures());
         $this->_notifyScenarioRun($scenario);
         /* warm up cache, if any */
         $settings = $scenario->getSettings();
         if (empty($settings[self::SETTING_SKIP_WARM_UP])) {
             try {
                 $scenarioWarmUp = new Magento_Performance_Scenario($scenario->getTitle(), $scenario->getFile(), $this->_warmUpArguments + $scenario->getArguments(), $scenario->getSettings(), $scenario->getFixtures());
                 $this->_scenarioHandler->run($scenarioWarmUp);
             } catch (Magento_Performance_Scenario_FailureException $scenarioFailure) {
                 // do not notify about failed warm up
             }
         }
         /* full run with reports recording */
         $reportFile = $this->_getScenarioReportFile($scenario);
         try {
             $this->_scenarioHandler->run($scenario, $reportFile);
         } catch (Magento_Performance_Scenario_FailureException $scenarioFailure) {
             $this->_notifyScenarioFailure($scenarioFailure);
         }
     }
 }
Exemplo n.º 2
0
 public function testRunException()
 {
     $expectedScenario = $this->_fixtureDir . DIRECTORY_SEPARATOR . 'scenario_error.jmx';
     $this->setExpectedException('Magento_Exception', "Unable to run scenario '{$expectedScenario}', format is not supported.");
     $this->_handler->expects($this->atLeastOnce())->method('run')->will($this->returnValue(false));
     $this->_object->run();
 }
Exemplo n.º 3
0
 /**
  * Run scenario and optionally write results to report file
  *
  * @param string $scenarioFile
  * @param Magento_Performance_Scenario_Arguments $scenarioArguments
  * @param string|null $reportFile Report file to write results to, NULL disables report creation
  * @return bool Whether handler was able to process scenario
  */
 public function run($scenarioFile, Magento_Performance_Scenario_Arguments $scenarioArguments, $reportFile = null)
 {
     if (!array_key_exists($scenarioFile, $this->_executedScenarios)) {
         $this->_notifyScenarioFirstRun($scenarioFile);
     }
     try {
         $result = $this->_handler->run($scenarioFile, $scenarioArguments, $reportFile);
         if ($result) {
             $this->_recordScenarioResult($scenarioFile, self::RESULT_SUCCESS);
         }
         return $result;
     } catch (Magento_Performance_Scenario_FailureException $scenarioFailure) {
         $this->_recordScenarioResult($scenarioFile, $scenarioFailure);
         $this->_notifyScenarioFailure($scenarioFile, $scenarioFailure);
         return true;
     }
 }
Exemplo n.º 4
0
 public function testRunStopOnSuccess()
 {
     $callSequence = new ArrayObject();
     $this->_handleOne->expects($this->once())->method('run')->will($this->returnCallback($this->_createCallRecorder($callSequence, 'handleOne', false)));
     $this->_handleTwo->expects($this->once())->method('run')->will($this->returnCallback($this->_createCallRecorder($callSequence, 'handleTwo', true)));
     $this->_handleThree->expects($this->never())->method('run');
     $this->assertTrue($this->_object->run('scenario.jmx', new Magento_Performance_Scenario_Arguments(array())));
     $this->assertEquals(array('handleOne', 'handleTwo'), (array) $callSequence);
 }
Exemplo n.º 5
0
 public function testOnScenarioRun()
 {
     $this->_handler->expects($this->any())->method('run');
     $notifications = array();
     $this->_object->onScenarioRun(function ($scenario) use(&$notifications) {
         $notifications[] = $scenario->getFile();
     });
     $this->_object->run();
     $this->assertEquals(array($this->_fixtureDir . DIRECTORY_SEPARATOR . 'scenario_error.jmx', $this->_fixtureDir . DIRECTORY_SEPARATOR . 'scenario_failure.jmx', $this->_fixtureDir . DIRECTORY_SEPARATOR . 'scenario.jmx'), $notifications);
 }
Exemplo n.º 6
0
 /**
  * Run entire test suite of scenarios
  *
  * @throws Magento_Exception
  */
 public function run()
 {
     $scenarios = $this->_getOptimizedScenarioList();
     foreach ($scenarios as $scenarioFile) {
         $scenarioArguments = $this->_config->getScenarioArguments($scenarioFile);
         $scenarioSettings = $this->_config->getScenarioSettings($scenarioFile);
         $scenarioFixtures = $this->_config->getScenarioFixtures($scenarioFile);
         $this->_application->applyFixtures($scenarioFixtures);
         /* warm up cache, if any */
         if (empty($scenarioSettings[self::SETTING_SKIP_WARM_UP])) {
             $warmUpArgs = new Magento_Performance_Scenario_Arguments($this->_warmUpArguments + (array) $scenarioArguments);
             $this->_scenarioHandler->run($scenarioFile, $warmUpArgs);
         }
         /* full run with reports recording */
         $scenarioName = preg_replace('/\\..+?$/', '', basename($scenarioFile));
         $reportFile = $this->_config->getReportDir() . DIRECTORY_SEPARATOR . $scenarioName . '.jtl';
         if (!$this->_scenarioHandler->run($scenarioFile, $scenarioArguments, $reportFile)) {
             throw new Magento_Exception("Unable to run scenario '{$scenarioFile}', format is not supported.");
         }
     }
 }
Exemplo n.º 7
0
 public function testOnScenarioFailure()
 {
     $failure = new Magento_Performance_Scenario_FailureException();
     $this->_handler->expects($this->any())->method('run')->will($this->throwException($failure));
     $notifications = array();
     $this->_object->onScenarioFailure(function ($scenarioFile, $actualFailure) use(&$notifications, $failure) {
         PHPUnit_Framework_Assert::assertSame($failure, $actualFailure);
         $notifications[] = $scenarioFile;
     });
     $this->_object->run('scenario.jmx', $this->_scenarioArgs);
     $this->assertEquals(array('scenario.jmx'), $notifications);
     $this->_object->run('scenario.jmx', $this->_scenarioArgs);
     $this->assertEquals(array('scenario.jmx', 'scenario.jmx'), $notifications);
 }
Exemplo n.º 8
0
 public function testRunDelegation()
 {
     $reportFile = 'scenario.jtl';
     $this->_handler->expects($this->once())->method('run')->with($this->_scenario, $reportFile);
     $this->_object->run($this->_scenario, $reportFile);
 }