/** * Run scenario and optionally write results to report file * * @param Magento_Performance_Scenario $scenario * @param string|null $reportFile Report file to write results to, NULL disables report creation * @throws Magento_Exception */ public function run(Magento_Performance_Scenario $scenario, $reportFile = null) { $scenarioExtension = pathinfo($scenario->getFile(), PATHINFO_EXTENSION); /** @var $scenarioHandler Magento_Performance_Scenario_HandlerInterface */ $scenarioHandler = $this->getHandler($scenarioExtension); if (!$scenarioHandler) { throw new Magento_Exception("Unable to run scenario '{$scenario->getTitle()}', format is not supported."); } $scenarioHandler->run($scenario, $reportFile); }
/** * Returns unique report file for the scenario. * Used in order to generate unique report file paths for different scenarios that are represented by same files. * * @param Magento_Performance_Scenario $scenario * @return string */ protected function _getScenarioReportFile(Magento_Performance_Scenario $scenario) { $basePath = $this->_config->getReportDir() . DIRECTORY_SEPARATOR . pathinfo($scenario->getFile(), PATHINFO_FILENAME); $iteration = 1; do { $suffix = $iteration == 1 ? '' : '_' . $iteration; $reportFile = $basePath . $suffix . '.jtl'; $iteration++; } while (isset($this->_reportFiles[$reportFile])); $this->_reportFiles[$reportFile] = true; return $reportFile; }
/** * Build and return scenario execution command and arguments for it, compatible with the getopt() "long options" * @link http://www.php.net/getopt * * @param Magento_Performance_Scenario $scenario * @return array */ protected function _buildScenarioCmd(Magento_Performance_Scenario $scenario) { $command = 'php -f %s --'; $arguments = array($scenario->getFile()); foreach ($scenario->getArguments() as $paramName => $paramValue) { $command .= " --{$paramName} %s"; $arguments[] = $paramValue; } return array($command, $arguments); }
public function testGetFile() { $this->assertEquals('test/file.jmx', $this->_object->getFile()); }
/** * Build and return scenario execution command and arguments for it * * @param Magento_Performance_Scenario $scenario * @param string|null $reportFile * @return array */ protected function _buildScenarioCmd(Magento_Performance_Scenario $scenario, $reportFile = null) { $command = 'jmeter -n -t %s'; $arguments = array($scenario->getFile()); if ($reportFile) { $command .= ' -l %s'; $arguments[] = $reportFile; } foreach ($scenario->getArguments() as $key => $value) { $command .= ' %s'; $arguments[] = "-J{$key}={$value}"; } return array($command, $arguments); }