From 47c6f259af048f6f46d36ad8a35c00747292c329 Mon Sep 17 00:00:00 2001 From: Justin Wong <51811017+justin-wong-ce@users.noreply.github.com> Date: Thu, 6 Feb 2025 00:49:14 -0800 Subject: [PATCH] Add BSL test suite functionality to run_tests.sh (#16708) What is the motivation for this PR? Allow easier execution of BSL tests How did you do it? Add an option for BSL tests in tests/run_tests.sh How did you verify/test it? Attempting a BSL run - the option works. --- tests/run_tests.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 35e801676ee..aa26e2cd5fb 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -7,6 +7,7 @@ function show_help_and_exit() echo " -h -? : get this help" echo " -a : specify if auto-recover is allowed (default: True)" echo " -b : specify name of k8s master group used in k8s inventory, format: k8s_vms{msetnumber}_{servernumber}" + echo " -B : run BSL test suite" echo " -c : specify test cases to execute (default: none, executed all matched)" echo " -d : specify comma-separated DUT names (default: DUT name associated with testbed in testbed file)" echo " -e : specify extra parameter(s) (default: none)" @@ -96,6 +97,7 @@ function setup_environment() AUTO_RECOVER="True" BYPASS_UTIL="False" + BSL="False" CLI_LOG_LEVEL='warning' EXTRA_PARAMETERS="" FILE_LOG_LEVEL='debug' @@ -246,6 +248,7 @@ function run_debug_tests() echo "ANSIBLE_CONFIG: ${ANSIBLE_CONFIG}" echo "ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY}" echo "AUTO_RECOVER: ${AUTO_RECOVER}" + echo "BSL: ${BSL}" echo "BYPASS_UTIL: ${BYPASS_UTIL}" echo "CLI_LOG_LEVEL: ${CLI_LOG_LEVEL}" echo "EXTRA_PARAMETERS: ${EXTRA_PARAMETERS}" @@ -281,6 +284,9 @@ function pre_post_extra_params() # It aims to verify common test cases work as expected under macsec links. # At pre/post test stage, enabling macsec only wastes time and is not needed. params=${params//--enable_macsec/} + if [[ x"${BSL}" == x"True" ]]; then + params="${params} --ignore=bgp --skip_sanity" + fi echo $params } @@ -360,10 +366,17 @@ function run_individual_tests() return ${EXIT_CODE} } +function run_bsl_tests() +{ + echo "=== Running BSL tests ===" + echo Running: python3 -m pytest ${PYTEST_COMMON_OPTS} --skip_sanity --disable_loganalyzer --junit-xml=logs/bsl.xml --log-file logs/bsl.log -m bsl + python3 -m pytest ${PYTEST_COMMON_OPTS} --skip_sanity --disable_loganalyzer --junit-xml=logs/bsl.xml --log-file logs/bsl.log -m bsl +} + setup_environment -while getopts "h?a:b:c:C:d:e:Ef:F:i:I:k:l:m:n:oOp:q:rs:S:t:ux" opt; do +while getopts "h?a:b:Bc:C:d:e:Ef:F:i:I:k:l:m:n:oOp:q:rs:S:t:ux" opt; do case ${opt} in h|\? ) show_help_and_exit 0 @@ -375,6 +388,9 @@ while getopts "h?a:b:c:C:d:e:Ef:F:i:I:k:l:m:n:oOp:q:rs:S:t:ux" opt; do KUBE_MASTER_ID=${OPTARG} SKIP_FOLDERS=${SKIP_FOLDERS//k8s/} ;; + B ) + BSL="True" + ;; c ) TEST_CASES="${TEST_CASES} ${OPTARG}" ;; @@ -469,7 +485,12 @@ if [[ x"${TEST_METHOD}" != x"debug" && x"${BYPASS_UTIL}" == x"False" ]]; then fi RC=0 -run_${TEST_METHOD}_tests || RC=$? + +if [[ x"${BSL}" == x"True" ]]; then + run_bsl_tests || RC=$? +else + run_${TEST_METHOD}_tests || RC=$? +fi if [[ x"${TEST_METHOD}" != x"debug" && x"${BYPASS_UTIL}" == x"False" ]]; then cleanup_dut