Skip to content

Commit f5dfd24

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MQE-1379
# Conflicts: # src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php
2 parents 01f0847 + 580d6dc commit f5dfd24

File tree

1 file changed

+29
-78
lines changed

1 file changed

+29
-78
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 29 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil;
2222
use Yandex\Allure\Adapter\AllureException;
2323
use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport;
24-
use Symfony\Component\Process\Process;
2524
use Yandex\Allure\Adapter\Support\AttachmentSupport;
2625
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
2726
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
@@ -522,13 +521,35 @@ public function scrollToTopOfPage()
522521
*/
523522
public function magentoCLI($command, $timeout = null, $arguments = null)
524523
{
525-
return $this->curlExecMagentoCLI($command, $timeout, $arguments);
526-
//TODO: calling bin/magento from pipeline is timing out, needs investigation (ref: MQE-1774)
527-
// try {
528-
// return $this->shellExecMagentoCLI($command, $arguments);
529-
// } catch (\Exception $exception) {
530-
// return $this->curlExecMagentoCLI($command, $arguments);
531-
// }
524+
// Remove index.php if it's present in url
525+
$baseUrl = rtrim(
526+
str_replace('index.php', '', rtrim($this->config['url'], '/')),
527+
'/'
528+
);
529+
530+
$apiURL = UrlFormatter::format(
531+
$baseUrl . '/' . ltrim(getenv('MAGENTO_CLI_COMMAND_PATH'), '/'),
532+
false
533+
);
534+
535+
$restExecutor = new WebapiExecutor();
536+
$executor = new CurlTransport();
537+
$executor->write(
538+
$apiURL,
539+
[
540+
'token' => $restExecutor->getAuthToken(),
541+
getenv('MAGENTO_CLI_COMMAND_PARAMETER') => $command,
542+
'arguments' => $arguments,
543+
'timeout' => $timeout,
544+
],
545+
CurlInterface::POST,
546+
[]
547+
);
548+
$response = $executor->read();
549+
$restExecutor->close();
550+
$executor->close();
551+
552+
return $response;
532553
}
533554

534555
/**
@@ -837,76 +858,6 @@ public function makeScreenshot($name = null)
837858
AllureHelper::addAttachmentToCurrentStep($screenName, 'Screenshot');
838859
}
839860

840-
/**
841-
* Takes given $command and executes it against bin/magento executable. Returns stdout output from the command.
842-
*
843-
* @param string $command
844-
* @param integer $timeout
845-
* @param string $arguments
846-
*
847-
* @throws \RuntimeException
848-
* @return string
849-
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
850-
*/
851-
private function shellExecMagentoCLI($command, $timeout, $arguments): string
852-
{
853-
$php = PHP_BINDIR ? PHP_BINDIR . DIRECTORY_SEPARATOR. 'php' : 'php';
854-
$binMagento = realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento');
855-
$command = $php . ' -f ' . $binMagento . ' ' . $command . ' ' . $arguments;
856-
$process = new Process(escapeshellcmd($command), MAGENTO_BP);
857-
$process->setIdleTimeout($timeout);
858-
$process->setTimeout(0);
859-
$exitCode = $process->run();
860-
if ($exitCode !== 0) {
861-
throw new \RuntimeException($process->getErrorOutput());
862-
}
863-
864-
return $process->getOutput();
865-
}
866-
867-
/**
868-
* Takes given $command and executes it against exposed MTF CLI entry point. Returns response from server.
869-
*
870-
* @param string $command
871-
* @param integer $timeout
872-
* @param string $arguments
873-
*
874-
* @return string
875-
* @throws TestFrameworkException
876-
*/
877-
private function curlExecMagentoCLI($command, $timeout, $arguments): string
878-
{
879-
// Remove index.php if it's present in url
880-
$baseUrl = rtrim(
881-
str_replace('index.php', '', rtrim($this->config['url'], '/')),
882-
'/'
883-
);
884-
885-
$apiURL = UrlFormatter::format(
886-
$baseUrl . '/' . ltrim(getenv('MAGENTO_CLI_COMMAND_PATH'), '/'),
887-
false
888-
);
889-
890-
$restExecutor = new WebapiExecutor();
891-
$executor = new CurlTransport();
892-
$executor->write(
893-
$apiURL,
894-
[
895-
'token' => $restExecutor->getAuthToken(),
896-
getenv('MAGENTO_CLI_COMMAND_PARAMETER') => $command,
897-
'arguments' => $arguments,
898-
'timeout' => $timeout,
899-
],
900-
CurlInterface::POST,
901-
[]
902-
);
903-
$response = $executor->read();
904-
$restExecutor->close();
905-
$executor->close();
906-
907-
return $response;
908-
}
909-
910861
/**
911862
* Create an entity
912863
* TODO: move this function to MagentoActionProxies after MQE-1904

0 commit comments

Comments
 (0)