Upload perf test results to the CI database

This commit is contained in:
Alexander Kuzmenkov 2020-11-03 02:10:19 +03:00
parent f10a5207f4
commit a25996ed8d

View File

@ -1074,6 +1074,56 @@ wait
unset IFS
}
function upload_results
{
if ! [ -v CHPC_DATABASE_URL ]
then
echo Database for test results is not specified, will not upload them.
return 0
fi
# Surprisingly, clickhouse-client doesn't understand --host 127.0.0.1:9000
# so I have to do this instead. I tried to use Poco URI parser for this,
# but it's also broken and can't parse host:port.
IFS=':' read host port <<<"${CHPC_DATABASE_URL}"
upload_client=(clickhouse-client
--host "${host}"
--port "${port}"
--secure
--user "${CHPC_DATABASE_USER}"
--password "${CHPC_DATABASE_PASSWORD}"
--config "ch/tests/config/client_config.xml"
--database perftest
-m
--date_time_input_format=best_effort)
set +x # Don't show password in the log
cat "report/all-query-metrics.tsv" | "${upload_client[@]}" --query "
insert into query_metrics_tmp
select
toDate(event_time) event_date,
toDateTime('$(cd ch && git show -s --format=%ci "$SHA_TO_TEST" | cut -d' ' -f-2)') event_time,
$PR_TO_TEST pr_number,
'$REF_SHA' old_sha,
'$SHA_TO_TEST' new_sha,
test,
query_index,
query_display_name,
metric_name,
old_value,
new_value,
diff,
stat_threshold
from input('metric_name text, old_value float, new_value float, diff float,
ratio_display_text text, stat_threshold float,
test text, query_index int, query_display_name text')
settings date_time_input_format='best_effort'
format TSV
settings date_time_input_format='best_effort'"
set -x
}
# Check that local and client are in PATH
clickhouse-local --version > /dev/null
clickhouse-client --version > /dev/null
@ -1145,6 +1195,9 @@ case "$stage" in
time "$script_dir/report.py" --report=all-queries > all-queries.html 2> >(tee -a report/errors.log 1>&2) ||:
time "$script_dir/report.py" > report.html
;&
"upload_results")
time upload_results ||:
;&
esac
# Print some final debug info to help debug Weirdness, of which there is plenty.