perf: fix when running with TEST_OUTPUT_DIRECTORY
When the TEST_OUTPUT_DIRECTORY is defined, then all test data will be written in that directory instead of the default directory located in "t/". While this works as expected for our normal tests, performance tests fail to locate and aggregate performance data because they don't know to handle TEST_OUTPUT_DIRECTORY correctly and always look at the default location. Fix the issue by adding a `--results-dir` parameter to "aggregate.perl" which identifies the directory where results are and by making the "run" script awake of the TEST_OUTPUT_DIRECTORY variable. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jun 18, 2021 at 15:56 UTC
3663e5904d7c0060f3b51ffe7c7469caeefb51e5
3 files changed
+24
-13
t/perf/aggregate.perl
+3
-2
@@ -58,6 +58,7 @@ sub usage {
58
Options:
59
--codespeed * Format output for Codespeed
60
--reponame <str> * Send given reponame to codespeed
61
+ --results-dir <str> * Directory where test results are located
62
--sort-by <str> * Sort output (only "regression" criteria is supported)
63
--subsection <str> * Use results from given subsection
64
@@ -91,11 +92,13 @@ sub sane_backticks {
92
93
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
94
$codespeed, $sortby, $subsection, $reponame);
95
+my $resultsdir = "test-results";
96
97
Getopt::Long::Configure qw/ require_order /;
98
99
my $rc = GetOptions("codespeed" => \$codespeed,
100
"reponame=s" => \$reponame,
101
+ "results-dir=s" => \$resultsdir,
102
"sort-by=s" => \$sortby,
103
"subsection=s" => \$subsection);
104
usage() unless $rc;
@@ -137,8 +140,6 @@ if (not @tests) {
140
@tests = glob "p????-*.sh";
141
}
142
140
-my $resultsdir = "test-results";
141
-
143
if (! $subsection and
144
exists $ENV{GIT_PERF_SUBSECTION} and
145
$ENV{GIT_PERF_SUBSECTION} ne "") {
t/perf/perf-lib.sh
+5
-2
@@ -45,7 +45,7 @@ export TEST_DIRECTORY TRASH_DIRECTORY GIT_BUILD_DIR GIT_TEST_CMP
45
MODERN_GIT=$GIT_BUILD_DIR/bin-wrappers/git
46
export MODERN_GIT
47
48
-perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
48
+perf_results_dir=$TEST_RESULTS_DIR
49
test -n "$GIT_PERF_SUBSECTION" && perf_results_dir="$perf_results_dir/$GIT_PERF_SUBSECTION"
50
mkdir -p "$perf_results_dir"
51
rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests
@@ -253,7 +253,10 @@ test_size () {
253
# and does it after running everything)
254
test_at_end_hook_ () {
255
if test -z "$GIT_PERF_AGGREGATING_LATER"; then
256
- ( cd "$TEST_DIRECTORY"/perf && ./aggregate.perl $(basename "$0") )
256
+ (
257
+ cd "$TEST_DIRECTORY"/perf &&
258
+ ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
259
+ )
260
fi
261
}
262
t/perf/run
+16
-9
@@ -188,10 +188,10 @@ run_subsection () {
188
189
if test -z "$GIT_PERF_SEND_TO_CODESPEED"
190
then
191
- ./aggregate.perl $codespeed_opt "$@"
191
+ ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $codespeed_opt "$@"
192
else
193
- json_res_file="test-results/$GIT_PERF_SUBSECTION/aggregate.json"
194
- ./aggregate.perl --codespeed "$@" | tee "$json_res_file"
193
+ json_res_file=""$TEST_RESULTS_DIR"/$GIT_PERF_SUBSECTION/aggregate.json"
194
+ ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" --codespeed "$@" | tee "$json_res_file"
195
send_data_url="$GIT_PERF_SEND_TO_CODESPEED/result/add/json/"
196
curl -v --request POST --data-urlencode "json=$(cat "$json_res_file")" "$send_data_url"
197
fi
@@ -203,10 +203,17 @@ get_var_from_env_or_config "GIT_PERF_SEND_TO_CODESPEED" "perf" "sendToCodespeed"
203
cd "$(dirname $0)"
204
. ../../GIT-BUILD-OPTIONS
205
206
-mkdir -p test-results
207
-get_subsections "perf" >test-results/run_subsections.names
206
+if test -n "$TEST_OUTPUT_DIRECTORY"
207
+then
208
+ TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results"
209
+else
210
+ TEST_RESULTS_DIR=test-results
211
+fi
212
+
213
+mkdir -p "$TEST_RESULTS_DIR"
214
+get_subsections "perf" >"$TEST_RESULTS_DIR"/run_subsections.names
215
209
-if test $(wc -l <test-results/run_subsections.names) -eq 0
216
+if test $(wc -l <"$TEST_RESULTS_DIR"/run_subsections.names) -eq 0
217
then
218
if test -n "$GIT_PERF_SUBSECTION"
219
then
@@ -222,10 +229,10 @@ then
229
)
230
elif test -n "$GIT_PERF_SUBSECTION"
231
then
225
- egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names >/dev/null ||
232
+ egrep "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names >/dev/null ||
233
die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'"
234
228
- egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names | while read -r subsec
235
+ egrep "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names | while read -r subsec
236
do
237
(
238
GIT_PERF_SUBSECTION="$subsec"
@@ -243,5 +250,5 @@ else
250
echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
251
run_subsection "$@"
252
)
246
- done <test-results/run_subsections.names
253
+ done <"$TEST_RESULTS_DIR"/run_subsections.names
254
fi