Skip to content

Commit 16e1f03

Browse files
committed
MQE-1711: Switch between Developer mode and Production mode takes long time and the test end up time out
1 parent 97f3b3e commit 16e1f03

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

dev/tests/verification/Resources/BasicFunctionalTest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class BasicFunctionalTestCest
126126
$grabMultipleKey1 = $I->grabMultiple(".functionalTestSelector"); // stepKey: grabMultipleKey1
127127
$grabTextFromKey1 = $I->grabTextFrom(".functionalTestSelector"); // stepKey: grabTextFromKey1
128128
$grabValueFromKey1 = $I->grabValueFrom(".functionalTestSelector"); // stepKey: grabValueFromKey1
129-
$magentoCli1 = $I->magentoCLI("maintenance:enable", "\"stuffHere\""); // stepKey: magentoCli1
129+
$magentoCli1 = $I->magentoCLI("maintenance:enable", "\"stuffHere\"", 60); // stepKey: magentoCli1
130130
$I->comment($magentoCli1);
131131
$I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1
132132
$I->maximizeWindow(); // stepKey: maximizeWindowKey1

dev/tests/verification/Resources/DataReplacementTest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DataReplacementTestCest
5252
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]); // stepKey: parameterArrayReplacementMSQBoth
5353
$I->selectMultipleOptions("#Doe" . msq("uniqueData"), "#element", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]); // stepKey: multiSelectDataReplacement
5454
$I->fillField(".selector", "0"); // stepKey: insertZero
55-
$insertCommand = $I->magentoCLI("do something Doe" . msq("uniqueData") . " with uniqueness"); // stepKey: insertCommand
55+
$insertCommand = $I->magentoCLI("do something Doe" . msq("uniqueData") . " with uniqueness", 60); // stepKey: insertCommand
5656
$I->comment($insertCommand);
5757
$I->seeInPageSource("StringBefore John StringAfter"); // stepKey: htmlReplace1
5858
$I->seeInPageSource("#John"); // stepKey: htmlReplace2

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

