Skip to content

Commit 7550083

Browse files
jdamore-linodebnussman-akamai
authored andcommitted
test: [M3-7763] - Account for parallelization in Cypress test result summary duration (linode#12765)
* Report Cypress test duration of slowest runner * Added changeset: Fix Cypress test result summary duration accuracy
1 parent da1c360 commit 7550083

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Tests
3+
---
4+
5+
Fix Cypress test result summary duration accuracy ([#12765](https://github.com/linode/manager/pull/12765))

packages/manager/cypress/support/plugins/junit-report.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const getCommonJunitConfig = (
2727
testSuite: string,
2828
config: Cypress.PluginConfigOptions
2929
) => {
30+
const runnerIndex = Number(config.env['CY_TEST_SPLIT_RUN_INDEX']) || 1;
31+
3032
if (config.env[envVarName]) {
3133
if (!config.reporterOptions) {
3234
config.reporterOptions = {};
@@ -38,6 +40,9 @@ const getCommonJunitConfig = (
3840
testsuitesTitle: testSuiteName,
3941
jenkinsMode: true,
4042
suiteTitleSeparatedBy: '→',
43+
properties: {
44+
runner_index: runnerIndex,
45+
},
4146
};
4247
}
4348
return config;

scripts/junit-summary/util/index.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,32 @@ import type { TestResult } from '../results/test-result';
99
* @returns Length of time for all suites to run, in seconds.
1010
*/
1111
export const getTestLength = (suites: TestSuites[]): number => {
12-
const unroundedLength = suites.reduce((acc: number, cur: TestSuites) => {
13-
return acc + (cur.time ?? 0);
14-
}, 0);
15-
return Math.round(unroundedLength * 1000) / 1000;
12+
const testDurations: {[key: number]: number} = suites.reduce((acc: {[key: number]: number}, cur: TestSuites) => {
13+
const suite = cur.testsuite?.[0];
14+
if (!suite) {
15+
return acc;
16+
}
17+
18+
const runnerIndex = (() => {
19+
if (!suite.properties) {
20+
return 1;
21+
}
22+
const indexProperty = suite.properties.find((property) => {
23+
return property.name === 'runner_index';
24+
});
25+
26+
if (!indexProperty) {
27+
return 1;
28+
}
29+
return Number(indexProperty.value);
30+
})();
31+
32+
acc[runnerIndex] = (acc[runnerIndex] || 0) + (cur.time ?? 0);
33+
return acc;
34+
}, {});
35+
36+
const highestDuration = Math.max(...Object.values(testDurations));
37+
return Math.round(highestDuration * 1000) / 1000;
1638
};
1739

1840
/**

0 commit comments

Comments
 (0)