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 <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2023-08-10 17:39:24 +00:00
parent d3e57cf454
commit 1c84680d8c

View File

@ -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
}