From 55e2f0955b97854d21f4853d12c1e5a843c215bb Mon Sep 17 00:00:00 2001 From: David Esparza Date: Tue, 18 Jul 2023 11:26:51 -0600 Subject: [PATCH] metrics: stop hypervirsor and shim at init_env stage This PR kills the hypervisor and the kata shim in the init_env stage prior to launch any metric test. Additionally this PR adds info messages in the main blocks of the blogbench test to help in debugging. Fixes: #7366 Signed-off-by: David Esparza --- tests/common.bash | 27 ++++++++++++++++++++++++++- tests/metrics/lib/common.bash | 1 + tests/metrics/storage/blogbench.sh | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/common.bash b/tests/common.bash index 6eaf39c5be..75598b24ec 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -181,7 +181,32 @@ function clean_env_ctr() count_tasks="$(sudo ctr t list -q | wc -l)" if (( count_tasks > 0 )); then - die "Can't remove running contaienrs." + die "Can't remove running containers." + fi + + kill_kata_components +} + +# Kills running shim and hypervisor components +function kill_kata_components() { + local kata_bin_dir="/opt/kata/bin" + local shim_path="${kata_bin_dir}/containerd-shim-kata-v2" + local hypervisor_path="${kata_bin_dir}/qemu-system-x86_64" + local pid_shim_count="$(pgrep -fc ${shim_path} || exit 0)" + + [ ${pid_shim_count} -gt "0" ] && sudo kill -SIGKILL "$(pgrep -f ${shim_path})" > /dev/null 2>&1 + + if [ "${KATA_HYPERVISOR}" = 'clh' ]; then + hypervisor_path="${kata_bin_dir}/cloud-hypervisor" + elif [ "${KATA_HYPERVISOR}" != 'qemu' ]; then + echo "Failed to stop the hypervisor: '${KATA_HYPERVISOR}' as it is not recognized" + return + fi + + local pid_hypervisor_count="$(pgrep -fc ${hypervisor_path} || exit 0)" + + if [ ${pid_hypervisor_count} -gt "0" ]; then + sudo kill -SIGKILL "$(pgrep -f ${hypervisor_path})" > /dev/null 2>&1 fi } diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index bd72dfc79b..c43019a709 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -178,6 +178,7 @@ function init_env() # This clean up is more aggressive, this is in order to # decrease the factors that could affect the metrics results. kill_processes_before_start + info "init environment complete" } # This function checks if there are containers or diff --git a/tests/metrics/storage/blogbench.sh b/tests/metrics/storage/blogbench.sh index 21e3a546d9..c5913f9315 100755 --- a/tests/metrics/storage/blogbench.sh +++ b/tests/metrics/storage/blogbench.sh @@ -39,6 +39,7 @@ function main() { sudo systemctl restart containerd metrics_json_init + info "Running Blogbench test" local output=$(sudo -E ${CTR_EXE} run --rm --runtime=${CTR_RUNTIME} ${IMAGE} test ${CMD}) # Save configuration @@ -66,6 +67,7 @@ EOF metrics_json_end_array "Config" # Save results + info "Saving Blogbench results" metrics_json_start_array local writes=$(tail -2 <<< "${output}" | head -1 | awk '{print $5}')