Skip to content

Commit 54d29e5

Browse files
authored
chore(NODE-6843): send results to perf endpoint (#4455)
1 parent 7dba9b1 commit 54d29e5

File tree

6 files changed

+101
-21
lines changed

6 files changed

+101
-21
lines changed

Diff for: .evergreen/config.in.yml

+9
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:

Diff for: .evergreen/config.yml

+13-15
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

Diff for: .evergreen/generate_evergreen_tasks.js

+3-6
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

Diff for: .evergreen/perf-send.sh

+9
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=$(realpath "${TARGET_FILE:-./test/benchmarks/driver_bench/results.json}")
8+
9+
node ./.evergreen/perf_send.mjs $TARGET_FILE

Diff for: .evergreen/perf_send.mjs

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
const body = {
31+
id: {
32+
project,
33+
version,
34+
variant,
35+
order,
36+
task_name,
37+
task_id,
38+
execution,
39+
mainline: requester === 'commit'
40+
},
41+
results
42+
};
43+
44+
const resp = await fetch(API_PATH, {
45+
method: 'POST',
46+
headers: {
47+
'Content-Type': 'application/json',
48+
accept: 'application/json'
49+
},
50+
body: JSON.stringify(body)
51+
});
52+
53+
const responseText = await resp.text();
54+
let jsonResponse = null;
55+
try {
56+
jsonResponse = JSON.parse(responseText)
57+
} catch (cause) {
58+
console.log('Failed to parse json response', cause);
59+
}
60+
61+
console.log(resp.statusText, util.inspect(jsonResponse ?? responseText, { depth: Infinity }));
62+
63+
if (jsonResponse.message == null) throw new Error("Didn't get success message");

Diff for: test/benchmarks/driver_bench/src/driver.mts

+4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export type MetricInfo = {
145145
test_name: string;
146146
args: Record<string, number>;
147147
};
148+
created_at: string;
149+
completed_at: string;
148150
metrics: Metric[];
149151
};
150152

@@ -161,6 +163,8 @@ export function metrics(test_name: string, result: number, tags?: string[]): Met
161163
])
162164
)
163165
},
166+
created_at: new Date().toISOString(),
167+
completed_at: new Date().toISOString(),
164168
// FIXME(NODE-6781): For now all of our metrics are of throughput so their improvement_direction is up,
165169
metrics: [
166170
{

0 commit comments

Comments
 (0)