diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /scripts/utils.sh | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'scripts/utils.sh')
-rw-r--r-- | scripts/utils.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/scripts/utils.sh b/scripts/utils.sh index d2e8c151438..faabc151963 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -60,7 +60,7 @@ function setup_db_user_only() { function setup_db() { run_timed_command "setup_db_user_only" - run_timed_command "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee" + run_timed_command_with_metric "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee" "setup_db" } function install_api_client_dependencies_with_apk() { @@ -78,15 +78,27 @@ function install_tff_gem() { function run_timed_command() { local cmd="${1}" + local metric_name="${2}" + local timed_metric_file local start=$(date +%s) + echosuccess "\$ ${cmd}" eval "${cmd}" + local ret=$? local end=$(date +%s) local runtime=$((end-start)) if [[ $ret -eq 0 ]]; then echosuccess "==> '${cmd}' succeeded in ${runtime} seconds." + + if [[ -n "${metric_name}" ]]; then + timed_metric_file=$(timed_metric_file $metric_name) + echo "# TYPE ${metric_name} gauge" > "${timed_metric_file}" + echo "# UNIT ${metric_name} seconds" >> "${timed_metric_file}" + echo "${metric_name} ${runtime}" >> "${timed_metric_file}" + fi + return 0 else echoerr "==> '${cmd}' failed (${ret}) in ${runtime} seconds." @@ -94,6 +106,26 @@ function run_timed_command() { fi } +function run_timed_command_with_metric() { + local cmd="${1}" + local metric_name="${2}" + local metrics_file=${METRICS_FILE:-metrics.txt} + + run_timed_command "${cmd}" "${metric_name}" + + local ret=$? + + cat $(timed_metric_file $metric_name) >> "${metrics_file}" + + return $ret +} + +function timed_metric_file() { + local metric_name="${1}" + + echo "$(pwd)/tmp/duration_${metric_name}.txt" +} + function echoerr() { local header="${2}" |