From 0d6d95947236fe58020a7ecb23b5554f3d4b0b9d Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 8 Jul 2020 17:41:09 +0000 Subject: [PATCH 1/5] [run_test.sh] fix junit log path for in individual test function Signed-off-by: Ying Xie --- tests/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index bdc9f055735..93f2703ffcb 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -177,7 +177,7 @@ function run_individual_tests() if [[ ${test_dir} != "." ]]; then mkdir -p logs/${test_dir} fi - TEST_LOGGING_OPTIONS="--log-file logs/${test_dir}/${test_name}.log --junitxml=results/${test_dir}/${test_name}.xml" + TEST_LOGGING_OPTIONS="--log-file logs/${test_dir}/${test_name}.log --junitxml=logs/${test_dir}/${test_name}.xml" fi py.test ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${test_script} ${EXTRA_PARAMETERS} From a0d1ef71f29ffb3faf605c5203a0326341a4799b Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 8 Jul 2020 17:50:10 +0000 Subject: [PATCH 2/5] unify log path definition --- tests/run_tests.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 93f2703ffcb..a3e098b8690 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -53,6 +53,7 @@ function setup_environment() FULL_PATH=$(realpath ${SCRIPT}) SCRIPT_PATH=$(dirname ${FULL_PATH}) BASE_PATH=$(dirname ${SCRIPT_PATH}) + LOG_PATH="logs" BYPASS_UTIL="False" CLI_LOG_LEVEL='warning' @@ -88,18 +89,18 @@ function setup_test_options() PYTEST_COMMON_OPTS="${PYTEST_COMMON_OPTS} --ignore=${skip}" done - if [[ -d logs ]]; then - rm -rf logs + if [[ -d ${LOG_PATH} ]]; then + rm -rf ${LOG_PATH} fi if [[ x"${OMIT_FILE_LOG}" == x"True" ]]; then UTIL_LOGGING_OPTIONS="" TEST_LOGGING_OPTIONS="" else - mkdir logs + mkdir ${LOG_PATH} - UTIL_LOGGING_OPTIONS="--junit-xml=logs/util.xml --log-file=logs/util.log" - TEST_LOGGING_OPTIONS="--junit-xml=logs/tr.xml --log-file=logs/test.log" + UTIL_LOGGING_OPTIONS="--junit-xml=${LOG_PATH}/util.xml --log-file=${LOG_PATH}/util.log" + TEST_LOGGING_OPTIONS="--junit-xml=${LOG_PATH}/tr.xml --log-file=${LOG_PATH}/test.log" fi UTIL_TOPOLOGY_OPTIONS="--topology util" TEST_TOPOLOGY_OPTIONS="--topology ${TOPOLOGY}" @@ -175,9 +176,9 @@ function run_individual_tests() script_name=$(basename ${test_script}) test_name=${script_name%.py} if [[ ${test_dir} != "." ]]; then - mkdir -p logs/${test_dir} + mkdir -p ${LOG_PATH}/${test_dir} fi - TEST_LOGGING_OPTIONS="--log-file logs/${test_dir}/${test_name}.log --junitxml=logs/${test_dir}/${test_name}.xml" + TEST_LOGGING_OPTIONS="--log-file ${LOG_PATH}/${test_dir}/${test_name}.log --junitxml=${LOG_PATH}/${test_dir}/${test_name}.xml" fi py.test ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${test_script} ${EXTRA_PARAMETERS} @@ -186,7 +187,7 @@ function run_individual_tests() # If test passed, no need to keep its log. if [ ${ret_code} -eq 0 ]; then if [[ x"${OMIT_FILE_LOG}" != x"True" && x"${RETAIN_SUCCESS_LOG}" == x"False" ]]; then - rm -f logs/${test_dir}/${test_name}.log + rm -f ${LOG_PATH}/${test_dir}/${test_name}.log fi else EXIT_CODE=1 From fa4723507c88ef425750bf923d353e68d26207db Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 8 Jul 2020 17:54:53 +0000 Subject: [PATCH 3/5] add option to specify log path --- tests/run_tests.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index a3e098b8690..d5890537777 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -14,6 +14,7 @@ function show_help_and_exit() echo " -l : specify cli log level: error|warning|info|debug (default warning)" echo " -m : specify test method group|individual|debug (default group)" echo " -o : omit the file logs" + echo " -p : specify log path (default: logs)" echo " -n : specify testbed name (*)" echo " -r : retain individual file log for suceeded tests (default: remove)" echo " -s : specify list of scripts to skip (default: none)" @@ -121,6 +122,7 @@ function run_debug_tests() echo "EXTRA_PARAMETERS: ${EXTRA_PARAMETERS}" echo "FILE_LOG_LEVEL: ${FILE_LOG_LEVEL}" echo "INVENTORY: ${INVENTORY}" + echo "LOG_PATH: ${LOG_PATH}" echo "OMIT_FILE_LOG: ${OMIT_FILE_LOG}" echo "RETAIN_SUCCESS_LOG: ${RETAIN_SUCCESS_LOG}" echo "SKIP_SCRIPTS: ${SKIP_SCRIPTS}" @@ -200,7 +202,7 @@ function run_individual_tests() setup_environment -while getopts "h?c:d:e:f:i:k:l:m:n:ors:t:u" opt; do +while getopts "h?c:d:e:f:i:k:l:m:n:op:rs:t:u" opt; do case ${opt} in h|\? ) show_help_and_exit 0 @@ -235,6 +237,9 @@ while getopts "h?c:d:e:f:i:k:l:m:n:ors:t:u" opt; do o ) OMIT_FILE_LOG="True" ;; + p ) + LOG_PATH=${OPTARG} + ;; r ) RETAIN_SUCCESS_LOG="True" ;; From f49beaf44d9ea70154b3531c5425088c8ac1eca1 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 8 Jul 2020 17:56:43 +0000 Subject: [PATCH 4/5] make full path to log dir --- tests/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index d5890537777..4e408301e81 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -98,7 +98,7 @@ function setup_test_options() UTIL_LOGGING_OPTIONS="" TEST_LOGGING_OPTIONS="" else - mkdir ${LOG_PATH} + mkdir -p ${LOG_PATH} UTIL_LOGGING_OPTIONS="--junit-xml=${LOG_PATH}/util.xml --log-file=${LOG_PATH}/util.log" TEST_LOGGING_OPTIONS="--junit-xml=${LOG_PATH}/tr.xml --log-file=${LOG_PATH}/test.log" From 12ef7006e43a74c3f934b3f7d5aae24ebda835cb Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 8 Jul 2020 18:00:53 +0000 Subject: [PATCH 5/5] fix help information ordering --- tests/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 4e408301e81..f97f512dfce 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -13,9 +13,9 @@ function show_help_and_exit() echo " -k : specify file log level: error|warning|info|debug (default debug)" echo " -l : specify cli log level: error|warning|info|debug (default warning)" echo " -m : specify test method group|individual|debug (default group)" + echo " -n : specify testbed name (*)" echo " -o : omit the file logs" echo " -p : specify log path (default: logs)" - echo " -n : specify testbed name (*)" echo " -r : retain individual file log for suceeded tests (default: remove)" echo " -s : specify list of scripts to skip (default: none)" echo " -t : specify toplogy: t0|t1|any|combo like t0,any (*)"