Skip to content

Commit 1b3c72c

Browse files
authored
Add display javaVersion for traffic light (#1083)
Add display javaVersion for traffic light Signed-off-by: LongyuZhang <longyu.zhang@ibm.com>
1 parent 39c5a60 commit 1b3c72c

1 file changed

Lines changed: 56 additions & 5 deletions

File tree

test-result-summary-client/src/TrafficLight/TrafficLight.jsx

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,40 @@ function TrafficLight() {
5050
);
5151
}
5252
}
53+
54+
const buildJavaVersionMap = async (data) => {
55+
let javaVersionMap = new Map();
56+
for (const childData of data) {
57+
const buildNameWithPlatform = childData.buildName.slice(
58+
0,
59+
childData.buildName.lastIndexOf('_')
60+
);
61+
if (
62+
!javaVersionMap.has(buildNameWithPlatform) &&
63+
childData.aggregateInfo
64+
) {
65+
if (childData.aggregateInfo.buildName) {
66+
const grandchildrenData = await fetchData(
67+
`/api/getChildBuilds?parentId=${childData._id}&buildName=${childData.aggregateInfo.buildName}`
68+
);
69+
for (const grandchildData of grandchildrenData) {
70+
if (grandchildData.javaVersion) {
71+
javaVersionMap.set(
72+
buildNameWithPlatform,
73+
grandchildData.javaVersion.replace(
74+
/\n/g,
75+
'\n '
76+
)
77+
);
78+
break;
79+
}
80+
}
81+
}
82+
}
83+
}
84+
return javaVersionMap;
85+
};
86+
5387
const handleCompare = async () => {
5488
let testData = await fetchData(
5589
`/api/getTrafficLightData?parentId=${testBuild}&buildType=test`
@@ -74,6 +108,10 @@ function TrafficLight() {
74108
baselineData.forEach((element) => {
75109
element.buildType = 'baseline';
76110
});
111+
112+
const testJavaVersionMap = await buildJavaVersionMap(testData);
113+
const baselineJavaVersionMap = await buildJavaVersionMap(baselineData);
114+
77115
const metricPropsJSON = await fetchData(`/api/getBenchmarkMetricProps`);
78116
const modifiedData = [...testData, ...baselineData]
79117
.map(
@@ -87,10 +125,18 @@ function TrafficLight() {
87125
aggregateInfo;
88126
const benchmark = benchmarkName.split('-')[0];
89127
const { platform } = getInfoFromBuildName(buildName);
90-
const buildNameTitle = parentBuildName
91-
.slice(0, parentBuildName.lastIndexOf('_'))
92-
.replace('Perf_open', '');
93-
128+
const originBuildNameTitle = parentBuildName.slice(
129+
0,
130+
parentBuildName.lastIndexOf('_')
131+
);
132+
const buildNameTitle = originBuildNameTitle.replace(
133+
'Perf_open',
134+
''
135+
);
136+
const javaVersion =
137+
buildType === 'test'
138+
? testJavaVersionMap.get(originBuildNameTitle)
139+
: baselineJavaVersionMap.get(originBuildNameTitle);
94140
return aggregateInfo.metrics.map(
95141
({ name: metricsName, statValues, rawValues }) => {
96142
let higherbetter = true;
@@ -117,6 +163,7 @@ function TrafficLight() {
117163
buildName,
118164
platform,
119165
higherbetter,
166+
javaVersion,
120167
};
121168
}
122169
);
@@ -168,6 +215,8 @@ function TrafficLight() {
168215
const totalCI =
169216
Number((testValues.CI + baselineValues.CI) * 100).toFixed(2) +
170217
'%';
218+
const testJavaVersion = testBuild.javaVersion;
219+
const baselineJaveVersion = baselineBuild.javaVersion;
171220
let icon = iconRed;
172221
if (percentage > 98) {
173222
icon = iconGreen;
@@ -183,7 +232,9 @@ function TrafficLight() {
183232
<br />
184233
Test CI: {testCI} <br />
185234
Baseline CI: {baselineCI} <br />
186-
Total CI: {totalCI}
235+
Total CI: {totalCI} <br />
236+
Test JavaVersion: {testJavaVersion} <br />
237+
Baseline JavaVersion: {baselineJaveVersion}
187238
</pre>
188239
}
189240
>

0 commit comments

Comments
 (0)