Skip to content

Commit 433542b

Browse files
committed
fix perf_send
1 parent 9020210 commit 433542b

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

.evergreen/perf_send.mjs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as fs from 'fs/promises';
55
import { inspect } from 'util';
66
console.log(process.versions);
7-
const API_PATH = "https://performance-monitoring-service-rest.server-tig.prod.corp.mongodb.com/raw_perf_results"
7+
const API_PATH = "https://performance-monitoring-service-rest.server-tig.prod.corp.mongodb.com/raw_perf_results";
88

99
const resultFile = process.argv[2];
1010
if (resultFile == undefined) {
@@ -18,13 +18,29 @@ const {
1818
project,
1919
task_id,
2020
task_name,
21-
revision_order_id: order,
21+
revision_order_id,
2222
build_variant: variant,
2323
version_id: version
2424
} = process.env;
2525

26+
const orderSplit = revision_order_id?.split('_');
27+
let order = orderSplit ? orderSplit[orderSplit.length - 1] : undefined;
28+
29+
if (!order) throw new Error(`failed to get order, got "${order}"`);
30+
31+
order = Number(order);
32+
33+
if (!Number.isInteger(order)) throw new Error(`Failed to parse integer from order, got ${order}`);
34+
35+
let results = await fs.readFile(resultFile, 'utf8');
36+
results = JSON.parse(results);
37+
38+
// FIXME(NODE-6838): We are using dummy dates here just to be able to successfully post our results
39+
for (const r of results) {
40+
r.info.created_at = new Date().toISOString();
41+
r.info.completed_at = new Date().toISOString();
42+
}
2643

27-
const results = await fs.readFile(resultFile, 'utf8');
2844
const body = {
2945
id: {
3046
project,
@@ -36,7 +52,7 @@ const body = {
3652
execution,
3753
mainline: requester === 'commit'
3854
},
39-
results: JSON.parse(results)
55+
results
4056
};
4157

4258
console.log(inspect(body, { depth: Infinity }));
@@ -49,8 +65,16 @@ const resp = await fetch(API_PATH, {
4965
body: JSON.stringify(body)
5066
});
5167

52-
if (resp.status !== 200) {
53-
throw new Error(`Got status code: ${resp.status}\nResponse body: ${await resp.text()}`);
68+
69+
let jsonResponse;
70+
try {
71+
jsonResponse = await resp.json();
72+
} catch (e) {
73+
throw new Error("Failed to parse json response", { cause: e });
5474
}
5575

76+
console.log(inspect(jsonResponse, { depth: Infinity }));
77+
78+
if (!jsonResponse.message) throw new Error("Didn't get success message");
79+
5680
console.log("Successfully posted results");

test/bench/custom/main.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async function completeSuite() {
5656
result.metrics.push({
5757
name: 'normalized_throughput',
5858
value: bench.hz / cpuBaselineResult,
59-
metadata
59+
metadata: { ...metadata, tags }
6060
});
6161
data.push(result);
6262
}

0 commit comments

Comments
 (0)