Skip to content

Commit

Permalink
[kvmtest]: archive the log for each test (sonic-net#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
lguohan authored Apr 2, 2020
1 parent cc88316 commit 1eaca24
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 31 deletions.
3 changes: 2 additions & 1 deletion jenkins/vs/buildimage-vs-image-201911-test/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ pipeline {
post {

always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/tr*.xml')
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/tr*.xml')
archiveArtifacts(artifacts: 'sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**')
}

fixed {
Expand Down
4 changes: 2 additions & 2 deletions jenkins/vs/buildimage-vs-image-pr/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ mv target ../
post {

always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/tr*.xml')
archiveArtifacts(artifacts: 'target/**')
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/tr*.xml')
archiveArtifacts(artifacts: 'target/**, sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**')
}
}
}
3 changes: 2 additions & 1 deletion jenkins/vs/buildimage-vs-image-test/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ pipeline {
post {

always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/tr*.xml')
archiveArtifacts(artifacts: 'sonic-mgmt/tests/logs/**, sonic-mgmt/tests/results/**')
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/tr*.xml')
}

fixed {
Expand Down
4 changes: 2 additions & 2 deletions jenkins/vs/buildimage-vs-image/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ mv target ../
post {

always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/tr*.xml')
archiveArtifacts(artifacts: 'target/**')
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/tr*.xml')
archiveArtifacts(artifacts: 'target/**, sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**')
}

fixed {
Expand Down
80 changes: 55 additions & 25 deletions scripts/vs/buildimage-vs-image/runtest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#!/bin/bash -xe

run_pytest()
{
tgname=$1
shift
tests=$@

echo "run tests: $tests"

mkdir -p logs/$tgname
for tn in ${tests}; do
tdir=$(dirname $tn)
if [ $tdir != "." ]; then
mkdir -p logs/$tgname/$tdir
fi
py.test $PYTEST_COMMON_OPTS --log-file logs/$tgname/$tn.log --junitxml=results/tr_$tn-$tgname.xml $tn.py
done
}

cd $HOME
mkdir -p .ssh
cp /data/pkey.txt .ssh/id_rsa
Expand All @@ -16,47 +34,59 @@ sleep 180

export ANSIBLE_LIBRARY=/data/sonic-mgmt/ansible/library/

PYTEST_COMMON_OPTS="--inventory veos.vtb \
--host-pattern all \
--user admin \
-vvv \
--show-capture stdout \
--testbed vms-kvm-t0 \
--testbed_file vtestbed.csv \
--disable_loganalyzer"

# Check testbed health
cd /data/sonic-mgmt/tests
py.test --inventory veos.vtb --host-pattern all --user admin -vvv --show-capture stdout --testbed vms-kvm-t0 \
--testbed_file vtestbed.csv --disable_loganalyzer --junitxml=tr.xml test_nbr_health.py
mkdir -p logs
mkdir -p results
py.test $PYTEST_COMMON_OPTS --log-file logs/test_nbr_health.log --junitxml=results/tr.xml test_nbr_health.py

# Run anounce route test case in order to populate BGP route
py.test --inventory veos.vtb --host-pattern all --user admin -vvv --show-capture stdout --testbed vms-kvm-t0 \
--testbed_file vtestbed.csv --disable_loganalyzer --junitxml=tr.xml test_announce_routes.py
py.test $PYTEST_COMMON_OPTS --log-file logs/test_announce_routes.log --junitxml=results/tr.xml test_announce_routes.py

# Tests to run using one vlan configuration
tests_1vlan="\
test_interfaces.py \
test_bgp_fact.py \
test_lldp.py \
test_bgp_speaker.py \
test_dhcp_relay.py \
tacacs/test_rw_user.py \
tacacs/test_ro_user.py \
ntp/test_ntp.py \
snmp/test_snmp_cpu.py \
snmp/test_snmp_interfaces.py \
snmp/test_snmp_lldp.py \
snmp/test_snmp_pfc_counters.py \
snmp/test_snmp_queue.py
tgname=1vlan
tests="\
test_interfaces \
test_bgp_fact \
test_lldp \
test_bgp_speaker \
test_dhcp_relay \
tacacs/test_rw_user \
tacacs/test_ro_user \
ntp/test_ntp \
snmp/test_snmp_cpu \
snmp/test_snmp_interfaces \
snmp/test_snmp_lldp \
snmp/test_snmp_pfc_counters \
snmp/test_snmp_queue
"

# Run tests_1vlan on vlab-01 virtual switch
py.test --inventory veos.vtb --host-pattern all --user admin -vvv --show-capture stdout --testbed vms-kvm-t0 \
--testbed_file vtestbed.csv --disable_loganalyzer --junitxml=tr_1vlan.xml $tests_1vlan
pushd /data/sonic-mgmt/tests
run_pytest $tgname $tests
popd

# Create and deploy two vlan configuration (two_vlan_a) to the virtual switch
cd /data/sonic-mgmt/ansible
./testbed-cli.sh -m veos.vtb -t vtestbed.csv deploy-mg vms-kvm-t0 lab password.txt -e vlan_config=two_vlan_a
sleep 180

# Tests to run using two vlan configuration
tests_2vlans="\
test_dhcp_relay.py \
tgname=2vlans
tests="\
test_dhcp_relay \
"

cd /data/sonic-mgmt/tests
# Run tests_2vlans on vlab-01 virtual switch
py.test --inventory veos.vtb --host-pattern all --user admin -vvv --show-capture stdout --testbed vms-kvm-t0 \
--testbed_file vtestbed.csv --disable_loganalyzer --junitxml=tr_2vlans.xml $tests_2vlans
pushd /data/sonic-mgmt/tests
run_pytest $tgname $tests
popd

0 comments on commit 1eaca24

Please sign in to comment.