protected function execute(InputInterface $input, OutputInterface $output)
{
$testSuite = $this->getTestSuite($input);
$arguments = $input->getArgument('arguments');
$patchFile = $this->getPatchFile($input);
$launchOnly = $input->getOption('launch-only');
$updateOnly = $input->getOption('update-only');
$gitHash = $input->getOption('checkout');
$perTestsuite = $input->getOption('one-instance-per-testsuite');
if (empty($testSuite) && empty($launchOnly) && empty($updateOnly)) {
throw new \InvalidArgumentException('Either provide a testsuite argument or define <comment>--launch-only</comment> or <comment>--update-only</comment>');
}
$awsConfig = new Config();
$awsConfig->validate();
$host = $this->launchInstance($output, $perTestsuite, $awsConfig, $testSuite);
if ($launchOnly) {
return 0;
}
$ssh = Ssh::connectToAws($host, $awsConfig->getPemFile());
$ssh->setOutput($output);
$testRunner = new Remote($ssh);
$testRunner->updatePiwik($gitHash);
$testRunner->replaceConfigIni(PIWIK_INCLUDE_PATH . '/plugins/TestRunner/Aws/config.ini.php');
if (!empty($patchFile)) {
$testRunner->applyPatch($patchFile);
}
if ($updateOnly) {
$ssh->disconnect();
return 0;
}
$testRunner->runTests($host, $testSuite, $arguments);
$message = $this->buildFinishedMessage($testSuite, $host);
$output->writeln("\n{$message}\n");
$ssh->disconnect();
}