2021-01-31 21:47:10 -06:00
|
|
|
parameters:
|
|
|
|
- name: dut
|
|
|
|
type: string
|
|
|
|
- name: tbname
|
|
|
|
type: string
|
|
|
|
- name: tbtype
|
|
|
|
type: string
|
|
|
|
- name: ptf_name
|
|
|
|
type: string
|
2022-05-12 00:21:25 -05:00
|
|
|
- name: vmtype
|
|
|
|
type: string
|
|
|
|
default: 'ceos'
|
2022-02-23 20:20:24 -06:00
|
|
|
- name: section
|
|
|
|
type: string
|
|
|
|
default: ''
|
2021-09-24 13:14:43 -05:00
|
|
|
- name: image
|
|
|
|
type: string
|
|
|
|
default: sonic-vs.img.gz
|
|
|
|
values:
|
|
|
|
- sonic-vs.img.gz
|
|
|
|
- sonic-4asic-vs.img.gz
|
|
|
|
- sonic-6asic-vs.img.gz
|
2021-01-31 21:47:10 -06:00
|
|
|
|
|
|
|
steps:
|
2022-10-20 00:06:10 -05:00
|
|
|
- template: cleanup.yml
|
2021-01-31 21:47:10 -06:00
|
|
|
- checkout: self
|
|
|
|
clean: true
|
|
|
|
displayName: 'checkout sonic-mgmt repo'
|
|
|
|
|
2022-10-25 02:45:01 -05:00
|
|
|
- script: |
|
|
|
|
sudo rm -rf ../target
|
|
|
|
displayName: "Cleanup"
|
|
|
|
|
2021-01-31 21:47:10 -06:00
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
2021-02-12 01:34:05 -06:00
|
|
|
artifact: sonic-buildimage.vs
|
|
|
|
displayName: "Download sonic-buildimage.vs artifact"
|
2021-01-31 21:47:10 -06:00
|
|
|
|
|
|
|
- script: |
|
|
|
|
set -x
|
|
|
|
sudo mkdir -p /data/sonic-vm/images
|
2021-09-24 13:14:43 -05:00
|
|
|
sudo cp -v ../target/${{ parameters.image}} /data/sonic-vm/images/sonic-vs.img.gz
|
2021-01-31 21:47:10 -06:00
|
|
|
sudo gzip -fd /data/sonic-vm/images/sonic-vs.img.gz
|
|
|
|
username=$(id -un)
|
|
|
|
sudo chown -R $username.$username /data/sonic-vm
|
|
|
|
|
|
|
|
pushd /data/sonic-mgmt
|
|
|
|
git remote update
|
|
|
|
git reset --hard origin/master
|
|
|
|
sed -i s/use_own_value/${username}/ ansible/veos_vtb
|
|
|
|
echo aaa > ansible/password.txt
|
2022-05-12 00:21:25 -05:00
|
|
|
docker exec sonic-mgmt bash -c "pushd /data/sonic-mgmt/ansible;./testbed-cli.sh -d /data/sonic-vm -m $(inventory) -t $(testbed_file) -k ${{ parameters.vmtype }} refresh-dut ${{ parameters.tbname }} password.txt" && sleep 180
|
2021-01-31 21:47:10 -06:00
|
|
|
displayName: "Setup testbed"
|
|
|
|
|
|
|
|
- script: |
|
|
|
|
rm -rf $(Build.ArtifactStagingDirectory)/*
|
2022-02-23 20:20:24 -06:00
|
|
|
docker exec sonic-mgmt bash -c "/data/sonic-mgmt/tests/kvmtest.sh -en -T ${{ parameters.tbtype }} ${{ parameters.tbname }} ${{ parameters.dut }} ${{ parameters.section }}"
|
2021-01-31 21:47:10 -06:00
|
|
|
displayName: "Run tests"
|
|
|
|
- script: |
|
|
|
|
# save dut state if test fails
|
|
|
|
virsh_version=$(virsh --version)
|
|
|
|
if [ $virsh_version == "6.0.0" ]; then
|
|
|
|
mkdir -p $(Build.ArtifactStagingDirectory)/kvmdump
|
|
|
|
virsh -c qemu:///system list
|
|
|
|
virsh -c qemu:///system save ${{ parameters.dut }} $(Build.ArtifactStagingDirectory)/kvmdump/${{ parameters.dut }}.memdmp
|
|
|
|
virsh -c qemu:///system dumpxml ${{ parameters.dut }} > $(Build.ArtifactStagingDirectory)/kvmdump/${{ parameters.dut }}.xml
|
|
|
|
img=$(virsh -c qemu:///system domblklist ${{ parameters.dut }} | grep vda | awk '{print $2}')
|
|
|
|
cp $img $(Build.ArtifactStagingDirectory)/kvmdump/${{ parameters.dut }}.img
|
2021-03-25 12:15:21 -05:00
|
|
|
gzip $(Build.ArtifactStagingDirectory)/kvmdump/${{ parameters.dut }}.img
|
|
|
|
sudo gzip $(Build.ArtifactStagingDirectory)/kvmdump/${{ parameters.dut }}.memdmp
|
2021-01-31 21:47:10 -06:00
|
|
|
virsh -c qemu:///system undefine ${{ parameters.dut }}
|
|
|
|
fi
|
|
|
|
|
|
|
|
docker commit ${{ parameters.ptf_name }} docker-ptf:$(Build.BuildNumber)
|
|
|
|
docker save docker-ptf:$(Build.BuildNumber) | gzip -c > $(Build.ArtifactStagingDirectory)/kvmdump/docker-ptf-dump.gz
|
|
|
|
docker rmi docker-ptf:$(Build.BuildNumber)
|
|
|
|
displayName: "Collect kvmdump"
|
|
|
|
condition: failed()
|
|
|
|
|
|
|
|
- script: |
|
|
|
|
cp -r /data/sonic-mgmt/tests/logs $(Build.ArtifactStagingDirectory)/
|
|
|
|
username=$(id -un)
|
|
|
|
sudo chown -R $username.$username $(Build.ArtifactStagingDirectory)
|
|
|
|
displayName: "Collect test logs"
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
|
|
|
|
- publish: $(Build.ArtifactStagingDirectory)/kvmdump
|
2022-02-23 20:20:24 -06:00
|
|
|
artifact: sonic-buildimage.kvmtest.${{ parameters.tbtype}}${{ parameters.section }}.memdump@$(System.JobAttempt)
|
2021-01-31 21:47:10 -06:00
|
|
|
displayName: "Archive sonic kvm memdump"
|
|
|
|
condition: failed()
|
|
|
|
|
|
|
|
- publish: $(Build.ArtifactStagingDirectory)/logs
|
2022-02-23 20:20:24 -06:00
|
|
|
artifact: sonic-buildimage.kvmtest.${{ parameters.tbtype }}${{ parameters.section }}.log@$(System.JobAttempt)
|
2021-01-31 21:47:10 -06:00
|
|
|
displayName: "Archive sonic kvm logs"
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
|
|
|
|
- task: PublishTestResults@2
|
|
|
|
inputs:
|
|
|
|
testResultsFiles: '$(Build.ArtifactStagingDirectory)/logs/**/*.xml'
|
2022-02-23 20:20:24 -06:00
|
|
|
testRunTitle: kvmtest.${{ parameters.tbtype }}${{ parameters.section }}
|
2021-01-31 21:47:10 -06:00
|
|
|
condition: succeededOrFailed()
|