-
Notifications
You must be signed in to change notification settings - Fork 1k
[run_test.sh] add maxfail option and improve help information #2013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,20 +5,21 @@ function show_help_and_exit() | |
| echo "Usage ${SCRIPT} [options]" | ||
| echo " options with (*) must be provided" | ||
| echo " -h -? : get this help" | ||
| echo " -c : specify test cases to execute (default: none, executed all matched)" | ||
| echo " -d : specify DUT name (*)" | ||
| echo " -e : specify extra parameter(s) (default: none)" | ||
| echo " -f : specify testbed file (default testbed.csv)" | ||
| echo " -i : specify inventory name" | ||
| 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 " -c <testcases> : specify test cases to execute (default: none, executed all matched)" | ||
| echo " -d <dut name> : specify DUT name (*)" | ||
| echo " -e <paramters> : specify extra parameter(s) (default: none)" | ||
| echo " -f <tb file> : specify testbed file (default testbed.csv)" | ||
| echo " -i <inventory> : specify inventory name" | ||
| echo " -k <log level> : specify file log level: error|warning|info|debug (default debug)" | ||
| echo " -l <log level> : specify cli log level: error|warning|info|debug (default warning)" | ||
|
||
| echo " -m <method> : specify test method group|individual|debug (default group)" | ||
| echo " -n <testbed> : specify testbed name (*)" | ||
| echo " -o : omit the file logs" | ||
| echo " -p : specify log path (default: logs)" | ||
| echo " -p <path> : specify log path (default: logs)" | ||
| echo " -q <n> : test will stop after <n> failures (default: not stop on failure)" | ||
| 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 (*)" | ||
| echo " -s <tests> : specify list of tests to skip (default: none)" | ||
| echo " -t <topology> : specify toplogy: t0|t1|any|combo like t0,any (*)" | ||
| echo " -u : bypass util group" | ||
| echo " -x : print commands and their arguments as they are executed" | ||
|
|
||
|
|
@@ -69,6 +70,7 @@ function setup_environment() | |
| TESTBED_FILE="${BASE_PATH}/ansible/testbed.csv" | ||
| TEST_CASES="" | ||
| TEST_METHOD='group' | ||
| TEST_MAX_FAIL=0 | ||
|
|
||
| export ANSIBLE_CONFIG=${BASE_PATH}/ansible | ||
| export ANSIBLE_LIBRARY=${BASE_PATH}/ansible/library/ | ||
|
|
@@ -113,6 +115,12 @@ function setup_test_options() | |
| else | ||
| TEST_TOPOLOGY_OPTIONS="--topology ${TOPOLOGY}" | ||
| fi | ||
|
|
||
| PYTEST_UTIL_OPTS=${PYTEST_COMMON_OPTS} | ||
| # Max failure only applicable to the test session. Not the preparation and cleanup session. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lguohan I can't remember off the top of my head - would a failure in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a minor detail we can come back to later. I'll merge this PR so that you can work on your next change. |
||
| if [[ ${TEST_MAX_FAIL} != 0 ]]; then | ||
| PYTEST_COMMON_OPTS="${PYTEST_COMMON_OPTS} --maxfail=${TEST_MAX_FAIL}" | ||
| fi | ||
| } | ||
|
|
||
| function run_debug_tests() | ||
|
|
@@ -136,6 +144,7 @@ function run_debug_tests() | |
| echo "SKIP_SCRIPTS: ${SKIP_SCRIPTS}" | ||
| echo "SKIP_FOLDERS: ${SKIP_FOLDERS}" | ||
| echo "TEST_CASES: ${TEST_CASES}" | ||
| echo "TEST_MAX_FAIL: ${TEST_MAX_FAIL}" | ||
| echo "TEST_METHOD: ${TEST_METHOD}" | ||
| echo "TESTBED_FILE: ${TESTBED_FILE}" | ||
| echo "TEST_LOGGING_OPTIONS: ${TEST_LOGGING_OPTIONS}" | ||
|
|
@@ -150,7 +159,7 @@ function run_debug_tests() | |
| function prepare_dut() | ||
| { | ||
| echo "=== Preparing DUT for subsequent tests ===" | ||
| py.test ${PYTEST_COMMON_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} -m pretest | ||
| py.test ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} -m pretest | ||
|
|
||
| # Give some delay for the newly announced routes to propagate. | ||
| sleep 120 | ||
|
|
@@ -159,7 +168,7 @@ function prepare_dut() | |
| function cleanup_dut() | ||
| { | ||
| echo "=== Cleaning up DUT after tests ===" | ||
| py.test ${PYTEST_COMMON_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} -m posttest | ||
| py.test ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} -m posttest | ||
| } | ||
|
|
||
| function run_group_tests() | ||
|
|
@@ -205,6 +214,9 @@ function run_individual_tests() | |
| fi | ||
| else | ||
| EXIT_CODE=1 | ||
| if [[ ${TEST_MAX_FAIL} != 0 ]]; then | ||
| return ${EXIT_CODE} | ||
| fi | ||
| fi | ||
|
|
||
| done | ||
|
|
@@ -214,7 +226,7 @@ function run_individual_tests() | |
|
|
||
| setup_environment | ||
|
|
||
| while getopts "h?c:d:e:f:i:k:l:m:n:op:rs:t:ux" opt; do | ||
| while getopts "h?c:d:e:f:i:k:l:m:n:op:q:rs:t:ux" opt; do | ||
| case ${opt} in | ||
| h|\? ) | ||
| show_help_and_exit 0 | ||
|
|
@@ -252,6 +264,9 @@ while getopts "h?c:d:e:f:i:k:l:m:n:op:rs:t:ux" opt; do | |
| p ) | ||
| LOG_PATH=${OPTARG} | ||
| ;; | ||
| q ) | ||
| TEST_MAX_FAIL=${OPTARG} | ||
| ;; | ||
| r ) | ||
| RETAIN_SUCCESS_LOG="True" | ||
| ;; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed.