From 1e640ec3a61abaae9093065bed8626edeb642a7c Mon Sep 17 00:00:00 2001 From: David Esparza Date: Thu, 1 Aug 2024 17:05:03 -0600 Subject: [PATCH 1/2] metrics: fix pargins json results file. This PR encloses the search string for 'default_vcpus =' and 'default_memory =' with double quotes in order to parse the precise values, which are included in the kata configuration file. Fixes: #10118 Signed-off-by: David Esparza --- tests/common.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/common.bash b/tests/common.bash index 5401571f2e..ba44fd89cd 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -179,8 +179,8 @@ function extract_kata_env() { # get the requested memory and num of vcpus from the kata config file. config_content="$(cat ${RUNTIME_CONFIG_PATH} | grep -vE "^#")" - REQ_MEMORY="$(echo "${config_content}" | grep -i default_memory | cut -d "=" -f2 | awk '{print $1}')" - REQ_NUM_VCPUS="$(echo "${config_content}" | grep -i default_vcpus | cut -d "=" -f2 | awk '{print $1}')" + REQ_MEMORY="$(echo "${config_content}" | grep -i 'default_memory =' | cut -d "=" -f2 | awk '{print $1}')" + REQ_NUM_VCPUS="$(echo "${config_content}" | grep -i 'default_vcpus =' | cut -d "=" -f2 | awk '{print $1}')" # Shimv2 path is being affected by https://github.com/kata-containers/kata-containers/issues/1151 SHIM_PATH=$(command -v containerd-shim-kata-v2) @@ -188,7 +188,10 @@ function extract_kata_env() { SHIM_VERSION=${RUNTIME_VERSION} - HYPERVISOR_PATH=$(sudo ${cmd} env --json | jq -r ${hypervisor_path}) + HYPERVISOR_PATH=$(echo "${kata_env}" | jq -r ${hypervisor_path}) + VIRTIOFSD_PATH=$(echo "${kata_env}" | jq -r ${virtio_fs_daemon_path}) + INITRD_PATH=$(echo "${kata_env}" | jq -r ${initrd_path}) + # TODO: there is no ${cmd} of rust version currently if [ "${KATA_HYPERVISOR}" != "dragonball" ]; then if [ "${KATA_HYPERVISOR}" = "stratovirt" ]; then @@ -197,9 +200,6 @@ function extract_kata_env() { HYPERVISOR_VERSION=$(sudo -E ${HYPERVISOR_PATH} --version | head -n1) fi fi - VIRTIOFSD_PATH=$(sudo ${cmd} env --json | jq -r ${virtio_fs_daemon_path}) - - INITRD_PATH=$(sudo ${cmd} env --json | jq -r ${initrd_path}) } # Checks that processes are not running From dcd0c0b2697a02aace08b373a283723138eae807 Mon Sep 17 00:00:00 2001 From: David Esparza Date: Thu, 1 Aug 2024 17:47:44 -0600 Subject: [PATCH 2/2] metrics: Remove duplicated headers from results file. This PR removes duplicated entries (vcpus count, and available memory), from onednn and openvino results files. Fixes: #10119 Signed-off-by: David Esparza --- tests/metrics/machine_learning/onednn.sh | 9 --------- tests/metrics/machine_learning/openvino.sh | 9 --------- 2 files changed, 18 deletions(-) diff --git a/tests/metrics/machine_learning/onednn.sh b/tests/metrics/machine_learning/onednn.sh index 399807707b..166c9121b7 100755 --- a/tests/metrics/machine_learning/onednn.sh +++ b/tests/metrics/machine_learning/onednn.sh @@ -49,20 +49,11 @@ EOF function save_config() { metrics_json_start_array - pushd "${DEFAULT_KATA_CONFIG_DIR}" - local MEM_AVAIL_MB="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep -i "default_memory =" | cut -d "=" -f2 | tr -d ' ' | tr -d '"')" - local NUM_CPUS="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep -i "default_vcpus =" | cut -d "=" -f2 | tr -d ' ' | tr -d '"')" - local SHARED_FS="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep shared_fs | cut -d "=" -f2 | tr -d ' ' | tr -d '"')" - popd - local json="$(cat << EOF { "image": "${IMAGE}", "units": "ms", "mode": "Lower Is Better", - "shared-fs": "${SHARED_FS}", - "num-vcpus": "${NUM_CPUS}", - "memory-available-mb": "${MEM_AVAIL_MB}" } EOF )" diff --git a/tests/metrics/machine_learning/openvino.sh b/tests/metrics/machine_learning/openvino.sh index d2fd3a9064..f1cd87c991 100755 --- a/tests/metrics/machine_learning/openvino.sh +++ b/tests/metrics/machine_learning/openvino.sh @@ -49,20 +49,11 @@ EOF function save_config() { metrics_json_start_array - pushd "${DEFAULT_KATA_CONFIG_DIR}" - local MEM_AVAIL_MB="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep -i "default_memory =" | cut -d "=" -f2 | tr -d ' ' | tr -d '"')" - local NUM_CPUS="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep -i "default_vcpus =" | cut -d "=" -f2 | tr -d ' ' | tr -d '"')" - local SHARED_FS="$(cat ${DEFAULT_KATA_CONFIG_FNAME} | grep shared_fs | cut -d "=" -f2 | tr -d ' ' | tr -d '"')" - popd - local json="$(cat << EOF { "image": "${IMAGE}", "units": "ms", "mode": "Lower Is Better", - "shared-fs": "${SHARED_FS}", - "num-vcpus": "${NUM_CPUS}", - "memory-available-mb": "${MEM_AVAIL_MB}" } EOF )"