-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[multi-asic]: Add azure pipeline script to run kvm test (#3241)
Approach What is the motivation for this PR? Add azure pipeline script to bring up multi-asic testbed and run kvm tests. How did you do it? Add azure pipeline script : Bring up multi-asic KVM testbed with 201911 image as 201911 image is currently stable for multi-asic Deploy minigraph Run multi-asic KVM tests
- Loading branch information
1 parent
b4a6c2f
commit 541056c
Showing
1 changed file
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Starter pipeline | ||
|
||
# Start with a minimal pipeline that you can customize to build and deploy your code. | ||
|
||
# Add steps that build, run tests, deploy, and more: | ||
|
||
# https://aka.ms/yaml | ||
|
||
pr: | ||
- master | ||
|
||
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) | ||
|
||
parameters: | ||
- name: dut | ||
type: string | ||
default: vlab-08 | ||
- name: tbname | ||
type: string | ||
default: vms-kvm-four-asic-t1-lag | ||
- name: ptf_name | ||
type: string | ||
default: ptf_test | ||
- name: tbtype | ||
type: string | ||
default: multi-asic-t1-lag | ||
|
||
resources: | ||
repositories: | ||
- repository: sonic-mgmt | ||
type: github | ||
name: Azure/sonic-mgmt | ||
endpoint: build | ||
|
||
stages: | ||
- stage: Test | ||
pool: sonictest | ||
variables: | ||
- name: inventory | ||
value: veos_vtb | ||
- name: testbed_file | ||
value: vtestbed.csv | ||
- name: image_file_path | ||
value: https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-multiasic-vs-image-201911/lastSuccessfulBuild/artifact/target/sonic-vs.img.gz | ||
|
||
jobs: | ||
- job: four_asic_vs_test | ||
displayName: "kvmmultiasictest" | ||
timeoutInMinutes: 0 | ||
steps: | ||
|
||
- script: | | ||
sudo mkdir -p /data/sonic-vm/images | ||
wget $(image_file_path) | ||
sudo cp -v ./sonic-vs.img.gz /data/sonic-vm/images/sonic-vs.img.gz | ||
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 | ||
docker rm -f sonic-mgmt-masic || true | ||
./setup-container.sh -n sonic-mgmt-masic -d /data | ||
sed -i s/use_own_value/${username}/ ansible/veos_vtb | ||
echo aaa > ansible/password.txt | ||
parent_dir="/data/sonic-mgmt" | ||
docker exec sonic-mgmt-masic bash -c "pushd $parent_dir/ansible;./testbed-cli.sh -d /data/sonic-vm -m $(inventory) -t $(testbed_file) -k ceos refresh-dut ${{ parameters.tbname }} password.txt; ./testbed-cli.sh -m $(inventory) -t $(testbed_file) deploy-mg ${{ parameters.tbname }} veos_vtb password.txt" && sleep 180 | ||
displayName: "Setup t1-8-lag testbed" | ||
- script: | | ||
# Reboot dut to ensure services are up and stable. | ||
echo "Reboot DUT" | ||
sudo virsh reboot ${{ parameters.dut }} | ||
echo "sleep" | ||
sleep 120 | ||
username=$(id -un) | ||
rm -rf $(Build.ArtifactStagingDirectory)/* | ||
parent_dir="/data/sonic-mgmt" | ||
tests="test_interfaces.py \ | ||
bgp/test_bgp_fact.py \ | ||
lldp/test_lldp.py \ | ||
route/test_default_route.py \ | ||
snmp/test_snmp_pfc_counters.py \ | ||
snmp/test_snmp_queue.py \ | ||
snmp/test_snmp_loopback.py \ | ||
snmp/test_snmp_default_route.py \ | ||
tacacs/test_rw_user.py \ | ||
tacacs/test_ro_user.py \ | ||
tacacs/test_jit_user.py" | ||
CMD="cd $parent_dir/tests; \ | ||
export ANSIBLE_CONFIG=$parent_dir/ansible ANSIBLE_LIBRARY=$parent_dir/ansible; \ | ||
./run_tests.sh -c \"$tests\" -d ${{ parameters.dut }} -f $(testbed_file) -i $(inventory) -n ${{ parameters.tbname }} -e --disable_loganalyzer -u" | ||
echo $CMD | ||
docker exec sonic-mgmt-masic bash -c "$CMD" | ||
displayName: "multi-asic t1-lag tests" | ||
continueOnError: false | ||
- 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 | ||
virsh -c qemu:///system undefine ${{ parameters.dut }} | ||
fi | ||
displayName: "Collect kvmdump" | ||
condition: failed() | ||
- script: | | ||
docker ps | ||
pushd /data/sonic-mgmt | ||
cp -r ./tests/logs $(Build.ArtifactStagingDirectory)/ | ||
username=$(id -un) | ||
sudo chown -R $username.$username $(Build.ArtifactStagingDirectory) | ||
displayName: "Collect test logs" | ||
condition: succeededOrFailed() | ||
- publish: $(Build.ArtifactStagingDirectory)/kvmdump | ||
artifact: sonic-buildimage.kvmtest.$(tbtype).memdump@$(System.JobAttempt) | ||
displayName: "Archive sonic kvm memdump" | ||
condition: failed() | ||
|
||
- publish: $(Build.ArtifactStagingDirectory)/logs | ||
artifact: sonic-buildimage.kvmtest.$(tbtype).log@$(System.JobAttempt) | ||
displayName: "Archive sonic kvm logs" | ||
condition: succeededOrFailed() | ||
|
||
- task: PublishTestResults@2 | ||
inputs: | ||
testResultsFiles: '$(Build.ArtifactStagingDirectory)/logs/**/*.xml' | ||
testRunTitle: kvmtest.$(tbtype) | ||
condition: succeededOrFailed() |