Skip to content

Commit f285fe3

Browse files
authored
Merge pull request #368 from magento-commerce/ACQE-5871
ACQE-5871: Add ability to increase default MagentoCLI timeout
2 parents fdf77db + cfec610 commit f285fe3

File tree

7 files changed

+109
-7
lines changed

7 files changed

+109
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @Description("<h3>Test files</h3>verification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml<br>")
17+
*/
18+
class MagentoCliTestCest
19+
{
20+
/**
21+
* @var bool
22+
*/
23+
private $isSuccess = false;
24+
25+
/**
26+
* @param AcceptanceTester $I
27+
* @throws \Exception
28+
*/
29+
public function _after(AcceptanceTester $I)
30+
{
31+
if ($this->isSuccess) {
32+
unlink(__FILE__);
33+
}
34+
}
35+
36+
/**
37+
* @Features({"TestModule"})
38+
* @param AcceptanceTester $I
39+
* @return void
40+
* @throws \Exception
41+
*/
42+
public function MagentoCliTest(AcceptanceTester $I)
43+
{
44+
$magentoCli1 = $I->magentoCLI("maintenance:enable", 45, "\"stuffHere\""); // stepKey: magentoCli1
45+
$I->comment($magentoCli1);
46+
$magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2
47+
$I->comment($magentoCli2);
48+
$magentoCli3 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 45); // stepKey: magentoCli3
49+
$I->comment($magentoCli3); // stepKey: magentoCli3
50+
$magentoCli4 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 120); // stepKey: magentoCli4
51+
$I->comment($magentoCli4); // stepKey: magentoCli4
52+
}
53+
54+
public function _passed(AcceptanceTester $I)
55+
{
56+
// Test passed successfully.
57+
$this->isSuccess = true;
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="MagentoCliTest">
11+
<magentoCLI command="maintenance:enable" arguments="&quot;stuffHere&quot;" stepKey="magentoCli1"/>
12+
<magentoCLI command="maintenance:enable" arguments="&quot;stuffHere&quot;" timeout="120" stepKey="magentoCli2"/>
13+
<magentoCLI command="config:set somePath {{_CREDS.someKey}}" stepKey="magentoCli3"/>
14+
<magentoCLI command="config:set somePath {{_CREDS.someKey}}" timeout="120" stepKey="magentoCli4"/>
15+
</test>
16+
</tests>

dev/tests/verification/Tests/BasicCestGenerationTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ public function testWithXmlComments()
5959
{
6060
$this->generateAndCompareTest('XmlCommentedTest');
6161
}
62+
63+
/**
64+
* Tests magentoCLI and magentoCLISecret commands with env 'MAGENTO_CLI_WAIT_TIMEOUT' set
65+
*
66+
* @throws \Exception
67+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
68+
*/
69+
public function testMagentoCli()
70+
{
71+
putenv("MAGENTO_CLI_WAIT_TIMEOUT=45");
72+
$this->generateAndCompareTest('MagentoCliTest');
73+
putenv("MAGENTO_CLI_WAIT_TIMEOUT");
74+
}
6275
}

etc/config/.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ MODULE_ALLOWLIST=Magento_Framework,ConfigurableProductWishlist,ConfigurableProdu
6161
#*** Default timeout for wait actions
6262
WAIT_TIMEOUT=60
6363

64+
#*** Default timeout for 'magentoCLI' and 'magentoCLISecret' command
65+
MAGENTO_CLI_WAIT_TIMEOUT=60
66+
6467
#*** Uncomment and set to enable all tests, regardless of passing status, to have all their Allure artifacts.
6568
#VERBOSE_ARTIFACTS=true
6669

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ public function scrollToTopOfPage()
530530
/**
531531
* Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output.
532532
*
533-
* @param string $command
534-
* @param integer $timeout
535-
* @param string $arguments
533+
* @param string $command
534+
* @param integer|null $timeout
535+
* @param string|null $arguments
536536
* @return string
537537
*
538538
* @throws TestFrameworkException
@@ -846,9 +846,9 @@ public function fillSecretField($field, $value)
846846
* Function used to create data that contains sensitive credentials in a <createData> <field> override.
847847
* The data is decrypted immediately prior to data creation to avoid exposure in console or log.
848848
*
849-
* @param string $command
850-
* @param null $timeout
851-
* @param null $arguments
849+
* @param string $command
850+
* @param integer|null $timeout
851+
* @param string|null $arguments
852852
* @throws TestFrameworkException
853853
* @return string
854854
*/

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

+11
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ public static function getDefaultWaitTimeout()
184184
return getenv('WAIT_TIMEOUT');
185185
}
186186

187+
/**
188+
* Retrieve default timeout for 'magentoCLI' or 'magentoCLISecret' in seconds
189+
*
190+
* @return integer
191+
*/
192+
public static function getDefaultMagentoCLIWaitTimeout()
193+
{
194+
$timeout = getenv('MAGENTO_CLI_WAIT_TIMEOUT');
195+
return !empty($timeout) ? $timeout : self::DEFAULT_COMMAND_WAIT_TIMEOUT;
196+
}
197+
187198
/**
188199
* This function returns the string property stepKey.
189200
*

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
842842
}
843843

844844
if (in_array($actionObject->getType(), ActionObject::COMMAND_ACTION_ATTRIBUTES)) {
845-
$time = $time ?? ActionObject::DEFAULT_COMMAND_WAIT_TIMEOUT;
845+
$time = $time ?? ActionObject::getDefaultMagentoCLIWaitTimeout();
846846
} else {
847847
$time = $time ?? ActionObject::getDefaultWaitTimeout();
848848
}

0 commit comments

Comments
 (0)