Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo " -e <paramters> : specify extra parameter(s) (default: none)"
echo " -e <parameters> : specify extra parameter(s) (default: none)"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed.

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)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention log vs. cli log level in the tag so it's more clear which is which at a glance?

Copy link
Copy Markdown
Collaborator Author

@yxieca yxieca Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed. didn't use full wording so that I don't have to move ':' indentation.

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"

Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 announce_routes or neighbor_health trigger a failure in the old/current PR tests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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()
Expand All @@ -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}"
Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
;;
Expand Down