Skip to content

Commit b52807c

Browse files
authored
[kvm] Use run_tests.sh script in sonic-mgmt to run PR tests (sonic-net#139)
Signed-off-by: Danny Allen <[email protected]>
1 parent d3c45ad commit b52807c

8 files changed

Lines changed: 51 additions & 78 deletions

File tree

jenkins/mgmt/sonic-mgmt-canary/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ pipeline {
3939

4040
post {
4141
always {
42-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
43-
archiveArtifacts(artifacts: 'sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
42+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/logs/**/tr.xml')
43+
archiveArtifacts(artifacts: 'sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
4444
}
4545
}
4646
}

jenkins/mgmt/sonic-mgmt-pr/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pipeline {
3636

3737
post {
3838
always {
39-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
40-
archiveArtifacts(artifacts: 'sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
39+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/logs/**/tr.xml')
40+
archiveArtifacts(artifacts: 'sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
4141
}
4242
}
4343
}

jenkins/vs/buildimage-vs-image-201911-test/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ pipeline {
6767
post {
6868

6969
always {
70-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
71-
archiveArtifacts(artifacts: 'sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
70+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/logs/**/tr.xml')
71+
archiveArtifacts(artifacts: 'sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
7272
}
7373

7474
fixed {

jenkins/vs/buildimage-vs-image-pr/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ sudo cp ../target/sonic-vs.bin /nfs/jenkins/sonic-vs-${JOB_NAME##*/}.${BUILD_NUM
8787

8888
post {
8989
always {
90-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
91-
archiveArtifacts(artifacts: 'target/**, sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
90+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/logs/**/tr.xml')
91+
archiveArtifacts(artifacts: 'target/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
9292
}
9393
}
9494
}

jenkins/vs/buildimage-vs-image-test/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ pipeline {
6767
post {
6868

6969
always {
70-
archiveArtifacts(artifacts: 'sonic-mgmt/tests/logs/**, sonic-mgmt/tests/results/**, kvmdump/**, ptfdump/**')
71-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
70+
archiveArtifacts(artifacts: 'sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
71+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/logs/**/tr.xml')
7272
}
7373

7474
fixed {

jenkins/vs/buildimage-vs-image/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ sudo cp ../target/sonic-vs-dbg.bin /nfs/jenkins/sonic-vs-dbg-${JOB_NAME##*/}.${B
100100

101101
post {
102102
always {
103-
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
104-
archiveArtifacts(artifacts: 'target/**, sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
103+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/logs/**/tr.xml')
104+
archiveArtifacts(artifacts: 'target/**, sonic-mgmt/tests/logs/**, kvmdump/**, ptfdump/**')
105105
}
106106
}
107107

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
#!/bin/bash -xe
22

33
tbname=$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

246
cd $HOME
257
mkdir -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
4123
export 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
5436
cd /data/sonic-mgmt/tests
55-
rm -rf logs results
37+
rm -rf logs
5638
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
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.
6442
tgname=1vlan
6543
tests="\
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
8965
pushd /data/sonic-mgmt/tests
90-
run_pytest $tgname $tests
66+
./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c "$tests" -p logs/$tgname
9167
popd
9268

9369
# Create and deploy two vlan configuration (two_vlan_a) to the virtual switch
9470
cd /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
9672
sleep 180
9773

98-
# Tests to run using two vlan configuration
74+
# Run tests_2vlans on vlab-01 virtual switch
9975
tgname=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
10578
pushd /data/sonic-mgmt/tests
106-
run_pytest $tgname $tests
79+
./run_tests.sh $PYTEST_CLI_COMMON_OPTS -c "$tests" -p logs/$tgname
10780
popd

scripts/vs/buildimage-vs-image/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cd sonic-mgmt/ansible
2828
sed -i s:use_own_value:johnar: veos.vtb
2929
echo abc > password.txt
3030
cd ../../
31-
docker run --rm=true -v $(pwd):/data -w /data -i sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt ./scripts/vs/buildimage-vs-image/runtest.sh $tbname
31+
docker run --rm=true -v $(pwd):/data -w /data -i sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt ./scripts/vs/buildimage-vs-image/runtest.sh $tbname $dut
3232

3333
# save dut state if test fails
3434
if [ $? != 0 ]; then

0 commit comments

Comments
 (0)