From 476a11194a8227e1a06ecdc805a8fa46601156bc Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Tue, 4 Jul 2023 16:11:54 +0000 Subject: [PATCH 1/8] tests: Enable memory usage metrics tests This PR enables the memory usage metrics tests for kata CI. Fixes #7229 Signed-off-by: Gabriela Cervantes --- tests/metrics/gha-run.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/metrics/gha-run.sh b/tests/metrics/gha-run.sh index a684c4f607..a2c531728d 100755 --- a/tests/metrics/gha-run.sh +++ b/tests/metrics/gha-run.sh @@ -116,8 +116,6 @@ function run_test_launchtimes() { function run_test_memory_usage() { info "Running memory-usage test using ${KATA_HYPERVISOR} hypervisor" - # ToDo: remove the exit once the metrics workflow is stable - exit 0 create_symbolic_links bash tests/metrics/density/memory_usage.sh 20 5 } From b9d66e0d530d042051f4089d35052d755e460924 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Tue, 4 Jul 2023 17:24:55 +0000 Subject: [PATCH 2/8] metrics: Fix double quotes variables in memory usage script This PR usses double quotes in all the variables as well as general fixes to the memory usage script in order to have uniformity. Signed-off-by: Gabriela Cervantes --- tests/metrics/density/memory_usage.sh | 133 +++++++++++++------------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/tests/metrics/density/memory_usage.sh b/tests/metrics/density/memory_usage.sh index 4551488450..a35d01e092 100755 --- a/tests/metrics/density/memory_usage.sh +++ b/tests/metrics/density/memory_usage.sh @@ -12,6 +12,7 @@ # This test uses smem tool to get the memory used. set -e +set -x SCRIPT_PATH=$(dirname "$(readlink -f "$0")") source "${SCRIPT_PATH}/../lib/common.bash" @@ -32,7 +33,7 @@ MEM_TMP_FILE=$(mktemp meminfo.XXXXXXXXXX) PS_TMP_FILE=$(mktemp psinfo.XXXXXXXXXX) function remove_tmp_file() { - rm -rf $MEM_TMP_FILE $PS_TMP_FILE + rm -rf "${MEM_TMP_FILE $PS_TMP_FILE}" } trap remove_tmp_file EXIT @@ -53,14 +54,14 @@ EOF get_runc_pss_memory(){ ctr_runc_shim_path="/usr/local/bin/containerd-shim-runc-v2" - get_pss_memory "$ctr_runc_shim_path" + get_pss_memory "${ctr_runc_shim_path}" } get_runc_individual_memory() { - runc_process_result=$(cat $MEM_TMP_FILE | tr "\n" " " | sed -e 's/\s$//g' | sed 's/ /, /g') + runc_process_result=$(cat "${MEM_TMP_FILE}" | tr "\n" " " | sed -e 's/\s$//g' | sed 's/ /, /g') # Verify runc process result - if [ -z "$runc_process_result" ];then + if [ -z "${runc_process_result}" ];then die "Runc process not found" fi @@ -71,7 +72,7 @@ get_runc_individual_memory() { local json="$(cat << EOF { "runc individual results": [ - $(for ((i=0;i<${NUM_CONTAINERS[@]};++i)); do + $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do printf '%s\n\t\t\t' "${runc_values[i]}" done) ] @@ -90,32 +91,32 @@ get_pss_memory(){ count=0 avg=0 - if [ -z "$ps" ]; then + if [ -z "${ps}" ]; then die "No argument to get_pss_memory()" fi # Save all the processes names # This will be help us to retrieve raw information - echo $ps >> $PS_TMP_FILE + echo "${ps}" >> "${PS_TMP_FILE}" - data=$(sudo "$SMEM_BIN" --no-header -P "^$ps" -c "pss" | sed 's/[[:space:]]//g') + data=$(sudo "${SMEM_BIN}" --no-header -P "^$ps" -c "pss" | sed 's/[[:space:]]//g') # Save all the smem results # This will help us to retrieve raw information - echo $data >> $MEM_TMP_FILE + echo "${data}" >> "${MEM_TMP_FILE}" - for i in $data;do + for i in "${data}"; do if (( i > 0 ));then mem_amount=$(( i + mem_amount )) (( count++ )) fi done - if (( $count > 0 ));then - avg=$(bc -l <<< "scale=2; $mem_amount / $count") + if (( "${count}" > 0 ));then + avg=$(bc -l <<< "scale=2; ${mem_amount} / ${count}") fi - echo "$avg" + echo "${avg}" } ppid() { @@ -140,26 +141,26 @@ get_pss_memory_virtiofsd() { die "virtiofsd_path not provided" fi - echo "${virtiofsd_path}" >> $PS_TMP_FILE + echo "${virtiofsd_path}" >> "${PS_TMP_FILE}" - virtiofsd_pids=$(ps aux | grep [v]irtiofsd | awk '{print $2}') + virtiofsd_pids=$(ps aux | grep virtiofsd | awk '{print $2}') data=$(sudo smem --no-header -P "^${virtiofsd_path}" -c pid -c "pid pss") - for p in ${virtiofsd_pids}; do - parent_pid=$(ppid ${p}) + for p in "${virtiofsd_pids}"; do + parent_pid=$(ppid "${p}") cmd="$(cat /proc/${p}/cmdline | tr -d '\0')" cmd_parent="$(cat /proc/${parent_pid}/cmdline | tr -d '\0')" if [ "${cmd}" != "${cmd_parent}" ]; then pss_parent=$(printf "%s" "${data}" | grep "\s^${p}" | awk '{print $2}') - fork=$(pgrep -P ${p}) + fork=$(pgrep -P "${p}") pss_fork=$(printf "%s" "${data}" | grep "^\s*${fork}" | awk '{print $2}') pss_process=$((pss_fork + pss_parent)) # Save all the smem results # This will help us to retrieve raw information - echo "${pss_process}" >>$MEM_TMP_FILE + echo "${pss_process}" >>"${MEM_TMP_FILE}" if ((pss_process > 0)); then mem_amount=$((pss_process + mem_amount)) @@ -168,22 +169,22 @@ get_pss_memory_virtiofsd() { fi done - if (( $count > 0 ));then - avg=$(bc -l <<< "scale=2; $mem_amount / $count") + if (( "${count}" > 0 ));then + avg=$(bc -l <<< "scale=2; ${mem_amount} / ${count}") fi echo "${avg}" } get_individual_memory(){ # Getting all the individual container information - first_process_name=$(cat $PS_TMP_FILE | awk 'NR==1' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') - first_process_result=$(cat $MEM_TMP_FILE | awk 'NR==1' | sed 's/ /, /g') + first_process_name=$(cat "${PS_TMP_FILE}" | awk 'NR==1' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') + first_process_result=$(cat "${MEM_TMP_FILE}" | awk 'NR==1' | sed 's/ /, /g') - second_process_name=$(cat $PS_TMP_FILE | awk 'NR==2' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') - second_process_result=$(cat $MEM_TMP_FILE | awk 'NR==2' | sed 's/ /, /g') + second_process_name=$(cat "${PS_TMP_FILE}" | awk 'NR==2' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') + second_process_result=$(cat "${MEM_TMP_FILE}" | awk 'NR==2' | sed 's/ /, /g') - third_process_name=$(cat $PS_TMP_FILE | awk 'NR==3' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') - third_process_result=$(cat $MEM_TMP_FILE | awk 'NR==3' | sed 's/ /, /g') + third_process_name=$(cat "${PS_TMP_FILE}" | awk 'NR==3' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') + third_process_result=$(cat "${MEM_TMP_FILE}" | awk 'NR==3' | sed 's/ /, /g') read -r -a first_values <<< "${first_process_result}" read -r -a second_values <<< "${second_process_result}" @@ -193,20 +194,20 @@ get_individual_memory(){ local json="$(cat << EOF { - "$first_process_name memory": [ - $(for ((i=0;i<${NUM_CONTAINERS[@]};++i)); do + "${first_process_name memory}": [ + $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do [ -n "${first_values[i]}" ] && printf '%s\n\t\t\t' "${first_values[i]}" done) ], - "$second_process_name memory": [ - $(for ((i=0;i<${NUM_CONTAINERS[@]};++i)); do + "${second_process_name memory}": [ + $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do [ -n "${second_values[i]}" ] && printf '%s\n\t\t\t' "${second_values[i]}" done) ], - "$third_process_name memory": [ - $(for ((i=0;i<${NUM_CONTAINERS[@]};++i)); do + "${third_process_name memory}": [ + $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do [ -n "${third_values[i]}" ] && printf '%s\n\t\t\t' "${third_values[i]}" done) @@ -227,40 +228,40 @@ get_docker_memory_usage(){ containers=() - for ((i=1; i<= NUM_CONTAINERS; i++)); do + for ((i=1; i<"${NUM_CONTAINERS[@]}"; i++)); do containers+=($(random_name)) - ${CTR_EXE} run --runtime "${CTR_RUNTIME}" -d ${IMAGE} ${containers[-1]} ${CMD} + sudo "${CTR_EXE}" run --runtime "${CTR_RUNTIME}" -d "${IMAGE}" "${containers[-1]}" "${CMD}" done - if [ "$AUTO_MODE" == "auto" ]; then + if [ "${AUTO_MODE}" == "auto" ]; then if (( ksm_on != 1 )); then die "KSM not enabled, cannot use auto mode" fi echo "Entering KSM settle auto detect mode..." - wait_ksm_settle $WAIT_TIME + wait_ksm_settle "${WAIT_TIME}" else # If KSM is enabled, then you normally want to sleep long enough to # let it do its work and for the numbers to 'settle'. - echo "napping $WAIT_TIME s" - sleep "$WAIT_TIME" + echo "napping ${WAIT_TIME} s" + sleep "${WAIT_TIME}" fi metrics_json_start_array # Check the runtime in order in order to determine which process will # be measured about PSS - if [ "$RUNTIME" == "runc" ]; then + if [ "${RUNTIME}" == "runc" ]; then runc_workload_mem="$(get_runc_pss_memory)" - memory_usage="$runc_workload_mem" + memory_usage="${runc_workload_mem}" local json="$(cat << EOF { "average": { - "Result": $memory_usage, + "Result": ${memory_usage}, "Units" : "KB" }, "runc": { - "Result": $runc_workload_mem, + "Result": ${runc_workload_mem}, "Units" : "KB" } } @@ -276,39 +277,39 @@ EOF # Now if you do not have enough rights # the smem failure to read the stats will also be trapped. - hypervisor_mem="$(get_pss_memory "$HYPERVISOR_PATH")" - if [ "$hypervisor_mem" == "0" ]; then - die "Failed to find PSS for $HYPERVISOR_PATH" + hypervisor_mem="$(get_pss_memory "${HYPERVISOR_PATH}")" + if [ "${hypervisor_mem}" == "0" ]; then + die "Failed to find PSS for ${HYPERVISOR_PATH}" fi - virtiofsd_mem="$(get_pss_memory_virtiofsd "$VIRTIOFSD_PATH")" - if [ "$virtiofsd_mem" == "0" ]; then - echo >&2 "WARNING: Failed to find PSS for $VIRTIOFSD_PATH" + virtiofsd_mem="$(get_pss_memory_virtiofsd "${VIRTIOFSD_PATH}")" + if [ "${virtiofsd_mem}" == "0" ]; then + echo >&2 "WARNING: Failed to find PSS for ${VIRTIOFSD_PATH}" fi - shim_mem="$(get_pss_memory "$SHIM_PATH")" - if [ "$shim_mem" == "0" ]; then - die "Failed to find PSS for $SHIM_PATH" + shim_mem="$(get_pss_memory "${SHIM_PATH}")" + if [ "${shim_mem}" == "0" ]; then + die "Failed to find PSS for ${SHIM_PATH}" fi - mem_usage="$(bc -l <<< "scale=2; $hypervisor_mem +$virtiofsd_mem + $shim_mem")" - memory_usage="$mem_usage" + mem_usage="$(bc -l <<< "scale=2; ${hypervisor_mem} +${virtiofsd_mem} + ${shim_mem}")" + memory_usage="${mem_usage}" local json="$(cat << EOF { "average": { - "Result": $mem_usage, + "Result": ${mem_usage}, "Units" : "KB" }, "qemus": { - "Result": $hypervisor_mem, + "Result": ${hypervisor_mem}, "Units" : "KB" }, "virtiofsds": { - "Result": $virtiofsd_mem, + "Result": ${virtiofsd_mem}, "Units" : "KB" }, "shims": { - "Result": $shim_mem, + "Result": ${shim_mem}, "Units" : "KB" } } @@ -327,12 +328,12 @@ save_config(){ local json="$(cat << EOF { - "containers": $NUM_CONTAINERS, - "ksm": $ksm_on, - "auto": "$AUTO_MODE", - "waittime": $WAIT_TIME, - "image": "$IMAGE", - "command": "$CMD" + "containers": "${NUM_CONTAINERS}", + "ksm": "${ksm_on}", + "auto": "${AUTO_MODE}", + "waittime": "${WAIT_TIME}", + "image": "${IMAGE}", + "command": "${CMD}" } EOF @@ -352,10 +353,12 @@ main(){ #Check for KSM before reporting test name, as it can modify it check_for_ksm + sudo systemctl restart containerd + init_env check_cmds "${SMEM_BIN}" bc - check_images "$IMAGE" + check_images "${IMAGE}" if [ "${CTR_RUNTIME}" == "io.containerd.kata.v2" ]; then export RUNTIME="kata-runtime" From d8f90e89d5e0075b11c1a7c8f8cef1b231e5e06c Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Tue, 4 Jul 2023 19:53:17 +0000 Subject: [PATCH 3/8] metrics: Rename function at memory usage script This PR renames the function name for the memory usage script. Signed-off-by: Gabriela Cervantes --- tests/metrics/density/memory_usage.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/metrics/density/memory_usage.sh b/tests/metrics/density/memory_usage.sh index a35d01e092..3a7f89d5fb 100755 --- a/tests/metrics/density/memory_usage.sh +++ b/tests/metrics/density/memory_usage.sh @@ -33,7 +33,7 @@ MEM_TMP_FILE=$(mktemp meminfo.XXXXXXXXXX) PS_TMP_FILE=$(mktemp psinfo.XXXXXXXXXX) function remove_tmp_file() { - rm -rf "${MEM_TMP_FILE $PS_TMP_FILE}" + rm -rf "${MEM_TMP_FILE}" "${PS_TMP_FILE}" } trap remove_tmp_file EXIT @@ -99,7 +99,7 @@ get_pss_memory(){ # This will be help us to retrieve raw information echo "${ps}" >> "${PS_TMP_FILE}" - data=$(sudo "${SMEM_BIN}" --no-header -P "^$ps" -c "pss" | sed 's/[[:space:]]//g') + data=$(sudo "${SMEM_BIN}" --no-header -P "^${ps}" -c "pss" | sed 's/[[:space:]]//g') # Save all the smem results # This will help us to retrieve raw information @@ -220,7 +220,7 @@ EOF } # Try to work out the 'average memory footprint' of a container. -get_docker_memory_usage(){ +get_memory_usage(){ hypervisor_mem=0 virtiofsd_mem=0 shim_mem=0 @@ -277,16 +277,16 @@ EOF # Now if you do not have enough rights # the smem failure to read the stats will also be trapped. - hypervisor_mem="$(get_pss_memory "${HYPERVISOR_PATH}")" + hypervisor_mem="$(get_pss_memory ${HYPERVISOR_PATH})" if [ "${hypervisor_mem}" == "0" ]; then die "Failed to find PSS for ${HYPERVISOR_PATH}" fi - virtiofsd_mem="$(get_pss_memory_virtiofsd "${VIRTIOFSD_PATH}")" + virtiofsd_mem="$(get_pss_memory_virtiofsd ${VIRTIOFSD_PATH})" if [ "${virtiofsd_mem}" == "0" ]; then echo >&2 "WARNING: Failed to find PSS for ${VIRTIOFSD_PATH}" fi - shim_mem="$(get_pss_memory "${SHIM_PATH}")" + shim_mem="$(get_pss_memory ${SHIM_PATH})" if [ "${shim_mem}" == "0" ]; then die "Failed to find PSS for ${SHIM_PATH}" fi @@ -353,8 +353,6 @@ main(){ #Check for KSM before reporting test name, as it can modify it check_for_ksm - sudo systemctl restart containerd - init_env check_cmds "${SMEM_BIN}" bc @@ -370,7 +368,7 @@ main(){ metrics_json_init save_config - get_docker_memory_usage + get_memory_usage if [ "$RUNTIME" == "runc" ]; then get_runc_individual_memory From 18968f428fdf2d9f919c0402eff402d1484a0804 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Tue, 4 Jul 2023 20:06:25 +0000 Subject: [PATCH 4/8] metrics: Add function to have uniformity This PR adds the function name before the function to have uniformity across all the test. Signed-off-by: Gabriela Cervantes --- tests/metrics/density/memory_usage.sh | 33 ++++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/metrics/density/memory_usage.sh b/tests/metrics/density/memory_usage.sh index 3a7f89d5fb..aadf5a7c26 100755 --- a/tests/metrics/density/memory_usage.sh +++ b/tests/metrics/density/memory_usage.sh @@ -39,7 +39,7 @@ function remove_tmp_file() { trap remove_tmp_file EXIT # Show help about this script -help(){ +function help(){ cat << EOF Usage: $0 [auto] Description: @@ -52,12 +52,12 @@ EOF } -get_runc_pss_memory(){ +function get_runc_pss_memory(){ ctr_runc_shim_path="/usr/local/bin/containerd-shim-runc-v2" get_pss_memory "${ctr_runc_shim_path}" } -get_runc_individual_memory() { +function get_runc_individual_memory() { runc_process_result=$(cat "${MEM_TMP_FILE}" | tr "\n" " " | sed -e 's/\s$//g' | sed 's/ /, /g') # Verify runc process result @@ -85,7 +85,7 @@ EOF # This function measures the PSS average # memory of a process. -get_pss_memory(){ +function get_pss_memory(){ ps="$1" mem_amount=0 count=0 @@ -106,7 +106,7 @@ get_pss_memory(){ echo "${data}" >> "${MEM_TMP_FILE}" for i in "${data}"; do - if (( i > 0 ));then + if (( $i > 0 ));then mem_amount=$(( i + mem_amount )) (( count++ )) fi @@ -119,7 +119,7 @@ get_pss_memory(){ echo "${avg}" } -ppid() { +function ppid() { local pid pid=$(ps -p "${1:-nopid}" -o ppid=) echo "${pid//[[:blank:]]/}" @@ -131,7 +131,7 @@ ppid() { # virtiofsd forks itself so, smem sees the process # two times, this function sum both pss values: # pss_virtiofsd=pss_fork + pss_parent -get_pss_memory_virtiofsd() { +function get_pss_memory_virtiofsd() { mem_amount=0 count=0 avg=0 @@ -175,7 +175,7 @@ get_pss_memory_virtiofsd() { echo "${avg}" } -get_individual_memory(){ +function get_individual_memory(){ # Getting all the individual container information first_process_name=$(cat "${PS_TMP_FILE}" | awk 'NR==1' | awk -F "/" '{print $NF}' | sed 's/[[:space:]]//g') first_process_result=$(cat "${MEM_TMP_FILE}" | awk 'NR==1' | sed 's/ /, /g') @@ -194,19 +194,19 @@ get_individual_memory(){ local json="$(cat << EOF { - "${first_process_name memory}": [ + "${first_process_name} memory": [ $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do [ -n "${first_values[i]}" ] && printf '%s\n\t\t\t' "${first_values[i]}" done) ], - "${second_process_name memory}": [ + "${second_process_name} memory": [ $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do [ -n "${second_values[i]}" ] && printf '%s\n\t\t\t' "${second_values[i]}" done) ], - "${third_process_name memory}": [ + "${third_process_name} memory": [ $(for ((i=0;i<"${NUM_CONTAINERS[@]}";++i)); do [ -n "${third_values[i]}" ] && printf '%s\n\t\t\t' "${third_values[i]}" @@ -220,7 +220,7 @@ EOF } # Try to work out the 'average memory footprint' of a container. -get_memory_usage(){ +function get_memory_usage(){ hypervisor_mem=0 virtiofsd_mem=0 shim_mem=0 @@ -228,9 +228,10 @@ get_memory_usage(){ containers=() - for ((i=1; i<"${NUM_CONTAINERS[@]}"; i++)); do + info "Creating ${NUM_CONTAINERS} containers" + for ((i=1; i<="${NUM_CONTAINERS}"; i++)); do containers+=($(random_name)) - sudo "${CTR_EXE}" run --runtime "${CTR_RUNTIME}" -d "${IMAGE}" "${containers[-1]}" "${CMD}" + sudo "${CTR_EXE}" run --runtime "${CTR_RUNTIME}" -d "${IMAGE}" "${containers[-1]}" sh -c "${CMD}" done if [ "${AUTO_MODE}" == "auto" ]; then @@ -323,7 +324,7 @@ EOF clean_env_ctr } -save_config(){ +function save_config(){ metrics_json_start_array local json="$(cat << EOF @@ -342,7 +343,7 @@ EOF metrics_json_end_array "Config" } -main(){ +function main(){ # Verify enough arguments if [ $# != 2 ] && [ $# != 3 ];then echo >&2 "error: Not enough arguments [$@]" From 1c3dbafbf0714acd7ea67c3aad7ac705d2376b76 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Wed, 5 Jul 2023 18:17:57 +0000 Subject: [PATCH 5/8] metrics: Fix function of how to retrieve multiple values This PR fixes the function of how to add multiple values of pss memory. Signed-off-by: Gabriela Cervantes --- tests/metrics/density/memory_usage.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/metrics/density/memory_usage.sh b/tests/metrics/density/memory_usage.sh index aadf5a7c26..b6cc827e3c 100755 --- a/tests/metrics/density/memory_usage.sh +++ b/tests/metrics/density/memory_usage.sh @@ -99,13 +99,14 @@ function get_pss_memory(){ # This will be help us to retrieve raw information echo "${ps}" >> "${PS_TMP_FILE}" - data=$(sudo "${SMEM_BIN}" --no-header -P "^${ps}" -c "pss" | sed 's/[[:space:]]//g') + data=$(sudo "${SMEM_BIN}" --no-header -P "^${ps}" -c "pss" | sed 's/[[:space:]]//g' | tr '\n' ' ' | sed 's/[[:blank:]]*$//') # Save all the smem results # This will help us to retrieve raw information echo "${data}" >> "${MEM_TMP_FILE}" - for i in "${data}"; do + gral_data=$(echo "${data// /+}" | bc) + for i in "${gral_data}"; do if (( $i > 0 ));then mem_amount=$(( i + mem_amount )) (( count++ )) @@ -143,7 +144,7 @@ function get_pss_memory_virtiofsd() { echo "${virtiofsd_path}" >> "${PS_TMP_FILE}" - virtiofsd_pids=$(ps aux | grep virtiofsd | awk '{print $2}') + virtiofsd_pids=$(ps aux | grep [v]irtiofsd | awk '{print $2}' | head -1) data=$(sudo smem --no-header -P "^${virtiofsd_path}" -c pid -c "pid pss") for p in "${virtiofsd_pids}"; do From 78086ed1feff71be7c13f4f6fbeaa0df198f5bc0 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Wed, 5 Jul 2023 19:19:04 +0000 Subject: [PATCH 6/8] checkmetrics: Add memory usage value for clh This PR adds the memory usage value for clh. Signed-off-by: Gabriela Cervantes --- .../checkmetrics-json-clh-kata-metric8.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml index 7966b69eb9..9c593320d2 100644 --- a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml +++ b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml @@ -19,3 +19,17 @@ checktype = "mean" midval = 0.42 minpercent = 15.0 maxpercent = 15.0 + +[[metric]] +name = "memory-footprint" +type = "json" +description = "measure memory usage" +# Min and Max values to set a 'range' that +# the median of the CSV Results data must fall +# within (inclusive) +checkvar = ".\"memory-footprint\".Results | .[] | .average.Result" +checktype = "mean" +midval = 2518364.00 +minpercent = 15.0 +maxpercent = 15.0 + From 5a61065ab73f84c4dc08006613301af41d4f7f52 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Wed, 5 Jul 2023 19:21:03 +0000 Subject: [PATCH 7/8] checkmetrics: Add checkmetrics value for memory usage in qemu This PR adds the checkmetrics value for memory usage in qemu. Signed-off-by: Gabriela Cervantes --- .../checkmetrics-json-clh-kata-metric8.toml | 1 - .../checkmetrics-json-qemu-kata-metric8.toml | 13 +++++++++++++ tests/metrics/density/memory_usage.sh | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml index 9c593320d2..4ac4f5cf71 100644 --- a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml +++ b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml @@ -32,4 +32,3 @@ checktype = "mean" midval = 2518364.00 minpercent = 15.0 maxpercent = 15.0 - diff --git a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml index c243ed2c52..102f7d34dc 100644 --- a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml +++ b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml @@ -19,3 +19,16 @@ checktype = "mean" midval = 0.61 minpercent = 15.0 maxpercent = 15.0 + +[[metric]] +name = "memory-footprint" +type = "json" +description = "measure memory usage" +# Min and Max values to set a 'range' that +# the median of the CSV Results data must fall +# within (inclusive) +checkvar = ".\"memory-footprint\".Results | .[] | .average.Result" +checktype = "mean" +midval = 2435844.00 +minpercent = 15.0 +maxpercent = 15.0 diff --git a/tests/metrics/density/memory_usage.sh b/tests/metrics/density/memory_usage.sh index b6cc827e3c..57d2ce3cdd 100755 --- a/tests/metrics/density/memory_usage.sh +++ b/tests/metrics/density/memory_usage.sh @@ -12,7 +12,6 @@ # This test uses smem tool to get the memory used. set -e -set -x SCRIPT_PATH=$(dirname "$(readlink -f "$0")") source "${SCRIPT_PATH}/../lib/common.bash" From 6acce83e12ca049d489b5ad51a8fd78455696221 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Wed, 5 Jul 2023 19:27:24 +0000 Subject: [PATCH 8/8] metrics: Fix the call to check_metrics function This PR fixes the call to check_metrics function as KATA_HYPERVISOR is not needed to be passed. Signed-off-by: Gabriela Cervantes --- .../ci_worker/checkmetrics-json-clh-kata-metric8.toml | 8 ++++---- .../ci_worker/checkmetrics-json-qemu-kata-metric8.toml | 8 ++++---- tests/metrics/gha-run.sh | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml index 4ac4f5cf71..562b2c83b1 100644 --- a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml +++ b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-clh-kata-metric8.toml @@ -17,8 +17,8 @@ description = "measure container lifecycle timings" checkvar = ".\"boot-times\".Results | .[] | .\"to-workload\".Result" checktype = "mean" midval = 0.42 -minpercent = 15.0 -maxpercent = 15.0 +minpercent = 20.0 +maxpercent = 20.0 [[metric]] name = "memory-footprint" @@ -30,5 +30,5 @@ description = "measure memory usage" checkvar = ".\"memory-footprint\".Results | .[] | .average.Result" checktype = "mean" midval = 2518364.00 -minpercent = 15.0 -maxpercent = 15.0 +minpercent = 20.0 +maxpercent = 20.0 diff --git a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml index 102f7d34dc..c6bc851471 100644 --- a/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml +++ b/tests/metrics/cmd/checkmetrics/ci_worker/checkmetrics-json-qemu-kata-metric8.toml @@ -17,8 +17,8 @@ description = "measure container lifecycle timings" checkvar = ".\"boot-times\".Results | .[] | .\"to-workload\".Result" checktype = "mean" midval = 0.61 -minpercent = 15.0 -maxpercent = 15.0 +minpercent = 20.0 +maxpercent = 20.0 [[metric]] name = "memory-footprint" @@ -30,5 +30,5 @@ description = "measure memory usage" checkvar = ".\"memory-footprint\".Results | .[] | .average.Result" checktype = "mean" midval = 2435844.00 -minpercent = 15.0 -maxpercent = 15.0 +minpercent = 20.0 +maxpercent = 20.0 diff --git a/tests/metrics/gha-run.sh b/tests/metrics/gha-run.sh index a2c531728d..14317211ee 100755 --- a/tests/metrics/gha-run.sh +++ b/tests/metrics/gha-run.sh @@ -95,7 +95,6 @@ function check_containerd_config_for_kata() { } function check_metrics() { - KATA_HYPERVISOR="${1}" local cm_base_file="${checkmetrics_config_dir}/checkmetrics-json-${KATA_HYPERVISOR}-kata-metric8.toml" checkmetrics --debug --percentage --basefile "${cm_base_file}" --metricsdir "${results_dir}" cm_result=$? @@ -109,8 +108,6 @@ function run_test_launchtimes() { create_symbolic_links bash tests/metrics/time/launch_times.sh -i public.ecr.aws/ubuntu/ubuntu:latest -n 20 - - check_metrics "${KATA_HYPERVISOR}" } function run_test_memory_usage() { @@ -118,6 +115,8 @@ function run_test_memory_usage() { create_symbolic_links bash tests/metrics/density/memory_usage.sh 20 5 + + check_metrics } function run_test_memory_usage_inside_container() {