Skip to content

Commit 9e10bfc

Browse files
authored
Merge pull request #140 from magento-commerce/MQE-3124
MQE-3124: Fix unbalanced execution time among parallel groups
2 parents 7adbae6 + 7111f9d commit 9e10bfc

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

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

+41-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,35 @@ class TestObject
2121

2222
const TEST_ACTION_WEIGHT = [
2323
'waitForPageLoad' => 1500,
24-
'amOnPage' => 1000,
24+
'amOnPage' => 1500,
2525
'waitForLoadingMaskToDisappear' => 500,
2626
'wait' => self::WAIT_TIME_ATTRIBUTE,
27+
'waitForAjaxLoad' => 500,
28+
'waitForElementNotVisible' => 500,
29+
'waitForElementVisible' => 500,
30+
'waitForText' => 500,
31+
'waitForElement' => 500,
32+
'waitForJS' => 500,
2733
'comment' => 5,
2834
'assertCount' => 5,
29-
'closeAdminNotification' => 10
35+
'closeAdminNotification' => 10,
36+
'magentoCLI' => 1000,
37+
'magentoCron' => 3000,
38+
'createData' => 500,
39+
'deleteData' => 200,
40+
'updateData' => 200,
41+
'getOTP' => 1000,
3042
];
3143

44+
const WEBAPI_AUTH_TEST_ACTIONS = [
45+
'createData',
46+
'deleteData',
47+
'updateData',
48+
'getData',
49+
];
50+
51+
const WEBAPI_AUTH_TEST_ACTION_WEIGHT = 6000;
52+
3253
/**
3354
* Name of the test
3455
*
@@ -85,6 +106,13 @@ class TestObject
85106
*/
86107
private $deprecated;
87108

109+
/**
110+
* Indicates if a test contains an action that requires Web API authentication.
111+
*
112+
* @var boolean
113+
*/
114+
private $hasWebApiAuthAction;
115+
88116
/**
89117
* TestObject constructor.
90118
*
@@ -112,6 +140,7 @@ public function __construct(
112140
$this->filename = $filename;
113141
$this->parentTest = $parentTest;
114142
$this->deprecated = $deprecated;
143+
$this->hasWebApiAuthAction = false;
115144
}
116145

117146
/**
@@ -222,7 +251,11 @@ public function getEstimatedDuration()
222251

223252
$testTime = $this->calculateWeightedActionTimes($this->getOrderedActions());
224253

225-
return $hookTime + $testTime;
254+
if ($this->hasWebApiAuthAction) {
255+
return $hookTime + $testTime + self::WEBAPI_AUTH_TEST_ACTION_WEIGHT;
256+
} else {
257+
return $hookTime + $testTime;
258+
}
226259
}
227260

228261
/**
@@ -237,6 +270,11 @@ private function calculateWeightedActionTimes($actions)
237270
// search for any actions of special type
238271
foreach ($actions as $action) {
239272
/** @var ActionObject $action */
273+
274+
if (!$this->hasWebApiAuthAction && in_array($action->getType(), self::WEBAPI_AUTH_TEST_ACTIONS)) {
275+
$this->hasWebApiAuthAction = true;
276+
}
277+
240278
if (array_key_exists($action->getType(), self::TEST_ACTION_WEIGHT)) {
241279
$weight = self::TEST_ACTION_WEIGHT[$action->getType()];
242280
if ($weight === self::WAIT_TIME_ATTRIBUTE) {

0 commit comments

Comments
 (0)