+13-11
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public function scrollToTopOfPage()
519519
*/
520520
public function magentoCLI($command, $arguments = null, $timeout = null)
521521
{
522-
return $this->curlExecMagentoCLI($command, $arguments, $timeout);
522+
return $this->curlExecMagentoCLI($command, $arguments, $timeout);
523523
//TODO: calling bin/magento from pipeline is timing out, needs investigation (ref: MQE-1774)
524524
// try {
525525
// return $this->shellExecMagentoCLI($command, $arguments);
@@ -673,19 +673,19 @@ public function fillSecretField($field, $value)
673673
* Function used to create data that contains sensitive credentials in a <createData> <field> override.
674674
* The data is decrypted immediately prior to data creation to avoid exposure in console or log.
675675
*
676-
* @param string $command
677-
* @param null $arguments
678-
* @param int $timeout
676+
* @param string $command
677+
* @param null $arguments
678+
* @param null $timeout
679679
* @throws TestFrameworkException
680680
* @return string
681681
*/
682-
public function magentoCLISecret($command, $timeout, $arguments = null)
682+
public function magentoCLISecret($command, $arguments = null, $timeout = null)
683683
{
684684
// to protect any secrets from being printed to console the values are executed only at the webdriver level as a
685685
// decrypted value
686686

687687
$decryptedCommand = CredentialStore::getInstance()->decryptAllSecretsInString($command);
688-
return $this->magentoCLI($decryptedCommand, $timeout, $arguments);
688+
return $this->magentoCLI($decryptedCommand, $arguments, $timeout);
689689
}
690690

691691
/**
@@ -837,20 +837,21 @@ public function makeScreenshot($name = null)
837837
/**
838838
* Takes given $command and executes it against bin/magento executable. Returns stdout output from the command.
839839
*
840-
* @param string $command
841-
* @param string $arguments
840+
* @param string $command
841+
* @param string $arguments
842+
* @param integer $timeout
842843
*
843844
* @throws \RuntimeException
844845
* @return string
845846
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
846847
*/
847-
private function shellExecMagentoCLI($command, $arguments): string
848+
private function shellExecMagentoCLI($command, $arguments, $timeout): string
848849
{
849850
$php = PHP_BINDIR ? PHP_BINDIR . DIRECTORY_SEPARATOR. 'php' : 'php';
850851
$binMagento = realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento');
851852
$command = $php . ' -f ' . $binMagento . ' ' . $command . ' ' . $arguments;
852853
$process = new Process(escapeshellcmd($command), MAGENTO_BP);
853-
$process->setIdleTimeout(60);
854+
$process->setIdleTimeout($timeout);
854855
$process->setTimeout(0);
855856
$exitCode = $process->run();
856857
if ($exitCode !== 0) {
@@ -867,9 +868,10 @@ private function shellExecMagentoCLI($command, $arguments): string
867868
* @param string $arguments
868869
* @param integer $timeout
869870
*
871+
* @return string
870872
* @throws TestFrameworkException
871873
*/
872-
private function curlExecMagentoCLI($command, $arguments, $timeout): string
874+
private function curlExecMagentoCLI($command, $arguments, $timeout): string
873875
{
874876
// Remove index.php if it's present in url
875877
$baseUrl = rtrim(

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class ActionObject
6363
const DELETE_DATA_MUTUAL_EXCLUSIVE_ATTRIBUTES = ["url", "createDataKey"];
6464
const EXTERNAL_URL_AREA_INVALID_ACTIONS = ['amOnPage'];
6565
const FUNCTION_CLOSURE_ACTIONS = ['waitForElementChange', 'performOn', 'executeInSelenium'];
66+
const COMMAND_ACTION_ATTRIBUTES = ['magentoCLI', 'magentoCLISecret'];
6667
const MERGE_ACTION_ORDER_AFTER = 'after';
6768
const MERGE_ACTION_ORDER_BEFORE = 'before';
6869
const ACTION_ATTRIBUTE_TIMEZONE = 'timezone';
@@ -72,6 +73,7 @@ class ActionObject
7273
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\((?(?!}}).)+\)}})/';
7374
const STRING_PARAMETER_REGEX = "/'[^']+'/";
7475
const DEFAULT_WAIT_TIMEOUT = 10;
76+
const DEFAULT_COMMAND_WAIT_TIMEOUT = 60;
7577
const ACTION_ATTRIBUTE_USERINPUT = 'userInput';
7678
const ACTION_TYPE_COMMENT = 'comment';
7779

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class TestGenerator
4242
const HOOK_SCOPE = 'hook';
4343
const SUITE_SCOPE = 'suite';
4444
const PRESSKEY_ARRAY_ANCHOR_KEY = '987654321098765432109876543210';
45-
const COMMAND_WAIT_TIMEOUT = 60;
4645
const PERSISTED_OBJECT_NOTATION_REGEX = '/\${1,2}[\w.\[\]]+\${1,2}/';
4746
const NO_STEPKEY_ACTIONS = [
4847
'comment',
@@ -611,11 +610,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
611610
$time = $customActionAttributes['time'];
612611
}
613612
if (isset($customActionAttributes['timeout'])) {
614-
$commandTimeout = $customActionAttributes['timeout'];
613+
$time = $customActionAttributes['timeout'];
615614
}
616-
$time = $time ?? ActionObject::getDefaultWaitTimeout();
617615

618-
$commandTimeout = $commandTimeout ?? self::COMMAND_WAIT_TIMEOUT;
616+
if (in_array($actionObject->getType(), ActionObject::COMMAND_ACTION_ATTRIBUTES)) {
617+
$time = $time ?? ActionObject::DEFAULT_COMMAND_WAIT_TIMEOUT;
618+
} else {
619+
$time = $time ?? ActionObject::getDefaultWaitTimeout();
620+
}
619621

620622
if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') {
621623
// validate the param array is in the correct format
@@ -1285,7 +1287,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
12851287
$actionObject,
12861288
$command,
12871289
$arguments,
1288-
$commandTimeout
1290+
$time
12891291
);
12901292
$testSteps .= sprintf(self::STEP_KEY_ANNOTATION, $stepKey) . PHP_EOL;
12911293
$testSteps .= sprintf(

0 commit comments

Comments
 (0)