From 1c84680d8c97339b8f18f701d00ad4efcdfe8650 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Thu, 10 Aug 2023 17:39:24 +0000 Subject: [PATCH] metrics: Add check containers are up in common script This PR adds check containers are up in common script for kata metrics. Signed-off-by: Gabriela Cervantes --- tests/metrics/lib/common.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index 14dabda38f..56da11417c 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -383,3 +383,17 @@ function collect_results() { echo -e "\n" } +function check_containers_are_up() { + local NUM_CONTAINERS="$1" + [[ -z ${NUM_CONTAINERS} ]] && die "Number of containers is missing" + + local TIMEOUT=60 + local containers_launched=0 + for i in $(seq "${TIMEOUT}") ; do + info "Verify that the containers are running" + containers_launched="$(sudo ${CTR_EXE} t list | grep -c "RUNNING")" + [ "${containers_launched}" -eq "${NUM_CONTAINERS}" ] && break + sleep 1 + [ "${i}" == "${TIMEOUT}" ] && return 1 + done +}