11#! /bin/bash -xe
22
33tbname=$1
4- dut=$2
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+ }
523
624cd $HOME
725mkdir -p .ssh
@@ -22,59 +40,68 @@ export ANSIBLE_LIBRARY=/data/sonic-mgmt/ansible/library/
2240# workaround for issue https://github.com/Azure/sonic-mgmt/issues/1659
2341export export ANSIBLE_KEEP_REMOTE_FILES=1
2442
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- "
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"
3552
53+ # Check testbed health
3654cd /data/sonic-mgmt/tests
37- rm -rf logs
55+ rm -rf logs results
3856mkdir -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
3959
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.
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
62+
63+ # Tests to run using one vlan configuration
4264tgname=1vlan
4365tests=" \
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"
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+ "
6487
88+ # Run tests_1vlan on vlab-01 virtual switch
6589pushd /data/sonic-mgmt/tests
66- ./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c " $tests " -p logs/ $tgname
90+ run_pytest $tgname $tests
6791popd
6892
6993# Create and deploy two vlan configuration (two_vlan_a) to the virtual switch
7094cd /data/sonic-mgmt/ansible
7195./testbed-cli.sh -m veos.vtb -t vtestbed.csv deploy-mg $tbname lab password.txt -e vlan_config=two_vlan_a
7296sleep 180
7397
74- # Run tests_2vlans on vlab-01 virtual switch
98+ # Tests to run using two vlan configuration
7599tgname=2vlans
76- tests=" dhcp_relay/test_dhcp_relay.py"
100+ tests=" \
101+ dhcp_relay/test_dhcp_relay \
102+ "
77103
104+ # Run tests_2vlans on vlab-01 virtual switch
78105pushd /data/sonic-mgmt/tests
79- ./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c " $tests " -p logs/ $tgname
106+ run_pytest $tgname $tests
80107popd
0 commit comments