From 6b6a6ee724ed2de952c5ab6fdb7e09cf9e5f2f74 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Thu, 10 Aug 2023 17:27:11 +0000 Subject: [PATCH] metrics: Add common functions to the common script This PR adds the collect results function to the common metrics script. Fixes #7617 Signed-off-by: Gabriela Cervantes (cherry picked from commit 9879709aae781440dc2a4624fe0a501208e6aee7) --- tests/metrics/lib/common.bash | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index 4111d67d40..14dabda38f 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -361,3 +361,25 @@ function wait_ksm_settle() done info "Timed out after ${1}s waiting for KSM to settle" } + +function collect_results() { + WORKLOAD=${1} + [[ -z ${WORKLOAD} ]] && die "Container workload is missing" + + local tasks_running=("${containers[@]}") + local retries=100 + + while [ "${#tasks_running[@]}" -gt 0 ] && [ "${retries}" -gt 0 ]; do + for i in "${!tasks_running[@]}"; do + check_file=$(sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${tasks_running[i]}" sh > + + # if the current task is done, remove the corresponding container from the active list + [ "${check_file}" -eq "1" ] && unset 'tasks_running[i]' + done + ((retries--)) + sleep 3 + echo -n "." + done + echo -e "\n" +} +