From 97f3b3ed6095d78f3d44300aa20807601b87a386 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Thu, 21 Nov 2019 16:54:01 -0600 Subject: [PATCH 1/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out. --- etc/config/command.php | 3 ++- .../Module/MagentoWebDriver.php | 25 +++++++++++-------- .../Test/etc/Actions/customActions.xsd | 7 ++++++ .../Util/TestGenerator.php | 9 +++++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/etc/config/command.php b/etc/config/command.php index adc372e43..b348bd3e5 100644 --- a/etc/config/command.php +++ b/etc/config/command.php @@ -14,6 +14,7 @@ $tokenPassedIn = urldecode($_POST['token'] ?? ''); $command = urldecode($_POST['command'] ?? ''); $arguments = urldecode($_POST['arguments'] ?? ''); + $timeout = urldecode($_POST['timeout'] ?? 60); // Token returned will be null if the token we passed in is invalid $tokenFromMagento = $tokenModel->loadByToken($tokenPassedIn)->getToken(); @@ -24,7 +25,7 @@ if ($valid) { $fullCommand = escapeshellcmd($magentoBinary . " $command" . " $arguments"); $process = new Symfony\Component\Process\Process($fullCommand); - $process->setIdleTimeout(60); + $process->setIdleTimeout($timeout); $process->setTimeout(0); $idleTimeout = false; try { diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index c1ab892d7..de8feaae2 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -510,14 +510,16 @@ public function scrollToTopOfPage() /** * Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output. * - * @param string $command - * @param string $arguments + * @param string $command + * @param string $arguments + * @param integer $timeout * @return string + * * @throws TestFrameworkException */ - public function magentoCLI($command, $arguments = null) + public function magentoCLI($command, $arguments = null, $timeout = null) { - return $this->curlExecMagentoCLI($command, $arguments); + return $this->curlExecMagentoCLI($command, $arguments, $timeout); //TODO: calling bin/magento from pipeline is timing out, needs investigation (ref: MQE-1774) // try { // return $this->shellExecMagentoCLI($command, $arguments); @@ -673,16 +675,17 @@ public function fillSecretField($field, $value) * * @param string $command * @param null $arguments + * @param int $timeout * @throws TestFrameworkException * @return string */ - public function magentoCLISecret($command, $arguments = null) + public function magentoCLISecret($command, $timeout, $arguments = null) { // to protect any secrets from being printed to console the values are executed only at the webdriver level as a // decrypted value $decryptedCommand = CredentialStore::getInstance()->decryptAllSecretsInString($command); - return $this->magentoCLI($decryptedCommand, $arguments); + return $this->magentoCLI($decryptedCommand, $timeout, $arguments); } /** @@ -860,12 +863,13 @@ private function shellExecMagentoCLI($command, $arguments): string /** * Takes given $command and executes it against exposed MTF CLI entry point. Returns response from server. * - * @param string $command - * @param string $arguments - * @return string + * @param string $command + * @param string $arguments + * @param integer $timeout + * * @throws TestFrameworkException */ - private function curlExecMagentoCLI($command, $arguments): string + private function curlExecMagentoCLI($command, $arguments, $timeout): string { // Remove index.php if it's present in url $baseUrl = rtrim( @@ -882,6 +886,7 @@ private function curlExecMagentoCLI($command, $arguments): string 'token' => $restExecutor->getAuthToken(), getenv('MAGENTO_CLI_COMMAND_PARAMETER') => $command, 'arguments' => $arguments, + 'timeout' => $timeout, ], CurlInterface::POST, [] diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd index 3a002e126..2424d0d31 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd @@ -50,6 +50,13 @@ + + + + Idle timeout in seconds, defaulted to 60s when not specified. + + + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index ce45af963..be9d26c96 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -42,6 +42,7 @@ class TestGenerator const HOOK_SCOPE = 'hook'; const SUITE_SCOPE = 'suite'; const PRESSKEY_ARRAY_ANCHOR_KEY = '987654321098765432109876543210'; + const COMMAND_WAIT_TIMEOUT = 60; const PERSISTED_OBJECT_NOTATION_REGEX = '/\${1,2}[\w.\[\]]+\${1,2}/'; const NO_STEPKEY_ACTIONS = [ 'comment', @@ -532,6 +533,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $sortOrder = null; $storeCode = null; $format = null; + $commandTimeout = null; $assertExpected = null; $assertActual = null; @@ -609,10 +611,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $time = $customActionAttributes['time']; } if (isset($customActionAttributes['timeout'])) { - $time = $customActionAttributes['timeout']; + $commandTimeout = $customActionAttributes['timeout']; } $time = $time ?? ActionObject::getDefaultWaitTimeout(); + $commandTimeout = $commandTimeout ?? self::COMMAND_WAIT_TIMEOUT; + if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') { // validate the param array is in the correct format $this->validateParameterArray($customActionAttributes['parameterArray']); @@ -1280,7 +1284,8 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $actor, $actionObject, $command, - $arguments + $arguments, + $commandTimeout ); $testSteps .= sprintf(self::STEP_KEY_ANNOTATION, $stepKey) . PHP_EOL; $testSteps .= sprintf( From 16e1f03ec072c6734f37e2338ceb450fa28fbb63 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 22 Nov 2019 13:45:05 -0600 Subject: [PATCH 2/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out --- .../Resources/BasicFunctionalTest.txt | 2 +- .../Resources/DataReplacementTest.txt | 2 +- .../Module/MagentoWebDriver.php | 24 ++++++++++--------- .../Test/Objects/ActionObject.php | 2 ++ .../Util/TestGenerator.php | 12 ++++++---- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index f82c84119..c5dc13e2e 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -126,7 +126,7 @@ class BasicFunctionalTestCest $grabMultipleKey1 = $I->grabMultiple(".functionalTestSelector"); // stepKey: grabMultipleKey1 $grabTextFromKey1 = $I->grabTextFrom(".functionalTestSelector"); // stepKey: grabTextFromKey1 $grabValueFromKey1 = $I->grabValueFrom(".functionalTestSelector"); // stepKey: grabValueFromKey1 - $magentoCli1 = $I->magentoCLI("maintenance:enable", "\"stuffHere\""); // stepKey: magentoCli1 + $magentoCli1 = $I->magentoCLI("maintenance:enable", "\"stuffHere\"", 60); // stepKey: magentoCli1 $I->comment($magentoCli1); $I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1 $I->maximizeWindow(); // stepKey: maximizeWindowKey1 diff --git a/dev/tests/verification/Resources/DataReplacementTest.txt b/dev/tests/verification/Resources/DataReplacementTest.txt index 731ae63f8..4b4531a4e 100644 --- a/dev/tests/verification/Resources/DataReplacementTest.txt +++ b/dev/tests/verification/Resources/DataReplacementTest.txt @@ -52,7 +52,7 @@ class DataReplacementTestCest $I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]); // stepKey: parameterArrayReplacementMSQBoth $I->selectMultipleOptions("#Doe" . msq("uniqueData"), "#element", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]); // stepKey: multiSelectDataReplacement $I->fillField(".selector", "0"); // stepKey: insertZero - $insertCommand = $I->magentoCLI("do something Doe" . msq("uniqueData") . " with uniqueness"); // stepKey: insertCommand + $insertCommand = $I->magentoCLI("do something Doe" . msq("uniqueData") . " with uniqueness", 60); // stepKey: insertCommand $I->comment($insertCommand); $I->seeInPageSource("StringBefore John StringAfter"); // stepKey: htmlReplace1 $I->seeInPageSource("#John"); // stepKey: htmlReplace2 diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index de8feaae2..3602ddfb4 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -519,7 +519,7 @@ public function scrollToTopOfPage() */ public function magentoCLI($command, $arguments = null, $timeout = null) { - return $this->curlExecMagentoCLI($command, $arguments, $timeout); + return $this->curlExecMagentoCLI($command, $arguments, $timeout); //TODO: calling bin/magento from pipeline is timing out, needs investigation (ref: MQE-1774) // try { // return $this->shellExecMagentoCLI($command, $arguments); @@ -673,19 +673,19 @@ public function fillSecretField($field, $value) * Function used to create data that contains sensitive credentials in a override. * The data is decrypted immediately prior to data creation to avoid exposure in console or log. * - * @param string $command - * @param null $arguments - * @param int $timeout + * @param string $command + * @param null $arguments + * @param null $timeout * @throws TestFrameworkException * @return string */ - public function magentoCLISecret($command, $timeout, $arguments = null) + public function magentoCLISecret($command, $arguments = null, $timeout = null) { // to protect any secrets from being printed to console the values are executed only at the webdriver level as a // decrypted value $decryptedCommand = CredentialStore::getInstance()->decryptAllSecretsInString($command); - return $this->magentoCLI($decryptedCommand, $timeout, $arguments); + return $this->magentoCLI($decryptedCommand, $arguments, $timeout); } /** @@ -837,20 +837,21 @@ public function makeScreenshot($name = null) /** * Takes given $command and executes it against bin/magento executable. Returns stdout output from the command. * - * @param string $command - * @param string $arguments + * @param string $command + * @param string $arguments + * @param integer $timeout * * @throws \RuntimeException * @return string * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - private function shellExecMagentoCLI($command, $arguments): string + private function shellExecMagentoCLI($command, $arguments, $timeout): string { $php = PHP_BINDIR ? PHP_BINDIR . DIRECTORY_SEPARATOR. 'php' : 'php'; $binMagento = realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento'); $command = $php . ' -f ' . $binMagento . ' ' . $command . ' ' . $arguments; $process = new Process(escapeshellcmd($command), MAGENTO_BP); - $process->setIdleTimeout(60); + $process->setIdleTimeout($timeout); $process->setTimeout(0); $exitCode = $process->run(); if ($exitCode !== 0) { @@ -867,9 +868,10 @@ private function shellExecMagentoCLI($command, $arguments): string * @param string $arguments * @param integer $timeout * + * @return string * @throws TestFrameworkException */ - private function curlExecMagentoCLI($command, $arguments, $timeout): string + private function curlExecMagentoCLI($command, $arguments, $timeout): string { // Remove index.php if it's present in url $baseUrl = rtrim( diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 9b1cdf1af..0434ca22d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -63,6 +63,7 @@ class ActionObject const DELETE_DATA_MUTUAL_EXCLUSIVE_ATTRIBUTES = ["url", "createDataKey"]; const EXTERNAL_URL_AREA_INVALID_ACTIONS = ['amOnPage']; const FUNCTION_CLOSURE_ACTIONS = ['waitForElementChange', 'performOn', 'executeInSelenium']; + const COMMAND_ACTION_ATTRIBUTES = ['magentoCLI', 'magentoCLISecret']; const MERGE_ACTION_ORDER_AFTER = 'after'; const MERGE_ACTION_ORDER_BEFORE = 'before'; const ACTION_ATTRIBUTE_TIMEZONE = 'timezone'; @@ -72,6 +73,7 @@ class ActionObject const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\((?(?!}}).)+\)}})/'; const STRING_PARAMETER_REGEX = "/'[^']+'/"; const DEFAULT_WAIT_TIMEOUT = 10; + const DEFAULT_COMMAND_WAIT_TIMEOUT = 60; const ACTION_ATTRIBUTE_USERINPUT = 'userInput'; const ACTION_TYPE_COMMENT = 'comment'; diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index be9d26c96..766f65b60 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -42,7 +42,6 @@ class TestGenerator const HOOK_SCOPE = 'hook'; const SUITE_SCOPE = 'suite'; const PRESSKEY_ARRAY_ANCHOR_KEY = '987654321098765432109876543210'; - const COMMAND_WAIT_TIMEOUT = 60; const PERSISTED_OBJECT_NOTATION_REGEX = '/\${1,2}[\w.\[\]]+\${1,2}/'; const NO_STEPKEY_ACTIONS = [ 'comment', @@ -611,11 +610,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $time = $customActionAttributes['time']; } if (isset($customActionAttributes['timeout'])) { - $commandTimeout = $customActionAttributes['timeout']; + $time = $customActionAttributes['timeout']; } - $time = $time ?? ActionObject::getDefaultWaitTimeout(); - $commandTimeout = $commandTimeout ?? self::COMMAND_WAIT_TIMEOUT; + if (in_array($actionObject->getType(), ActionObject::COMMAND_ACTION_ATTRIBUTES)) { + $time = $time ?? ActionObject::DEFAULT_COMMAND_WAIT_TIMEOUT; + } else { + $time = $time ?? ActionObject::getDefaultWaitTimeout(); + } if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') { // validate the param array is in the correct format @@ -1285,7 +1287,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $actionObject, $command, $arguments, - $commandTimeout + $time ); $testSteps .= sprintf(self::STEP_KEY_ANNOTATION, $stepKey) . PHP_EOL; $testSteps .= sprintf( From fceb17f52104dadb3e38a562a8c8730a9b2bd023 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 22 Nov 2019 14:46:57 -0600 Subject: [PATCH 3/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out fixed static checks + unit tests, added documentation. --- .../Resources/ActionGroupWithStepKeyReferences.txt | 2 +- docs/test/actions.md | 1 + .../FunctionalTestingFramework/Module/MagentoWebDriver.php | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index eddaaf784..2bb414230 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -45,7 +45,7 @@ class ActionGroupWithStepKeyReferencesCest $I->fillField($action1); // stepKey: action1ActionGroup $I->comment("Invocation stepKey will be appended in non stepKey instances"); $action3ActionGroup = $I->executeJS($action3ActionGroup); // stepKey: action3ActionGroup - $action4ActionGroup = $I->magentoCLI($action4ActionGroup, "\"stuffHere\""); // stepKey: action4ActionGroup + $action4ActionGroup = $I->magentoCLI($action4ActionGroup, "\"stuffHere\"", 60); // stepKey: action4ActionGroup $I->comment($action4ActionGroup); $date = new \DateTime(); $date->setTimestamp(strtotime("{$action5}")); diff --git a/docs/test/actions.md b/docs/test/actions.md index 9b125d7fc..c5dc83fdb 100644 --- a/docs/test/actions.md +++ b/docs/test/actions.md @@ -1262,6 +1262,7 @@ Attribute|Type|Use|Description ---|---|---|--- `command`|string |optional| CLI command to be executed in Magento environment. `arguments`|string |optional| Unescaped arguments to be passed in with the CLI command. +`timeout`|string|optional| Number of seconds CLI command can run without outputting anything. `stepKey`|string|required| A unique identifier of the action. `before`|string|optional| `stepKey` of action that must be executed next. `after`|string|optional| `stepKey` of preceding action. diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 3602ddfb4..2d09e7f2a 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -673,9 +673,9 @@ public function fillSecretField($field, $value) * Function used to create data that contains sensitive credentials in a override. * The data is decrypted immediately prior to data creation to avoid exposure in console or log. * - * @param string $command - * @param null $arguments - * @param null $timeout + * @param string $command + * @param null $arguments + * @param null $timeout * @throws TestFrameworkException * @return string */ From 2e1887e1b92bdd9333767541488449e4d15f285d Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 22 Nov 2019 16:08:52 -0600 Subject: [PATCH 4/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out --- etc/config/command.php | 2 +- src/Magento/FunctionalTestingFramework/Util/TestGenerator.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/etc/config/command.php b/etc/config/command.php index b348bd3e5..e3b8f1191 100644 --- a/etc/config/command.php +++ b/etc/config/command.php @@ -14,7 +14,7 @@ $tokenPassedIn = urldecode($_POST['token'] ?? ''); $command = urldecode($_POST['command'] ?? ''); $arguments = urldecode($_POST['arguments'] ?? ''); - $timeout = urldecode($_POST['timeout'] ?? 60); + $timeout = floatval(urldecode($_POST['timeout'] ?? 60)); // Token returned will be null if the token we passed in is invalid $tokenFromMagento = $tokenModel->loadByToken($tokenPassedIn)->getToken(); diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 766f65b60..a566e95f6 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -532,7 +532,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $sortOrder = null; $storeCode = null; $format = null; - $commandTimeout = null; $assertExpected = null; $assertActual = null; From d4faf137dbefe25850deea423a1c23cd803f57a1 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 25 Nov 2019 15:07:05 -0600 Subject: [PATCH 5/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out fixed issue with signature of magentoCLI --- .../ActionGroupWithStepKeyReferences.txt | 2 +- .../Resources/BasicFunctionalTest.txt | 4 +++- .../TestModule/Test/BasicFunctionalTest.xml | 1 + .../Module/MagentoWebDriver.php | 18 +++++++++--------- .../Util/TestGenerator.php | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index 2bb414230..d1cae1da4 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -45,7 +45,7 @@ class ActionGroupWithStepKeyReferencesCest $I->fillField($action1); // stepKey: action1ActionGroup $I->comment("Invocation stepKey will be appended in non stepKey instances"); $action3ActionGroup = $I->executeJS($action3ActionGroup); // stepKey: action3ActionGroup - $action4ActionGroup = $I->magentoCLI($action4ActionGroup, "\"stuffHere\"", 60); // stepKey: action4ActionGroup + $action4ActionGroup = $I->magentoCLI($action4ActionGroup, 60, "\"stuffHere\""); // stepKey: action4ActionGroup $I->comment($action4ActionGroup); $date = new \DateTime(); $date->setTimestamp(strtotime("{$action5}")); diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index c5dc13e2e..2bae80f80 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -126,8 +126,10 @@ class BasicFunctionalTestCest $grabMultipleKey1 = $I->grabMultiple(".functionalTestSelector"); // stepKey: grabMultipleKey1 $grabTextFromKey1 = $I->grabTextFrom(".functionalTestSelector"); // stepKey: grabTextFromKey1 $grabValueFromKey1 = $I->grabValueFrom(".functionalTestSelector"); // stepKey: grabValueFromKey1 - $magentoCli1 = $I->magentoCLI("maintenance:enable", "\"stuffHere\"", 60); // stepKey: magentoCli1 + $magentoCli1 = $I->magentoCLI("maintenance:enable", 60, "\"stuffHere\""); // stepKey: magentoCli1 $I->comment($magentoCli1); + $magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2 + $I->comment($magentoCli2); $I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1 $I->maximizeWindow(); // stepKey: maximizeWindowKey1 $I->moveBack(); // stepKey: moveBackKey1 diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml index ff0708554..09fedd1b8 100644 --- a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml @@ -76,6 +76,7 @@ + diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 2d09e7f2a..87e3b0c08 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -511,15 +511,15 @@ public function scrollToTopOfPage() * Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output. * * @param string $command - * @param string $arguments * @param integer $timeout + * @param string $arguments * @return string * * @throws TestFrameworkException */ - public function magentoCLI($command, $arguments = null, $timeout = null) + public function magentoCLI($command, $timeout = null, $arguments = null) { - return $this->curlExecMagentoCLI($command, $arguments, $timeout); + return $this->curlExecMagentoCLI($command, $timeout, $arguments); //TODO: calling bin/magento from pipeline is timing out, needs investigation (ref: MQE-1774) // try { // return $this->shellExecMagentoCLI($command, $arguments); @@ -674,18 +674,18 @@ public function fillSecretField($field, $value) * The data is decrypted immediately prior to data creation to avoid exposure in console or log. * * @param string $command - * @param null $arguments * @param null $timeout + * @param null $arguments * @throws TestFrameworkException * @return string */ - public function magentoCLISecret($command, $arguments = null, $timeout = null) + public function magentoCLISecret($command, $timeout = null, $arguments = null) { // to protect any secrets from being printed to console the values are executed only at the webdriver level as a // decrypted value $decryptedCommand = CredentialStore::getInstance()->decryptAllSecretsInString($command); - return $this->magentoCLI($decryptedCommand, $arguments, $timeout); + return $this->magentoCLI($decryptedCommand, $timeout, $arguments); } /** @@ -845,7 +845,7 @@ public function makeScreenshot($name = null) * @return string * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - private function shellExecMagentoCLI($command, $arguments, $timeout): string + private function shellExecMagentoCLI($command, $arguments, $timeout = 60): string { $php = PHP_BINDIR ? PHP_BINDIR . DIRECTORY_SEPARATOR. 'php' : 'php'; $binMagento = realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento'); @@ -865,13 +865,13 @@ private function shellExecMagentoCLI($command, $arguments, $timeout): string * Takes given $command and executes it against exposed MTF CLI entry point. Returns response from server. * * @param string $command - * @param string $arguments * @param integer $timeout + * @param string $arguments * * @return string * @throws TestFrameworkException */ - private function curlExecMagentoCLI($command, $arguments, $timeout): string + private function curlExecMagentoCLI($command, $timeout, $arguments): string { // Remove index.php if it's present in url $baseUrl = rtrim( diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index a566e95f6..a73054b08 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1285,8 +1285,8 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $actor, $actionObject, $command, - $arguments, - $time + $time, + $arguments ); $testSteps .= sprintf(self::STEP_KEY_ANNOTATION, $stepKey) . PHP_EOL; $testSteps .= sprintf( From 67472f582a3d386e2c47c6a17cb107edbf07d360 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 25 Nov 2019 15:23:52 -0600 Subject: [PATCH 6/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out fixed issue with signature of magentoCLI --- .../FunctionalTestingFramework/Module/MagentoWebDriver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 87e3b0c08..66d103b0c 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -838,14 +838,14 @@ public function makeScreenshot($name = null) * Takes given $command and executes it against bin/magento executable. Returns stdout output from the command. * * @param string $command - * @param string $arguments * @param integer $timeout + * @param string $arguments * * @throws \RuntimeException * @return string * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - private function shellExecMagentoCLI($command, $arguments, $timeout = 60): string + private function shellExecMagentoCLI($command, $timeout, $arguments): string { $php = PHP_BINDIR ? PHP_BINDIR . DIRECTORY_SEPARATOR. 'php' : 'php'; $binMagento = realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento'); From 0f7bd4a3d63a7c80cdd4d80c6d326d0918698144 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Tue, 26 Nov 2019 10:34:47 -0600 Subject: [PATCH 7/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out Added verification test for magentoCLISecret. --- dev/tests/verification/Resources/BasicFunctionalTest.txt | 4 ++++ .../verification/TestModule/Test/BasicFunctionalTest.xml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index 2bae80f80..bc7fe0b94 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -130,6 +130,10 @@ class BasicFunctionalTestCest $I->comment($magentoCli1); $magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2 $I->comment($magentoCli2); + $magentoCli3 = $I->magentoCLISecret("config:set somePath " . CredentialStore::getInstance()->getSecret("someKey"), 60); // stepKey: magentoCli3 + $I->comment($magentoCli3); // stepKey: magentoCli3 + $magentoCli4 = $I->magentoCLISecret("config:set somePath " . CredentialStore::getInstance()->getSecret("someKey"), 120); // stepKey: magentoCli4 + $I->comment($magentoCli4); // stepKey: magentoCli4 $I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1 $I->maximizeWindow(); // stepKey: maximizeWindowKey1 $I->moveBack(); // stepKey: moveBackKey1 diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml index 09fedd1b8..c23a3ce60 100644 --- a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml @@ -77,6 +77,8 @@ + + From f6a7763225ab6df1b331f00b8c33f82459c5dd08 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Tue, 26 Nov 2019 10:42:59 -0600 Subject: [PATCH 8/8] MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out Resolved conflicts in ActionObject. --- .../FunctionalTestingFramework/Test/Objects/ActionObject.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index eb5bfd5ce..ad5ca0c33 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -72,7 +72,6 @@ class ActionObject const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/'; const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\((?(?!}}).)+\)}})/'; const STRING_PARAMETER_REGEX = "/'[^']+'/"; - const DEFAULT_WAIT_TIMEOUT = 10; const DEFAULT_COMMAND_WAIT_TIMEOUT = 60; const ACTION_ATTRIBUTE_USERINPUT = 'userInput'; const ACTION_TYPE_COMMENT = 'comment';