From fc893927454aa6b0b541cba93f286a26cf8a9f12 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Thu, 10 Aug 2023 17:44:36 +0000 Subject: [PATCH] metrics: Add check containers are up in tensorflow mobilenet script This PR adds the check containers are up in the common script in the tensorflow mobilenet script. Signed-off-by: Gabriela Cervantes (cherry picked from commit 918c783084d7b775789f8a725892dd88feffccf0) --- tests/metrics/lib/common.bash | 10 +++++----- .../tensorflow_mobilenet_v1_bfloat16_fp32.sh | 15 ++------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index 56da11417c..a715ea035d 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -363,18 +363,18 @@ function wait_ksm_settle() } function collect_results() { - WORKLOAD=${1} - [[ -z ${WORKLOAD} ]] && die "Container workload is missing" + local WORKLOAD="$1" + [[ -z "${WORKLOAD}" ]] && die "Container workload is missing" local tasks_running=("${containers[@]}") local retries=100 while [ "${#tasks_running[@]}" -gt 0 ] && [ "${retries}" -gt 0 ]; do for i in "${!tasks_running[@]}"; do - check_file=$(sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${tasks_running[i]}" sh > + check_file=$(sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${tasks_running[i]}" sh -c "${WORKLOAD}") # if the current task is done, remove the corresponding container from the active list - [ "${check_file}" -eq "1" ] && unset 'tasks_running[i]' + [ "${check_file}" = 1 ] && unset 'tasks_running[i]' done ((retries--)) sleep 3 @@ -385,7 +385,7 @@ function collect_results() { function check_containers_are_up() { local NUM_CONTAINERS="$1" - [[ -z ${NUM_CONTAINERS} ]] && die "Number of containers is missing" + [[ -z "${NUM_CONTAINERS}" ]] && die "Number of containers is missing" local TIMEOUT=60 local containers_launched=0 diff --git a/tests/metrics/machine_learning/tensorflow_mobilenet_v1_bfloat16_fp32.sh b/tests/metrics/machine_learning/tensorflow_mobilenet_v1_bfloat16_fp32.sh index e48f75a5a8..aaacc86a4d 100755 --- a/tests/metrics/machine_learning/tensorflow_mobilenet_v1_bfloat16_fp32.sh +++ b/tests/metrics/machine_learning/tensorflow_mobilenet_v1_bfloat16_fp32.sh @@ -109,17 +109,6 @@ EOF metrics_json_end_array "Results" } -function check_containers_are_up() { - 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 -} - function main() { # Verify enough arguments if [ $# != 2 ]; then @@ -153,11 +142,11 @@ function main() { metrics_json_start_array # Check that the requested number of containers are running - check_containers_are_up + check_containers_are_up "${NUM_CONTAINERS}" # Check that the requested number of containers are running local timeout_launch="10" - check_containers_are_up & pid=$! + check_containers_are_up "${NUM_CONTAINERS}" & pid=$! (sleep "${timeout_launch}" && kill -HUP "${pid}") 2>/dev/null & pid_tout=$! if wait "${pid}" 2>/dev/null; then