14
14
use Magento \FunctionalTestingFramework \Test \Objects \TestObject ;
15
15
use Magento \FunctionalTestingFramework \Util \Filesystem \DirSetupUtil ;
16
16
use Magento \FunctionalTestingFramework \Util \Sorter \ParallelGroupSorter ;
17
+ use RecursiveArrayIterator ;
18
+ use RecursiveIteratorIterator ;
17
19
18
20
class ParallelTestManifest extends BaseTestManifest
19
21
{
@@ -97,9 +99,10 @@ public function createTestGroups($lines)
97
99
public function generate ()
98
100
{
99
101
DirSetupUtil::createGroupDir ($ this ->dirPath );
102
+ $ suites = $ this ->getFlattenedSuiteConfiguration ($ this ->parallelGroupSorter ->getResultingSuiteConfig ());
100
103
101
104
foreach ($ this ->testGroups as $ groupNumber => $ groupContents ) {
102
- $ this ->generateGroupFile ($ groupContents , $ groupNumber );
105
+ $ this ->generateGroupFile ($ groupContents , $ groupNumber, $ suites );
103
106
}
104
107
}
105
108
@@ -115,15 +118,16 @@ public function getSorter()
115
118
116
119
/**
117
120
* Function which takes an array containing entries representing the test execution as well as the associated group
118
- * for the entry in order to generate a txt file used by devops for parllel execution in Jenkins.
121
+ * for the entry in order to generate a txt file used by devops for parllel execution in Jenkins. The results
122
+ * are checked against a flattened list of suites in order to generate proper entries.
119
123
*
120
124
* @param array $testGroup
121
125
* @param int $nodeNumber
126
+ * @param array $suites
122
127
* @return void
123
128
*/
124
- private function generateGroupFile ($ testGroup , $ nodeNumber )
129
+ private function generateGroupFile ($ testGroup , $ nodeNumber, $ suites )
125
130
{
126
- $ suites = $ this ->parallelGroupSorter ->getResultingSuiteConfig ();
127
131
foreach ($ testGroup as $ entryName => $ testValue ) {
128
132
$ fileResource = fopen ($ this ->dirPath . DIRECTORY_SEPARATOR . "group {$ nodeNumber }.txt " , 'a ' );
129
133
@@ -137,4 +141,27 @@ private function generateGroupFile($testGroup, $nodeNumber)
137
141
fclose ($ fileResource );
138
142
}
139
143
}
144
+
145
+ /**
146
+ * Function which recusrively parses a given potentially multidimensional array of suites containing their split
147
+ * groups. The result is a flattened array of suite names to relevant tests for generation of the manifest.
148
+ *
149
+ * @param array $multiDimensionalSuites
150
+ * @return array
151
+ */
152
+ private function getFlattenedSuiteConfiguration ($ multiDimensionalSuites )
153
+ {
154
+ $ suites = [];
155
+ foreach ($ multiDimensionalSuites as $ suiteName => $ suiteContent ) {
156
+ $ value = array_values ($ suiteContent )[0 ];
157
+ if (is_array ($ value )) {
158
+ $ suites = array_merge ($ suites , $ this ->getFlattenedSuiteConfiguration ($ suiteContent ));
159
+ continue ;
160
+ }
161
+
162
+ $ suites [$ suiteName ] = $ suiteContent ;
163
+ }
164
+
165
+ return $ suites ;
166
+ }
140
167
}
0 commit comments