Skip to content

Commit b0667b1

Browse files
authored
PYTHON-5358 - Switch to supported Perf usage in EVG (#2334)
1 parent cf9b68c commit b0667b1

File tree

6 files changed

+118
-7
lines changed

6 files changed

+118
-7
lines changed

.evergreen/generated_configs/functions.yml

+38-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,45 @@ functions:
162162

163163
# Send dashboard data
164164
send dashboard data:
165-
- command: perf.send
165+
- command: subprocess.exec
166+
params:
167+
binary: bash
168+
args:
169+
- .evergreen/scripts/perf-submission-setup.sh
170+
working_dir: src
171+
include_expansions_in_env:
172+
- requester
173+
- revision_order_id
174+
- project_id
175+
- version_id
176+
- build_variant
177+
- parsed_order_id
178+
- task_name
179+
- task_id
180+
- execution
181+
- is_mainline
182+
type: test
183+
- command: expansions.update
166184
params:
167-
file: src/results.json
185+
file: src/expansion.yml
186+
- command: subprocess.exec
187+
params:
188+
binary: bash
189+
args:
190+
- .evergreen/scripts/perf-submission.sh
191+
working_dir: src
192+
include_expansions_in_env:
193+
- requester
194+
- revision_order_id
195+
- project_id
196+
- version_id
197+
- build_variant
198+
- parsed_order_id
199+
- task_name
200+
- task_id
201+
- execution
202+
- is_mainline
203+
type: test
168204

169205
# Setup system
170206
setup system:

.evergreen/scripts/generate_config.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
ec2_assume_role,
4242
expansions_update,
4343
git_get_project,
44-
perf_send,
4544
)
4645
from shrub.v3.evg_task import EvgTask, EvgTaskDependency, EvgTaskRef
4746

@@ -1103,8 +1102,28 @@ def create_attach_benchmark_test_results_func():
11031102

11041103

11051104
def create_send_dashboard_data_func():
1106-
cmd = perf_send(file="src/results.json")
1107-
return "send dashboard data", [cmd]
1105+
includes = [
1106+
"requester",
1107+
"revision_order_id",
1108+
"project_id",
1109+
"version_id",
1110+
"build_variant",
1111+
"parsed_order_id",
1112+
"task_name",
1113+
"task_id",
1114+
"execution",
1115+
"is_mainline",
1116+
]
1117+
cmds = [
1118+
get_subprocess_exec(
1119+
include_expansions_in_env=includes, args=[".evergreen/scripts/perf-submission-setup.sh"]
1120+
),
1121+
expansions_update(file="src/expansion.yml"),
1122+
get_subprocess_exec(
1123+
include_expansions_in_env=includes, args=[".evergreen/scripts/perf-submission.sh"]
1124+
),
1125+
]
1126+
return "send dashboard data", cmds
11081127

11091128

11101129
mod = sys.modules[__name__]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# We use the requester expansion to determine whether the data is from a mainline evergreen run or not
3+
4+
set -eu
5+
6+
# shellcheck disable=SC2154
7+
if [ "${requester}" == "commit" ]; then
8+
echo "is_mainline: true" >> expansion.yml
9+
else
10+
echo "is_mainline: false" >> expansion.yml
11+
fi
12+
13+
# We parse the username out of the order_id as patches append that in and SPS does not need that information
14+
# shellcheck disable=SC2154
15+
echo "parsed_order_id: $(echo "${revision_order_id}" | awk -F'_' '{print $NF}')" >> expansion.yml

.evergreen/scripts/perf-submission.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# We use the requester expansion to determine whether the data is from a mainline evergreen run or not
3+
4+
set -eu
5+
6+
# Submit the performance data to the SPS endpoint
7+
# shellcheck disable=SC2154
8+
response=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X 'POST' \
9+
"https://performance-monitoring-api.corp.mongodb.com/raw_perf_results/cedar_report?project=${project_id}&version=${version_id}&variant=${build_variant}&order=${parsed_order_id}&task_name=${task_name}&task_id=${task_id}&execution=${execution}&mainline=${is_mainline}" \
10+
-H 'accept: application/json' \
11+
-H 'Content-Type: application/json' \
12+
-d @results.json)
13+
14+
http_status=$(echo "$response" | grep "HTTP_STATUS" | awk -F':' '{print $2}')
15+
response_body=$(echo "$response" | sed '/HTTP_STATUS/d')
16+
17+
# We want to throw an error if the data was not successfully submitted
18+
if [ "$http_status" -ne 200 ]; then
19+
echo "Error: Received HTTP status $http_status"
20+
echo "Response Body: $response_body"
21+
exit 1
22+
fi
23+
24+
echo "Response Body: $response_body"
25+
echo "HTTP Status: $http_status"

test/performance/async_perf_test.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ async def asyncTearDown(self):
144144
},
145145
},
146146
"metrics": [
147-
{"name": "megabytes_per_sec", "type": "MEDIAN", "value": megabytes_per_sec},
147+
{
148+
"name": "megabytes_per_sec",
149+
"type": "MEDIAN",
150+
"value": megabytes_per_sec,
151+
"metadata": {
152+
"improvement_direction": "up",
153+
"measurement_unit": "megabytes_per_second",
154+
},
155+
},
148156
],
149157
}
150158
)

test/performance/perf_test.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ def tearDown(self):
151151
},
152152
},
153153
"metrics": [
154-
{"name": "megabytes_per_sec", "type": "MEDIAN", "value": megabytes_per_sec},
154+
{
155+
"name": "megabytes_per_sec",
156+
"type": "MEDIAN",
157+
"value": megabytes_per_sec,
158+
"metadata": {
159+
"improvement_direction": "up",
160+
"measurement_unit": "megabytes_per_second",
161+
},
162+
},
155163
],
156164
}
157165
)

0 commit comments

Comments
 (0)