Skip to content

Commit

Permalink
Add BSL test suite functionality to run_tests.sh (#16708)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
justin-wong-ce authored Feb 6, 2025
1 parent c102cb4 commit 8312485
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function show_help_and_exit()
echo " -h -? : get this help"
echo " -a <True|False>: specify if auto-recover is allowed (default: True)"
echo " -b <master_id> : specify name of k8s master group used in k8s inventory, format: k8s_vms{msetnumber}_{servernumber}"
echo " -B : run BSL test suite"
echo " -c <testcases> : specify test cases to execute (default: none, executed all matched)"
echo " -d <dut name> : specify comma-separated DUT names (default: DUT name associated with testbed in testbed file)"
echo " -e <parameters>: specify extra parameter(s) (default: none)"
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
}

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

0 comments on commit 8312485

Please sign in to comment.