Example #1
0
 /**
  * Run scenario and optionally write results to report file
  *
  * @param \Magento\TestFramework\Performance\Scenario $scenario
  * @param string|null $reportFile Report file to write results to, NULL disables report creation
  * @throws \Magento\Framework\Exception
  */
 public function run(\Magento\TestFramework\Performance\Scenario $scenario, $reportFile = null)
 {
     $scenarioExtension = pathinfo($scenario->getFile(), PATHINFO_EXTENSION);
     /** @var $scenarioHandler \Magento\TestFramework\Performance\Scenario\HandlerInterface */
     $scenarioHandler = $this->getHandler($scenarioExtension);
     if (!$scenarioHandler) {
         throw new \Magento\Framework\Exception("Unable to run scenario '{$scenario->getTitle()}', format is not supported.");
     }
     $scenarioHandler->run($scenario, $reportFile);
 }
Example #2
0
 /**
  * Build and return scenario execution command and arguments for it
  *
  * @param \Magento\TestFramework\Performance\Scenario $scenario
  * @param string|null $reportFile
  * @return array
  */
 protected function _buildScenarioCmd(\Magento\TestFramework\Performance\Scenario $scenario, $reportFile = null)
 {
     $command = 'jmeter -n -t %s';
     $arguments = [$scenario->getFile()];
     if ($reportFile) {
         $command .= ' -l %s';
         $arguments[] = $reportFile;
     }
     foreach ($scenario->getArguments() as $key => $value) {
         $command .= ' %s';
         $arguments[] = "-J{$key}={$value}";
     }
     return [$command, $arguments];
 }
Example #3
0
 public function testGetFixtures()
 {
     $expectedFixtures = array('fixture1', 'fixture2');
     $this->assertEquals($expectedFixtures, $this->_object->getFixtures());
 }
Example #4
0
 /**
  * Build and return scenario execution command and arguments for it, compatible with the getopt() "long options"
  * @link http://www.php.net/getopt
  *
  * @param \Magento\TestFramework\Performance\Scenario $scenario
  * @return array
  */
 protected function _buildScenarioCmd(\Magento\TestFramework\Performance\Scenario $scenario)
 {
     $command = 'php -f %s --';
     $arguments = [$scenario->getFile()];
     foreach ($scenario->getArguments() as $paramName => $paramValue) {
         $command .= " --{$paramName} %s";
         $arguments[] = $paramValue;
     }
     return [$command, $arguments];
 }
Example #5
0
 /**
  * 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\TestFramework\Performance\Scenario $scenario
  * @return string
  */
 protected function _getScenarioReportFile(\Magento\TestFramework\Performance\Scenario $scenario)
 {
     $basePath = $this->_config->getReportDir() . '/' . 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;
 }