1
1
#! /bin/bash -xe
2
2
3
3
tbname=$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
+ }
5
23
6
24
cd $HOME
7
25
mkdir -p .ssh
@@ -22,59 +40,68 @@ export ANSIBLE_LIBRARY=/data/sonic-mgmt/ansible/library/
22
40
# workaround for issue https://github.com/Azure/sonic-mgmt/issues/1659
23
41
export export ANSIBLE_KEEP_REMOTE_FILES=1
24
42
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"
35
52
53
+ # Check testbed health
36
54
cd /data/sonic-mgmt/tests
37
- rm -rf logs
55
+ rm -rf logs results
38
56
mkdir -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
39
59
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
42
64
tgname=1vlan
43
65
tests=" \
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
+ "
64
87
88
+ # Run tests_1vlan on vlab-01 virtual switch
65
89
pushd /data/sonic-mgmt/tests
66
- ./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c " $tests " -p logs/ $tgname
90
+ run_pytest $tgname $tests
67
91
popd
68
92
69
93
# Create and deploy two vlan configuration (two_vlan_a) to the virtual switch
70
94
cd /data/sonic-mgmt/ansible
71
95
./testbed-cli.sh -m veos.vtb -t vtestbed.csv deploy-mg $tbname lab password.txt -e vlan_config=two_vlan_a
72
96
sleep 180
73
97
74
- # Run tests_2vlans on vlab-01 virtual switch
98
+ # Tests to run using two vlan configuration
75
99
tgname=2vlans
76
- tests=" dhcp_relay/test_dhcp_relay.py"
100
+ tests=" \
101
+ dhcp_relay/test_dhcp_relay \
102
+ "
77
103
104
+ # Run tests_2vlans on vlab-01 virtual switch
78
105
pushd /data/sonic-mgmt/tests
79
- ./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c " $tests " -p logs/ $tgname
106
+ run_pytest $tgname $tests
80
107
popd
0 commit comments