2020-11-26 06:18:25 -06:00
|
|
|
# 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
|
|
|
|
|
|
|
|
trigger:
|
2021-01-26 17:42:04 -06:00
|
|
|
branches:
|
|
|
|
include:
|
|
|
|
- master
|
|
|
|
- 202012
|
2020-11-26 06:18:25 -06:00
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
pr:
|
|
|
|
- master
|
2020-11-26 06:18:25 -06:00
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
|
2020-11-26 06:18:25 -06:00
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
resources:
|
|
|
|
repositories:
|
|
|
|
- repository: sonic-mgmt
|
|
|
|
type: github
|
|
|
|
name: Azure/sonic-mgmt
|
|
|
|
endpoint: build
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- stage: Build
|
|
|
|
pool: sonicbld
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
- job:
|
|
|
|
displayName: "broadcom"
|
2021-01-12 08:01:59 -06:00
|
|
|
timeoutInMinutes: 600
|
2021-01-07 21:50:11 -06:00
|
|
|
steps:
|
|
|
|
- checkout: self
|
2021-01-30 16:19:41 -06:00
|
|
|
clean: true
|
2021-01-07 21:50:11 -06:00
|
|
|
submodules: recursive
|
|
|
|
displayName: 'Checkout code'
|
2021-01-29 10:53:57 -06:00
|
|
|
- script: |
|
|
|
|
git submodule foreach --recursive git clean -xfdf
|
|
|
|
git submodule foreach --recursive git reset --hard
|
|
|
|
git submodule update --init --recursive
|
|
|
|
displayName: 'reset submodules'
|
2021-01-07 21:50:11 -06:00
|
|
|
- script: |
|
|
|
|
sudo modprobe overlay
|
|
|
|
CACHE_OPTIONS="SONIC_DPKG_CACHE_METHOD=rcache SONIC_DPKG_CACHE_SOURCE=/nfs/dpkg_cache/broadcom"
|
|
|
|
ENABLE_DOCKER_BASE_PULL=y make configure PLATFORM=broadcom
|
2021-01-13 12:30:49 -06:00
|
|
|
trap "sudo rm -rf fsroot" EXIT
|
2021-01-24 19:31:47 -06:00
|
|
|
make USERNAME=admin SONIC_BUILD_JOBS=$(nproc) $CACHE_OPTIONS target/sonic-broadcom.bin && \
|
|
|
|
ENABLE_SYNCD_RPC=y make USERNAME=admin SONIC_BUILD_JOBS=$(nproc) $CACHE_OPTIONS target/docker-syncd-brcm-rpc.gz
|
2021-01-07 21:50:11 -06:00
|
|
|
displayName: 'Build sonic image'
|
|
|
|
- publish: $(System.DefaultWorkingDirectory)/
|
|
|
|
artifact: sonic-buildimage.broadcom
|
|
|
|
displayName: "Archive sonic image"
|
|
|
|
|
2021-01-12 08:01:59 -06:00
|
|
|
- job:
|
|
|
|
displayName: "mellanox"
|
|
|
|
timeoutInMinutes: 600
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
2021-01-30 16:19:41 -06:00
|
|
|
clean: true
|
2021-01-12 08:01:59 -06:00
|
|
|
submodules: recursive
|
|
|
|
displayName: 'Checkout code'
|
|
|
|
|
2021-01-29 10:53:57 -06:00
|
|
|
- script: |
|
|
|
|
git submodule foreach --recursive git clean -xfdf
|
|
|
|
git submodule foreach --recursive git reset --hard
|
|
|
|
git submodule update --init --recursive
|
|
|
|
displayName: 'reset submodules'
|
2021-01-12 08:01:59 -06:00
|
|
|
- script: |
|
|
|
|
sudo modprobe overlay
|
|
|
|
CACHE_OPTIONS="SONIC_DPKG_CACHE_METHOD=rcache SONIC_DPKG_CACHE_SOURCE=/nfs/dpkg_cache/mellanox"
|
|
|
|
ENABLE_DOCKER_BASE_PULL=y make configure PLATFORM=mellanox
|
2021-01-13 12:30:49 -06:00
|
|
|
trap "sudo rm -rf fsroot" EXIT
|
2021-01-24 19:31:47 -06:00
|
|
|
make USERNAME=admin SONIC_BUILD_JOBS=$(nproc) $CACHE_OPTIONS target/sonic-mellanox.bin && \
|
|
|
|
ENABLE_SYNCD_RPC=y make USERNAME=admin SONIC_BUILD_JOBS=$(nproc) $CACHE_OPTIONS target/docker-syncd-mlnx-rpc.gz
|
2021-01-12 08:01:59 -06:00
|
|
|
displayName: 'Build sonic image'
|
|
|
|
- publish: $(System.DefaultWorkingDirectory)/
|
|
|
|
artifact: sonic-buildimage.mellanox
|
|
|
|
displayName: "Archive sonic image"
|
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
- job:
|
|
|
|
displayName: "kvm"
|
2021-01-12 08:01:59 -06:00
|
|
|
timeoutInMinutes: 600
|
2021-01-07 21:50:11 -06:00
|
|
|
steps:
|
|
|
|
- checkout: self
|
2021-01-30 16:19:41 -06:00
|
|
|
clean: true
|
2021-01-07 21:50:11 -06:00
|
|
|
submodules: recursive
|
|
|
|
displayName: 'Checkout code'
|
|
|
|
|
2021-01-29 10:53:57 -06:00
|
|
|
- script: |
|
|
|
|
git submodule foreach --recursive git clean -xfdf
|
|
|
|
git submodule foreach --recursive git reset --hard
|
|
|
|
git submodule update --init --recursive
|
|
|
|
displayName: 'reset submodules'
|
2021-01-07 21:50:11 -06:00
|
|
|
- script: |
|
|
|
|
echo $(Build.BuildNumber)
|
|
|
|
sudo modprobe overlay
|
|
|
|
CACHE_OPTIONS="SONIC_DPKG_CACHE_METHOD=rcache SONIC_DPKG_CACHE_SOURCE=/nfs/dpkg_cache/vs"
|
|
|
|
ENABLE_DOCKER_BASE_PULL=y make configure PLATFORM=vs
|
2021-01-13 12:30:49 -06:00
|
|
|
trap "sudo rm -rf fsroot" EXIT
|
2021-01-19 11:35:19 -06:00
|
|
|
make USERNAME=admin SONIC_BUILD_JOBS=$(nproc) $CACHE_OPTIONS \
|
2021-01-27 21:58:58 -06:00
|
|
|
target/docker-sonic-vs.gz target/sonic-vs.img.gz target/docker-ptf.gz
|
2021-01-07 21:50:11 -06:00
|
|
|
displayName: 'Build sonic image'
|
|
|
|
- publish: $(System.DefaultWorkingDirectory)/
|
|
|
|
artifact: sonic-buildimage.kvm
|
|
|
|
displayName: "Archive sonic image"
|
|
|
|
|
|
|
|
- stage: Test
|
|
|
|
pool: sonictest
|
|
|
|
variables:
|
|
|
|
- name: dut
|
|
|
|
value: vlab-01
|
|
|
|
- name: tbname
|
|
|
|
value: vms-kvm-t0
|
|
|
|
- name: inventory
|
|
|
|
value: veos_vtb
|
|
|
|
- name: testbed_file
|
|
|
|
value: vtestbed.csv
|
|
|
|
- name: ptf_name
|
|
|
|
value: ptf_vms6-1
|
|
|
|
|
|
|
|
jobs:
|
2021-01-24 23:01:19 -06:00
|
|
|
- job:
|
|
|
|
displayName: "vstest"
|
|
|
|
timeoutInMinutes: 60
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
|
|
submodules: recursive
|
|
|
|
displayName: 'Checkout code'
|
|
|
|
|
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
source: specific
|
|
|
|
project: build
|
|
|
|
pipeline: 9
|
|
|
|
artifacts: sonic-swss-common.amd64.ubuntu20_04
|
|
|
|
runVersion: 'latestFromBranch'
|
|
|
|
runBranch: 'refs/heads/master'
|
|
|
|
displayName: "Download sonic swss common deb packages"
|
|
|
|
|
2021-01-27 21:58:58 -06:00
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
artifact: sonic-buildimage.kvm
|
|
|
|
displayName: "Download sonic-buildimage.kvm artifact"
|
|
|
|
|
2021-01-24 23:01:19 -06:00
|
|
|
- script: |
|
2021-01-27 21:58:58 -06:00
|
|
|
set -x
|
2021-01-24 23:01:19 -06:00
|
|
|
sudo dpkg -i --force-confask,confnew ../sonic-swss-common.amd64.ubuntu20_04/libswsscommon_1.0.0_amd64.deb
|
|
|
|
sudo dpkg -i ../sonic-swss-common.amd64.ubuntu20_04/python3-swsscommon_1.0.0_amd64.deb
|
2021-01-27 21:58:58 -06:00
|
|
|
sudo docker load -i ../target/docker-sonic-vs.gz
|
2021-01-24 23:01:19 -06:00
|
|
|
docker tag docker-sonic-vs:latest docker-sonic-vs:$(Build.BuildNumber)
|
|
|
|
username=$(id -un)
|
|
|
|
|
|
|
|
trap "docker ps; docker images; ip netns list; \
|
|
|
|
docker rmi docker-sonic-vs:$(Build.BuildNumber); \
|
|
|
|
ip netns list | grep -E [-]srv[0-9]+ | awk '{print $1}' | xargs -I {} sudo ip netns delete {}; \
|
2021-01-25 21:05:01 -06:00
|
|
|
sudo chown -R ${username}.${username} .; \
|
|
|
|
sudo chown -R ${username}.${username} $(System.DefaultWorkingDirectory)" EXIT
|
2021-01-24 23:01:19 -06:00
|
|
|
pushd platform/vs/tests
|
2021-01-27 21:58:58 -06:00
|
|
|
sudo py.test -v --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.BuildNumber)
|
2021-01-24 23:01:19 -06:00
|
|
|
displayName: "Run vs tests"
|
|
|
|
|
|
|
|
- task: PublishTestResults@2
|
|
|
|
inputs:
|
|
|
|
testResultsFiles: '**/tr.xml'
|
|
|
|
testRunTitle: vstest
|
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
- job:
|
|
|
|
displayName: "kvmtest"
|
|
|
|
timeoutInMinutes: 240
|
|
|
|
steps:
|
2021-01-27 21:58:58 -06:00
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
artifact: sonic-buildimage.kvm
|
|
|
|
displayName: "Download sonic-buildimage.kvm artifact"
|
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
- script: |
|
2021-01-27 21:58:58 -06:00
|
|
|
set -x
|
2021-01-07 21:50:11 -06:00
|
|
|
sudo mkdir -p /data/sonic-vm/images
|
2021-01-27 21:58:58 -06:00
|
|
|
sudo cp -v ../target/sonic-vs.img.gz /data/sonic-vm/images/sonic-vs.img.gz
|
2021-01-07 21:50:11 -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
|
2021-01-26 04:28:27 -06: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 ceos refresh-dut $(tbname) password.txt" && sleep 180
|
2021-01-07 21:50:11 -06:00
|
|
|
displayName: "Setup T0 testbed"
|
|
|
|
- script: |
|
|
|
|
pwd
|
|
|
|
username=$(id -un)
|
|
|
|
|
2021-01-26 15:09:56 -06:00
|
|
|
rm -rf $(Build.ArtifactStagingDirectory)/*
|
2021-01-18 23:26:41 -06:00
|
|
|
docker exec sonic-mgmt bash -c "/data/sonic-mgmt/tests/kvmtest.sh -en $(tbname) $(dut)"
|
2021-01-07 21:50:11 -06:00
|
|
|
|
|
|
|
# save dut state if test fails
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
virsh_version=$(virsh --version)
|
|
|
|
if [ $virsh_version == "6.0.0" ]; then
|
2021-01-26 15:09:56 -06:00
|
|
|
mkdir -p $(Build.ArtifactStagingDirectory)/kvmdump
|
2021-01-07 21:50:11 -06:00
|
|
|
virsh -c qemu:///system list
|
2021-01-26 15:09:56 -06:00
|
|
|
virsh -c qemu:///system save $(dut) $(Build.ArtifactStagingDirectory)/kvmdump/$(dut).memdmp
|
|
|
|
virsh -c qemu:///system dumpxml $(dut) > $(Build.ArtifactStagingDirectory)/kvmdump/$(dut).xml
|
2021-01-07 21:50:11 -06:00
|
|
|
img=$(virsh -c qemu:///system domblklist $(dut) | grep vda | awk '{print $2}')
|
2021-01-26 15:09:56 -06:00
|
|
|
cp $img $(Build.ArtifactStagingDirectory)/kvmdump/$(dut).img
|
2021-01-07 21:50:11 -06:00
|
|
|
virsh -c qemu:///system undefine $(dut)
|
|
|
|
fi
|
|
|
|
|
2021-01-18 23:26:41 -06:00
|
|
|
docker commit $(ptf_name) docker-ptf:$(Build.BuildNumber)
|
2021-01-26 15:09:56 -06:00
|
|
|
docker save docker-ptf:$(Build.BuildNumber) | gzip -c > $(Build.ArtifactStagingDirectory)/kvmdump/docker-ptf-dump.gz
|
2021-01-07 21:50:11 -06:00
|
|
|
docker rmi docker-ptf:$(Build.BuildNumber)
|
|
|
|
|
2021-01-26 15:09:56 -06:00
|
|
|
cp -r /data/sonic-mgmt/tests/logs $(Build.ArtifactStagingDirectory)/
|
2021-01-27 22:57:17 -06:00
|
|
|
sudo chown -R $username.$username $(Build.ArtifactStagingDirectory)
|
2021-01-26 15:09:56 -06:00
|
|
|
|
2021-01-07 21:50:11 -06:00
|
|
|
exit 2
|
|
|
|
else
|
2021-01-26 15:09:56 -06:00
|
|
|
cp -r /data/sonic-mgmt/tests/logs $(Build.ArtifactStagingDirectory)/
|
2021-01-07 21:50:11 -06:00
|
|
|
fi
|
|
|
|
displayName: "Run T0 tests"
|
2021-01-26 15:09:56 -06:00
|
|
|
- publish: $(Build.ArtifactStagingDirectory)/kvmdump
|
2021-01-28 03:05:44 -06:00
|
|
|
artifact: sonic-buildimage.kvmtest.memdump@$(System.JobAttempt)
|
2021-01-26 15:09:56 -06:00
|
|
|
displayName: "Archive sonic kvm memdump"
|
|
|
|
condition: failed()
|
|
|
|
- publish: $(Build.ArtifactStagingDirectory)/logs
|
2021-01-28 03:05:44 -06:00
|
|
|
artifact: sonic-buildimage.kvmtest.log@$(System.JobAttempt)
|
2021-01-26 15:09:56 -06:00
|
|
|
displayName: "Archive sonic kvm logs"
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
- task: PublishTestResults@2
|
|
|
|
inputs:
|
|
|
|
testResultsFiles: '$(Build.ArtifactStagingDirectory)/logs/**/*.xml'
|
|
|
|
testRunTitle: kvmtest
|
|
|
|
condition: succeededOrFailed()
|