|
21 | 21 | use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil; |
22 | 22 | use Yandex\Allure\Adapter\AllureException; |
23 | 23 | use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport; |
24 | | -use Symfony\Component\Process\Process; |
25 | 24 | use Yandex\Allure\Adapter\Support\AttachmentSupport; |
26 | 25 | use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; |
27 | 26 | use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; |
@@ -522,13 +521,35 @@ public function scrollToTopOfPage() |
522 | 521 | */ |
523 | 522 | public function magentoCLI($command, $timeout = null, $arguments = null) |
524 | 523 | { |
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; |
532 | 553 | } |
533 | 554 |
|
534 | 555 | /** |
@@ -837,76 +858,6 @@ public function makeScreenshot($name = null) |
837 | 858 | AllureHelper::addAttachmentToCurrentStep($screenName, 'Screenshot'); |
838 | 859 | } |
839 | 860 |
|
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 | | - |
910 | 861 | /** |
911 | 862 | * Create an entity |
912 | 863 | * TODO: move this function to MagentoActionProxies after MQE-1904 |
|
0 commit comments