diff --git a/tests/common.bash b/tests/common.bash index 5f7443dc54..0fa0b1bdf1 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -298,23 +298,6 @@ function clean_env_ctr() fi } -# Kills running shim and hypervisor components -function kill_kata_components() { - local ATTEMPTS=2 - local TIMEOUT="30s" - local PID_NAMES=( "containerd-shim-kata-v2" "qemu-system-x86_64" "qemu-system-x86_64-tdx-experimental" "cloud-hypervisor" ) - - sudo systemctl stop containerd - # iterate over the list of kata components and stop them - for (( i=1; i<=ATTEMPTS; i++ )); do - for PID_NAME in "${PID_NAMES[@]}"; do - [[ ! -z "$(pidof ${PID_NAME})" ]] && sudo killall -w -s SIGKILL "${PID_NAME}" >/dev/null 2>&1 || true - done - sleep 1 - done - sudo timeout -s SIGKILL "${TIMEOUT}" systemctl start containerd -} - # Restarts a systemd service while ensuring the start-limit-burst is set to 0. # Outputs warnings to stdio if something has gone wrong. # @@ -601,7 +584,7 @@ function clone_cri_containerd() { # version: the version of the tarball that will be downloaded # tarball-name: the name of the tarball that will be downloaded function download_github_project_tarball() { - project="${1}" + project="${1}" version="${2}" tarball_name="${3}" @@ -731,7 +714,7 @@ OOMScoreAdjust=-999 [Install] WantedBy=multi-user.target EOF - fi + fi } # base_version: The version to be intalled in the ${major}.${minor} format diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index b5c58e9588..b06a84bb26 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -224,6 +224,23 @@ function kill_processes_before_start() kill_kata_components } +# Kills running shim and hypervisor components +function kill_kata_components() { + local ATTEMPTS=2 + local TIMEOUT="300s" + local PID_NAMES=( "containerd-shim-kata-v2" "qemu-system-x86_64" "qemu-system-x86_64-tdx-experimental" "cloud-hypervisor" ) + + sudo systemctl stop containerd + # iterate over the list of kata components and stop them + for (( i=1; i<=ATTEMPTS; i++ )); do + for PID_NAME in "${PID_NAMES[@]}"; do + [[ ! -z "$(pidof ${PID_NAME})" ]] && sudo killall -w -s SIGKILL "${PID_NAME}" >/dev/null 2>&1 || true + done + sleep 1 + done + sudo timeout -s SIGKILL "${TIMEOUT}" systemctl start containerd +} + # Generate a random name - generally used when creating containers, but can # be used for any other appropriate purpose function random_name() @@ -513,7 +530,7 @@ function get_current_kata_config_file() { current_config_file="${KATA_CONFIG_FNAME}" } -# This function checks if the current session is runnin as root, +# This function checks if the current session is runnin as root, # if that is not the case, the function exits with an error message. function check_if_root() { [ "$EUID" -ne 0 ] && die "Please run as root or use sudo."