[ci]: archive kvmtest artifacts (#6567)

- archive logs
- archive kvm memdump when failed
- publish kvm test results

Signed-off-by: Guohan Lu <lguohan@gmail.com>
This commit is contained in:
lguohan 2021-01-26 13:09:56 -08:00 committed by GitHub
parent 30ae46ea7f
commit a9a0e3062c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,19 +163,19 @@ stages:
pwd
username=$(id -un)
rm -rf $(Build.ArtifactStagingDirectory)/*
docker exec sonic-mgmt bash -c "/data/sonic-mgmt/tests/kvmtest.sh -en $(tbname) $(dut)"
# save dut state if test fails
if [ $? != 0 ]; then
virsh_version=$(virsh --version)
if [ $virsh_version == "6.0.0" ]; then
rm -rf kvmdump
mkdir -p kvmdump
mkdir -p $(Build.ArtifactStagingDirectory)/kvmdump
virsh -c qemu:///system list
virsh -c qemu:///system save $(dut) kvmdump/$(dut).memdmp
virsh -c qemu:///system dumpxml $(dut) > kvmdump/$(dut).xml
virsh -c qemu:///system save $(dut) $(Build.ArtifactStagingDirectory)/kvmdump/$(dut).memdmp
virsh -c qemu:///system dumpxml $(dut) > $(Build.ArtifactStagingDirectory)/kvmdump/$(dut).xml
img=$(virsh -c qemu:///system domblklist $(dut) | grep vda | awk '{print $2}')
cp $img kvmdump/$(dut).img
cp $img $(Build.ArtifactStagingDirectory)/kvmdump/$(dut).img
sudo chown -R $username.$username kvmdump
virsh -c qemu:///system undefine $(dut)
fi
@ -183,11 +183,28 @@ stages:
rm -rf ptfdump
mkdir -p ptfdump
docker commit $(ptf_name) docker-ptf:$(Build.BuildNumber)
docker save docker-ptf:$(Build.BuildNumber) | gzip -c > ptfdump/docker-ptf-dump.gz
docker save docker-ptf:$(Build.BuildNumber) | gzip -c > $(Build.ArtifactStagingDirectory)/kvmdump/docker-ptf-dump.gz
docker rmi docker-ptf:$(Build.BuildNumber)
cp -r /data/sonic-mgmt/tests/logs $(Build.ArtifactStagingDirectory)/
exit 2
else
sudo rm /nfs/azpl/kvmimage/sonic-vs.$(Build.BuildNumber).img.gz
cp -r /data/sonic-mgmt/tests/logs $(Build.ArtifactStagingDirectory)/
fi
displayName: "Run T0 tests"
- publish: $(Build.ArtifactStagingDirectory)/kvmdump
artifact: sonic-buildimage.kvmtest.memdump
displayName: "Archive sonic kvm memdump"
condition: failed()
- publish: $(Build.ArtifactStagingDirectory)/logs
artifact: sonic-buildimage.kvmtest.log
displayName: "Archive sonic kvm logs"
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testResultsFiles: '$(Build.ArtifactStagingDirectory)/logs/**/*.xml'
testRunTitle: kvmtest
condition: succeededOrFailed()