Skip to content

Commit

Permalink
Merge pull request #372 from magento-commerce/ACQE-5911
Browse files Browse the repository at this point in the history
Acqe 5911: 4.6.1 release
  • Loading branch information
jilu1 committed Dec 12, 2023
2 parents acc45c0 + d9df7d9 commit 980ce73
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Magento Functional Testing Framework Changelog
================================================

4.6.1
---------
### Enhancements
* Supported setting custom timeout value for `magentoCLI` command via an environment variable `MAGENTO_CLI_WAIT_TIMEOUT`.

4.6.0
---------
### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento2-functional-testing-framework",
"description": "Magento2 Functional Testing Framework",
"type": "library",
"version": "4.6.0",
"version": "4.6.1",
"license": "AGPL-3.0",
"keywords": ["magento", "automation", "functional", "testing"],
"config": {
Expand Down
22 changes: 18 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions dev/tests/verification/Resources/MagentoCliTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
namespace Magento\AcceptanceTest\_default\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use \Codeception\Util\Locator;
use Yandex\Allure\Adapter\Annotation\Features;
use Yandex\Allure\Adapter\Annotation\Stories;
use Yandex\Allure\Adapter\Annotation\Title;
use Yandex\Allure\Adapter\Annotation\Description;
use Yandex\Allure\Adapter\Annotation\Parameter;
use Yandex\Allure\Adapter\Annotation\Severity;
use Yandex\Allure\Adapter\Model\SeverityLevel;
use Yandex\Allure\Adapter\Annotation\TestCaseId;

/**
* @Description("<h3>Test files</h3>verification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml<br>")
*/
class MagentoCliTestCest
{
/**
* @var bool
*/
private $isSuccess = false;

/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _after(AcceptanceTester $I)
{
if ($this->isSuccess) {
unlink(__FILE__);
}
}

/**
* @Features({"TestModule"})
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function MagentoCliTest(AcceptanceTester $I)
{
$magentoCli1 = $I->magentoCLI("maintenance:enable", 45, "\"stuffHere\""); // stepKey: magentoCli1
$I->comment($magentoCli1);
$magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2
$I->comment($magentoCli2);
$magentoCli3 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 45); // stepKey: magentoCli3
$I->comment($magentoCli3); // stepKey: magentoCli3
$magentoCli4 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 120); // stepKey: magentoCli4
$I->comment($magentoCli4); // stepKey: magentoCli4
}

public function _passed(AcceptanceTester $I)
{
// Test passed successfully.
$this->isSuccess = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="MagentoCliTest">
<magentoCLI command="maintenance:enable" arguments="&quot;stuffHere&quot;" stepKey="magentoCli1"/>
<magentoCLI command="maintenance:enable" arguments="&quot;stuffHere&quot;" timeout="120" stepKey="magentoCli2"/>
<magentoCLI command="config:set somePath {{_CREDS.someKey}}" stepKey="magentoCli3"/>
<magentoCLI command="config:set somePath {{_CREDS.someKey}}" timeout="120" stepKey="magentoCli4"/>
</test>
</tests>
13 changes: 13 additions & 0 deletions dev/tests/verification/Tests/BasicCestGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ public function testWithXmlComments()
{
$this->generateAndCompareTest('XmlCommentedTest');
}

/**
* Tests magentoCLI and magentoCLISecret commands with env 'MAGENTO_CLI_WAIT_TIMEOUT' set
*
* @throws \Exception
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testMagentoCli()
{
putenv("MAGENTO_CLI_WAIT_TIMEOUT=45");
$this->generateAndCompareTest('MagentoCliTest');
putenv("MAGENTO_CLI_WAIT_TIMEOUT");
}
}
3 changes: 3 additions & 0 deletions etc/config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ MODULE_ALLOWLIST=Magento_Framework,ConfigurableProductWishlist,ConfigurableProdu
#*** Default timeout for wait actions
WAIT_TIMEOUT=60

#*** Default timeout for 'magentoCLI' and 'magentoCLISecret' command
MAGENTO_CLI_WAIT_TIMEOUT=60

#*** Uncomment and set to enable all tests, regardless of passing status, to have all their Allure artifacts.
#VERBOSE_ARTIFACTS=true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,9 @@ public function scrollToTopOfPage()
/**
* Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output.
*
* @param string $command
* @param integer $timeout
* @param string $arguments
* @param string $command
* @param integer|null $timeout
* @param string|null $arguments
* @return string
*
* @throws TestFrameworkException
Expand Down Expand Up @@ -846,9 +846,9 @@ public function fillSecretField($field, $value)
* Function used to create data that contains sensitive credentials in a <createData> <field> override.
* The data is decrypted immediately prior to data creation to avoid exposure in console or log.
*
* @param string $command
* @param null $timeout
* @param null $arguments
* @param string $command
* @param integer|null $timeout
* @param string|null $arguments
* @throws TestFrameworkException
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ public static function getDefaultWaitTimeout()
return getenv('WAIT_TIMEOUT');
}

/**
* Retrieve default timeout for 'magentoCLI' or 'magentoCLISecret' in seconds
*
* @return integer
*/
public static function getDefaultMagentoCLIWaitTimeout()
{
$timeout = getenv('MAGENTO_CLI_WAIT_TIMEOUT');
return !empty($timeout) ? $timeout : self::DEFAULT_COMMAND_WAIT_TIMEOUT;
}

/**
* This function returns the string property stepKey.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
}

if (in_array($actionObject->getType(), ActionObject::COMMAND_ACTION_ATTRIBUTES)) {
$time = $time ?? ActionObject::DEFAULT_COMMAND_WAIT_TIMEOUT;
$time = $time ?? ActionObject::getDefaultMagentoCLIWaitTimeout();
} else {
$time = $time ?? ActionObject::getDefaultWaitTimeout();
}
Expand Down

0 comments on commit 980ce73

Please sign in to comment.