Skip to content

Commit 97f3b3e

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

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

etc/config/command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$tokenPassedIn = urldecode($_POST['token'] ?? '');
1515
$command = urldecode($_POST['command'] ?? '');
1616
$arguments = urldecode($_POST['arguments'] ?? '');
17+
$timeout = urldecode($_POST['timeout'] ?? 60);
1718

1819
// Token returned will be null if the token we passed in is invalid
1920
$tokenFromMagento = $tokenModel->loadByToken($tokenPassedIn)->getToken();
@@ -24,7 +25,7 @@
2425
if ($valid) {
2526
$fullCommand = escapeshellcmd($magentoBinary . " $command" . " $arguments");
2627
$process = new Symfony\Component\Process\Process($fullCommand);
27-
$process->setIdleTimeout(60);
28+
$process->setIdleTimeout($timeout);
2829
$process->setTimeout(0);
2930
$idleTimeout = false;
3031
try {

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,16 @@ public function scrollToTopOfPage()
510510
/**
511511
* Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output.
512512
*
513-
* @param string $command
514-
* @param string $arguments
513+
* @param string $command
514+
* @param string $arguments
515+
* @param integer $timeout
515516
* @return string
517+
*
516518
* @throws TestFrameworkException
517519
*/
518-
public function magentoCLI($command, $arguments = null)
520+
public function magentoCLI($command, $arguments = null, $timeout = null)
519521
{
520-
return $this->curlExecMagentoCLI($command, $arguments);
522+
return $this->curlExecMagentoCLI($command, $arguments, $timeout);
521523
//TODO: calling bin/magento from pipeline is timing out, needs investigation (ref: MQE-1774)
522524
// try {
523525
// return $this->shellExecMagentoCLI($command, $arguments);
@@ -673,16 +675,17 @@ public function fillSecretField($field, $value)
673675
*
674676
* @param string $command
675677
* @param null $arguments
678+
* @param int $timeout
676679
* @throws TestFrameworkException
677680
* @return string
678681
*/
679-
public function magentoCLISecret($command, $arguments = null)
682+
public function magentoCLISecret($command, $timeout, $arguments = null)
680683
{
681684
// to protect any secrets from being printed to console the values are executed only at the webdriver level as a
682685
// decrypted value
683686

684687
$decryptedCommand = CredentialStore::getInstance()->decryptAllSecretsInString($command);
685-
return $this->magentoCLI($decryptedCommand, $arguments);
688+
return $this->magentoCLI($decryptedCommand, $timeout, $arguments);
686689
}
687690

688691
/**
@@ -860,12 +863,13 @@ private function shellExecMagentoCLI($command, $arguments): string
860863
/**
861864
* Takes given $command and executes it against exposed MTF CLI entry point. Returns response from server.
862865
*
863-
* @param string $command
864-
* @param string $arguments
865-
* @return string
866+
* @param string $command
867+
* @param string $arguments
868+
* @param integer $timeout
869+
*
866870
* @throws TestFrameworkException
867871
*/
868-
private function curlExecMagentoCLI($command, $arguments): string
872+
private function curlExecMagentoCLI($command, $arguments, $timeout): string
869873
{
870874
// Remove index.php if it's present in url
871875
$baseUrl = rtrim(
@@ -882,6 +886,7 @@ private function curlExecMagentoCLI($command, $arguments): string
882886
'token' => $restExecutor->getAuthToken(),
883887
getenv('MAGENTO_CLI_COMMAND_PARAMETER') => $command,
884888
'arguments' => $arguments,
889+
'timeout' => $timeout,
885890
],
886891
CurlInterface::POST,
887892
[]

src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
</xs:documentation>
5151
</xs:annotation>
5252
</xs:attribute>
53+
<xs:attribute type="xs:string" name="timeout">
54+
<xs:annotation>
55+
<xs:documentation>
56+
Idle timeout in seconds, defaulted to 60s when not specified.
57+
</xs:documentation>
58+
</xs:annotation>
59+
</xs:attribute>
5360
<xs:attributeGroup ref="commonActionAttributes"/>
5461
</xs:extension>
5562
</xs:simpleContent>

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ 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;
4546
const PERSISTED_OBJECT_NOTATION_REGEX = '/\${1,2}[\w.\[\]]+\${1,2}/';
4647
const NO_STEPKEY_ACTIONS = [
4748
'comment',
@@ -532,6 +533,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
532533
$sortOrder = null;
533534
$storeCode = null;
534535
$format = null;
536+
$commandTimeout = null;
535537

536538
$assertExpected = null;
537539
$assertActual = null;
@@ -609,10 +611,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
609611
$time = $customActionAttributes['time'];
610612
}
611613
if (isset($customActionAttributes['timeout'])) {
612-
$time = $customActionAttributes['timeout'];
614+
$commandTimeout = $customActionAttributes['timeout'];
613615
}
614616
$time = $time ?? ActionObject::getDefaultWaitTimeout();
615617

618+
$commandTimeout = $commandTimeout ?? self::COMMAND_WAIT_TIMEOUT;
619+
616620
if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') {
617621
// validate the param array is in the correct format
618622
$this->validateParameterArray($customActionAttributes['parameterArray']);
@@ -1280,7 +1284,8 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
12801284
$actor,
12811285
$actionObject,
12821286
$command,
1283-
$arguments
1287+
$arguments,
1288+
$commandTimeout
12841289
);
12851290
$testSteps .= sprintf(self::STEP_KEY_ANNOTATION, $stepKey) . PHP_EOL;
12861291
$testSteps .= sprintf(

0 commit comments

Comments
 (0)