Skip to content

Commit 58e8110

Browse files
committed
MQE-2495: config parallel by number of groups
1 parent 6f76b0b commit 58e8110

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

dev/tests/verification/Tests/SuiteGenerationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function testSuiteGenerationParallel()
122122

123123
//createParallelManifest
124124
/** @var ParallelByTimeTestManifest $parallelManifest */
125-
$parallelManifest = TestManifestFactory::makeManifest("parallel", ["functionalSuite1" => []]);
125+
$parallelManifest = TestManifestFactory::makeManifest("parallelByTime", ["functionalSuite1" => []]);
126126

127127
// Generate the Suite
128128
$parallelManifest->createTestGroups(1);

src/Magento/FunctionalTestingFramework/Util/Sorter/ParallelGroupSorter.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,17 @@ private function getSuiteNameToGroupCount($suites, $time)
180180
*/
181181
private function splitTestsIntoGroups($tests, $groupCnt)
182182
{
183+
// Reverse sort the test array by size
183184
arsort($tests);
184-
$groups = [];
185+
$groups = array_fill(0, $groupCnt, []);
185186

186-
$cnt = -1;
187187
foreach ($tests as $test => $size) {
188-
$cnt += 1;
189-
$index = $cnt % (2 * $groupCnt);
190-
if ($index <= $groupCnt - 1) {
191-
$groups[$index][$test] = $size;
192-
} else {
193-
$groups[intval(2 * $groupCnt - 1 - $index)][$test] = $size;
188+
for ($i = 0; $i < $groupCnt; $i++) {
189+
$sums[$i] = array_sum($groups[$i]);
194190
}
191+
asort($sums);
192+
// Always add the next test to the group with the smallest sum
193+
$groups[array_keys($sums)[0]][$test] = $size;
195194
}
196195
return $groups;
197196
}

0 commit comments

Comments
 (0)