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(); }
public function testOnScenarioFailure() { $scenario = new Magento_Performance_Scenario('Scenario with Error', 'scenario_error.jmx', array(), array(), array()); $scenarioOneFailure = $this->throwException(new Magento_Performance_Scenario_FailureException($scenario)); $this->_expectScenarioWarmUp('Scenario with Error', 'scenario_error.jmx', 0, $scenarioOneFailure); $this->_expectScenarioRun('Scenario with Error', 'scenario_error.jmx', 1, $scenarioOneFailure); /* Warm up is disabled for scenario */ $scenario = new Magento_Performance_Scenario('Scenario with Failure', 'scenario_failure.jmx', array(), array(), array()); $scenarioTwoFailure = $this->throwException(new Magento_Performance_Scenario_FailureException($scenario)); $this->_expectScenarioRun('Scenario with Failure', 'scenario_failure.jmx', 2, $scenarioTwoFailure); $scenario = new Magento_Performance_Scenario('Scenario', 'scenario.jmx', array(), array(), array()); $scenarioThreeFailure = $this->throwException(new Magento_Performance_Scenario_FailureException($scenario)); $this->_expectScenarioWarmUp('Scenario', 'scenario.jmx', 3); $this->_expectScenarioRun('Scenario', 'scenario.jmx', 4, $scenarioThreeFailure); $notifications = array(); $this->_object->onScenarioFailure(function (Magento_Performance_Scenario_FailureException $actualFailure) use(&$notifications) { $notifications[] = $actualFailure->getScenario()->getFile(); }); $this->_object->run(); $this->assertEquals(array('scenario_error.jmx', 'scenario_failure.jmx', 'scenario.jmx'), $notifications); }
* versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package performance_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** @var $bootstrap Magento_Performance_Config */ $config = (require_once __DIR__ . '/framework/bootstrap.php'); $shell = new Magento_Shell(true); $scenarioHandler = new Magento_Performance_Scenario_Handler_Statistics(new Magento_Performance_Scenario_Handler_Aggregate(array(new Magento_Performance_Scenario_Handler_Jmeter($shell), new Magento_Performance_Scenario_Handler_Php($shell)))); $scenarioTotalCount = count($config->getScenarios()); $scenarioCount = 1; $scenarioHandler->onScenarioFirstRun(function ($scenarioFile) use(&$scenarioCount, $scenarioTotalCount) { echo "Scenario {$scenarioCount} of {$scenarioTotalCount}: '{$scenarioFile}'" . PHP_EOL; $scenarioCount++; }); $scenarioHandler->onScenarioFailure(function ($scenarioFile, Magento_Performance_Scenario_FailureException $failure) { echo "Scenario '{$scenarioFile}' has failed!" . PHP_EOL . $failure->getMessage() . PHP_EOL . PHP_EOL; }); $testsuite = new Magento_Performance_Testsuite($config, new Magento_Application($config, $shell), $scenarioHandler); $testsuite->run(); $scenarioFailures = $scenarioHandler->getFailures(); if ($scenarioFailures) { $scenarioFailCount = count($scenarioFailures); echo "Failed {$scenarioFailCount} of {$scenarioTotalCount} scenario(s)" . PHP_EOL; exit(1); } else { echo 'Successful' . PHP_EOL; }