Skip to content

Commit a8cce50

Browse files
committed
ACQE-5871: Add ability to increase default MagentoCLI timeout
1 parent 21aa7b2 commit a8cce50

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed
Lines changed: 59 additions & 0 deletions
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+
}
Lines changed: 16 additions & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ActionObject
7272
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/';
7373
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\((?(?!}}).)+\)}})/';
7474
const STRING_PARAMETER_REGEX = "/'[^']+'/";
75+
const DEFAULT_COMMAND_WAIT_TIMEOUT = 60;
7576
const ACTION_ATTRIBUTE_USERINPUT = 'userInput';
7677
const ACTION_TYPE_COMMENT = 'comment';
7778
const ACTION_TYPE_HELPER = 'helper';
@@ -190,7 +191,8 @@ public static function getDefaultWaitTimeout()
190191
*/
191192
public static function getDefaultMagentoCLIWaitTimeout()
192193
{
193-
return getenv('MAGENTO_CLI_WAIT_TIMEOUT');
194+
$timeout = getenv('MAGENTO_CLI_WAIT_TIMEOUT');
195+
return $timeout !== false ? $timeout : self::DEFAULT_COMMAND_WAIT_TIMEOUT;
194196
}
195197

196198
/**

0 commit comments

Comments
 (0)