11#! /bin/bash -xe
22
33tbname=$1
4-
5- run_pytest ()
6- {
7- tgname=$1
8- shift
9- tests=$@
10-
11- echo " run tests: $tests "
12-
13- mkdir -p logs/$tgname
14- for tn in ${tests} ; do
15- tdir=$( dirname $tn )
16- if [ $tdir != " ." ]; then
17- mkdir -p logs/$tgname /$tdir
18- mkdir -p results/$tgname /$tdir
19- fi
20- py.test $PYTEST_COMMON_OPTS --log-file logs/$tgname /$tn .log --junitxml=results/$tgname /$tn .xml $tn .py
21- done
22- }
4+ dut=$2
235
246cd $HOME
257mkdir -p .ssh
@@ -40,68 +22,59 @@ export ANSIBLE_LIBRARY=/data/sonic-mgmt/ansible/library/
4022# workaround for issue https://github.com/Azure/sonic-mgmt/issues/1659
4123export export ANSIBLE_KEEP_REMOTE_FILES=1
4224
43- PYTEST_COMMON_OPTS=" --inventory veos.vtb \
44- --host-pattern all \
45- --user admin \
46- -vvv \
47- --show-capture stdout \
48- --testbed $tbname \
49- --testbed_file vtestbed.csv \
50- --disable_loganalyzer \
51- --log-file-level debug"
25+ PYTEST_CLI_COMMON_OPTS=" \
26+ -i veos.vtb \
27+ -d $dut \
28+ -n $tbname \
29+ -f vtestbed.csv \
30+ -k debug \
31+ -l warning \
32+ -m group \
33+ -e --disable_loganalyzer
34+ "
5235
53- # Check testbed health
5436cd /data/sonic-mgmt/tests
55- rm -rf logs results
37+ rm -rf logs
5638mkdir -p logs
57- mkdir -p results
58- py.test $PYTEST_COMMON_OPTS --log-file logs/test_nbr_health.log --junitxml=results/tr.xml test_nbr_health.py
59-
60- # Run anounce route test case in order to populate BGP route
61- py.test $PYTEST_COMMON_OPTS --log-file logs/test_announce_routes.log --junitxml=results/tr.xml test_announce_routes.py
6239
63- # Tests to run using one vlan configuration
40+ # Run tests_1vlan on vlab-01 virtual switch
41+ # TODO: Use a marker to select these tests rather than providing a hard-coded list here.
6442tgname=1vlan
6543tests=" \
66- test_interfaces \
67- pc/test_po_update \
68- bgp/test_bgp_fact \
69- lldp/test_lldp \
70- route/test_default_route \
71- bgp/test_bgp_speaker \
72- bgp/test_bgp_gr_helper \
73- dhcp_relay/test_dhcp_relay \
74- syslog/test_syslog \
75- tacacs/test_rw_user \
76- tacacs/test_ro_user \
77- ntp/test_ntp \
78- cacl/test_cacl_application \
79- cacl/test_cacl_function \
80- telemetry/test_telemetry \
81- snmp/test_snmp_cpu \
82- snmp/test_snmp_interfaces \
83- snmp/test_snmp_lldp \
84- snmp/test_snmp_pfc_counters \
85- snmp/test_snmp_queue
86- "
44+ test_interfaces.py \
45+ bgp/test_bgp_fact.py \
46+ bgp/test_bgp_gr_helper.py \
47+ bgp/test_bgp_speaker.py \
48+ cacl/test_cacl_application.py \
49+ cacl/test_cacl_function.py \
50+ dhcp_relay/test_dhcp_relay.py \
51+ lldp/test_lldp.py \
52+ ntp/test_ntp.py \
53+ pc/test_po_update.py \
54+ route/test_default_route.py \
55+ snmp/test_snmp_cpu.py \
56+ snmp/test_snmp_interfaces.py \
57+ snmp/test_snmp_lldp.py \
58+ snmp/test_snmp_pfc_counters.py \
59+ snmp/test_snmp_queue.py \
60+ syslog/test_syslog.py \
61+ tacacs/test_rw_user.py \
62+ tacacs/test_ro_user.py \
63+ telemetry/test_telemetry.py"
8764
88- # Run tests_1vlan on vlab-01 virtual switch
8965pushd /data/sonic-mgmt/tests
90- run_pytest $tgname $tests
66+ ./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c " $tests " -p logs/ $tgname
9167popd
9268
9369# Create and deploy two vlan configuration (two_vlan_a) to the virtual switch
9470cd /data/sonic-mgmt/ansible
9571./testbed-cli.sh -m veos.vtb -t vtestbed.csv deploy-mg $tbname lab password.txt -e vlan_config=two_vlan_a
9672sleep 180
9773
98- # Tests to run using two vlan configuration
74+ # Run tests_2vlans on vlab-01 virtual switch
9975tgname=2vlans
100- tests=" \
101- dhcp_relay/test_dhcp_relay \
102- "
76+ tests=" dhcp_relay/test_dhcp_relay.py"
10377
104- # Run tests_2vlans on vlab-01 virtual switch
10578pushd /data/sonic-mgmt/tests
106- run_pytest $tgname $tests
79+ ./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c " $tests " -p logs/ $tgname
10780popd
0 commit comments