Skip to content

Commit f429fbf

Browse files
committed
chore(NODE-6843): send results to perf endpoint
1 parent 5783db2 commit f429fbf

File tree

5 files changed

+107
-21
lines changed

5 files changed

+107
-21
lines changed

.evergreen/config.in.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ functions:
108108
args:
109109
- .evergreen/run-tests.sh
110110

111+
"perf send":
112+
- command: subprocess.exec
113+
params:
114+
working_dir: src
115+
binary: bash
116+
add_expansions_to_env: true
117+
args:
118+
- .evergreen/perf-send.sh
119+
111120
"run serverless tests":
112121
- command: timeout.update
113122
params:

.evergreen/config.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ functions:
8080
binary: bash
8181
args:
8282
- .evergreen/run-tests.sh
83+
perf send:
84+
- command: subprocess.exec
85+
params:
86+
working_dir: src
87+
binary: bash
88+
add_expansions_to_env: true
89+
args:
90+
- .evergreen/perf-send.sh
8391
run serverless tests:
8492
- command: timeout.update
8593
params:
@@ -1891,9 +1899,7 @@ tasks:
18911899
- func: install dependencies
18921900
- func: bootstrap mongo-orchestration
18931901
- func: run spec driver benchmarks
1894-
- command: perf.send
1895-
params:
1896-
file: src/test/benchmarks/driver_bench/results.json
1902+
- func: perf send
18971903
- name: run-spec-benchmark-tests-node-server-timeoutMS-120000
18981904
tags:
18991905
- run-spec-benchmark-tests
@@ -1912,9 +1918,7 @@ tasks:
19121918
- func: install dependencies
19131919
- func: bootstrap mongo-orchestration
19141920
- func: run spec driver benchmarks
1915-
- command: perf.send
1916-
params:
1917-
file: src/test/benchmarks/driver_bench/results.json
1921+
- func: perf send
19181922
- name: run-spec-benchmark-tests-node-server-timeoutMS-0
19191923
tags:
19201924
- run-spec-benchmark-tests
@@ -1933,9 +1937,7 @@ tasks:
19331937
- func: install dependencies
19341938
- func: bootstrap mongo-orchestration
19351939
- func: run spec driver benchmarks
1936-
- command: perf.send
1937-
params:
1938-
file: src/test/benchmarks/driver_bench/results.json
1940+
- func: perf send
19391941
- name: run-spec-benchmark-tests-node-server-monitorCommands-true
19401942
tags:
19411943
- run-spec-benchmark-tests
@@ -1954,9 +1956,7 @@ tasks:
19541956
- func: install dependencies
19551957
- func: bootstrap mongo-orchestration
19561958
- func: run spec driver benchmarks
1957-
- command: perf.send
1958-
params:
1959-
file: src/test/benchmarks/driver_bench/results.json
1959+
- func: perf send
19601960
- name: run-spec-benchmark-tests-node-server-logging
19611961
tags:
19621962
- run-spec-benchmark-tests
@@ -1975,9 +1975,7 @@ tasks:
19751975
- func: install dependencies
19761976
- func: bootstrap mongo-orchestration
19771977
- func: run spec driver benchmarks
1978-
- command: perf.send
1979-
params:
1980-
file: src/test/benchmarks/driver_bench/results.json
1978+
- func: perf send
19811979
- name: run-unit-tests-node-16
19821980
tags:
19831981
- unit-tests

.evergreen/generate_evergreen_tasks.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,9 @@ function addPerformanceTasks() {
765765
...[
766766
'install dependencies',
767767
'bootstrap mongo-orchestration',
768-
'run spec driver benchmarks'
769-
].map(func => ({ func })),
770-
{
771-
command: 'perf.send',
772-
params: { file: 'src/test/benchmarks/driver_bench/results.json' }
773-
}
768+
'run spec driver benchmarks',
769+
'perf send'
770+
].map(func => ({ func }))
774771
]
775772
});
776773

.evergreen/perf-send.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -euox pipefail
4+
5+
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
6+
7+
TARGET_FILE=${TARGET_FILE:-src/test/benchmarks/driver_bench/results.json}
8+
9+
node src/.evergreen/perf_send.mjs $TARGET_FILE

.evergreen/perf_send.mjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import fs from 'fs/promises';
2+
import util from 'util';
3+
4+
const API_PATH = 'https://performance-monitoring-api.corp.mongodb.com/raw_perf_results';
5+
6+
const resultFile = process.argv[2];
7+
if (resultFile == null) {
8+
throw new Error('Must specify result file');
9+
}
10+
11+
// Get expansions
12+
const {
13+
execution,
14+
requester,
15+
project,
16+
task_id,
17+
task_name,
18+
revision_order_id,
19+
build_variant: variant,
20+
version_id: version
21+
} = process.env;
22+
23+
const orderSplit = revision_order_id?.split('_');
24+
const order = Number(orderSplit ? orderSplit[orderSplit.length - 1] : undefined);
25+
26+
if (!Number.isInteger(order)) throw new Error(`Failed to parse integer from order, revision_order_id=${revision_order_id}`);
27+
28+
const results = JSON.parse(await fs.readFile(resultFile, 'utf8'));
29+
30+
// FIXME(NODE-6838): We are using dummy dates here just to be able to successfully post our results
31+
for (const r of results) {
32+
r.created_at = new Date().toISOString();
33+
r.completed_at = new Date().toISOString();
34+
}
35+
36+
const body = {
37+
id: {
38+
project,
39+
version,
40+
variant,
41+
order,
42+
task_name,
43+
task_id,
44+
execution,
45+
mainline: requester === 'commit'
46+
},
47+
results
48+
};
49+
50+
console.log('POST', util.inspect(body, { depth: Infinity }));
51+
52+
const resp = await fetch(API_PATH, {
53+
method: 'POST',
54+
headers: {
55+
'Content-Type': 'application/json',
56+
accept: 'application/json'
57+
},
58+
body: JSON.stringify(body)
59+
});
60+
61+
const responseText = await resp.text();
62+
let jsonResponse = null;
63+
try {
64+
jsonResponse = JSON.parse(responseText)
65+
} catch (cause) {
66+
console.log('Failed to parse json response', cause);
67+
}
68+
69+
console.log(resp.statusText, util.inspect(jsonResponse ?? responseText, { depth: Infinity }));
70+
71+
if (jsonResponse.message == null) throw new Error("Didn't get success message");
72+
73+
console.log(jsonResponse.message);

0 commit comments

Comments
 (0)