e91e38810a
co-authorized by: jianquanye@microsoft.com Why I did it Now, checkout code step and KVM test job can't be cancelled even though the whole build is cancelled. That's because by using Azure Pipeline Conditions, we customized the running condition, and we need to react to the Cancel action explicitly by asserting 'succeeded' https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#succeeded https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml#ive-got-a-conditional-step-that-runs-even-when-a-job-is-canceled-how-do-i-manage-to-cancel-all-jobs-at-once How I did it Assert 'succeeded' condition explicitly. How to verify it Verified by cancelling and rerunning the azure pipeline.
299 lines
8.4 KiB
YAML
299 lines
8.4 KiB
YAML
# 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:
|
|
branches:
|
|
include:
|
|
- master
|
|
- 202205
|
|
paths:
|
|
exclude:
|
|
- .github
|
|
|
|
pr:
|
|
branches:
|
|
include:
|
|
- master
|
|
- 202205
|
|
- bullseye
|
|
paths:
|
|
exclude:
|
|
- .github
|
|
|
|
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
|
|
|
|
resources:
|
|
repositories:
|
|
- repository: sonic-mgmt
|
|
type: github
|
|
name: sonic-net/sonic-mgmt
|
|
endpoint: sonic-net
|
|
- repository: buildimage
|
|
type: github
|
|
name: sonic-net/sonic-buildimage
|
|
endpoint: sonic-net
|
|
ref: master
|
|
|
|
variables:
|
|
- template: .azure-pipelines/azure-pipelines-repd-build-variables.yml
|
|
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
|
|
- template: .azure-pipelines/template-variables.yml
|
|
- ${{ else }}:
|
|
- template: .azure-pipelines/template-variables.yml@buildimage
|
|
- name: CACHE_MODE
|
|
value: rcache
|
|
- name: ENABLE_FIPS
|
|
value: y
|
|
|
|
stages:
|
|
- stage: BuildVS
|
|
pool: sonicbld
|
|
jobs:
|
|
- template: .azure-pipelines/azure-pipelines-build.yml
|
|
parameters:
|
|
buildOptions: 'USERNAME=admin SONIC_BUILD_JOBS=$(nproc) ${{ variables.VERSION_CONTROL_OPTIONS }}'
|
|
jobGroups:
|
|
- name: vs
|
|
|
|
- stage: Build
|
|
pool: sonicbld
|
|
dependsOn: []
|
|
jobs:
|
|
- template: .azure-pipelines/azure-pipelines-build.yml
|
|
parameters:
|
|
buildOptions: 'USERNAME=admin SONIC_BUILD_JOBS=$(nproc) ${{ variables.VERSION_CONTROL_OPTIONS }}'
|
|
jobGroups:
|
|
- name: broadcom
|
|
variables:
|
|
swi_image: yes
|
|
- name: mellanox
|
|
- name: marvell-armhf
|
|
pool: sonicbld-armhf
|
|
timeoutInMinutes: 1200
|
|
variables:
|
|
PLATFORM_ARCH: armhf
|
|
|
|
- stage: Test
|
|
dependsOn: BuildVS
|
|
condition: and(succeeded(), and(ne(stageDependencies.BuildVS.outputs['vs.SetVar.SKIP_VSTEST'], 'YES'), in(dependencies.BuildVS.result, 'Succeeded', 'SucceededWithIssues')))
|
|
variables:
|
|
- group: Testbed-Tools
|
|
- name: inventory
|
|
value: veos_vtb
|
|
- name: testbed_file
|
|
value: vtestbed.csv
|
|
|
|
jobs:
|
|
- job:
|
|
pool: sonictest
|
|
displayName: "vstest"
|
|
timeoutInMinutes: 60
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
submodules: recursive
|
|
displayName: 'Checkout code'
|
|
|
|
- task: DownloadPipelineArtifact@2
|
|
inputs:
|
|
source: specific
|
|
project: build
|
|
pipeline: 9
|
|
artifact: sonic-swss-common.amd64.ubuntu20_04
|
|
runVersion: 'latestFromBranch'
|
|
runBranch: 'refs/heads/master'
|
|
displayName: "Download sonic swss common deb packages"
|
|
|
|
- task: DownloadPipelineArtifact@2
|
|
inputs:
|
|
artifact: sonic-buildimage.vs
|
|
displayName: "Download sonic-buildimage.vs artifact"
|
|
|
|
- script: |
|
|
set -x
|
|
sudo apt-get update
|
|
sudo apt-get install libyang0.16 -y
|
|
sudo dpkg -i --force-confask,confnew ../libswsscommon_1.0.0_amd64.deb
|
|
sudo dpkg -i ../python3-swsscommon_1.0.0_amd64.deb
|
|
sudo docker load -i ../target/docker-sonic-vs.gz
|
|
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 {}; \
|
|
sudo chown -R ${username}.${username} .; \
|
|
sudo chown -R ${username}.${username} $(System.DefaultWorkingDirectory)" EXIT
|
|
pushd platform/vs/tests
|
|
sudo py.test -v --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.BuildNumber)
|
|
displayName: "Run vs tests"
|
|
|
|
- task: PublishTestResults@2
|
|
inputs:
|
|
testResultsFiles: '**/tr.xml'
|
|
testRunTitle: vstest
|
|
|
|
- job: t0_part1
|
|
pool: sonictest
|
|
displayName: "kvmtest-t0-part1"
|
|
timeoutInMinutes: 360
|
|
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES'))
|
|
continueOnError: false
|
|
steps:
|
|
- template: .azure-pipelines/run-test-template.yml
|
|
parameters:
|
|
dut: vlab-01
|
|
tbname: vms-kvm-t0
|
|
ptf_name: ptf_vms6-1
|
|
tbtype: t0
|
|
section: part-1
|
|
|
|
- job: t0_part2
|
|
pool: sonictest
|
|
displayName: "kvmtest-t0-part2"
|
|
timeoutInMinutes: 360
|
|
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES'))
|
|
continueOnError: false
|
|
steps:
|
|
- template: .azure-pipelines/run-test-template.yml
|
|
parameters:
|
|
dut: vlab-01
|
|
tbname: vms-kvm-t0
|
|
ptf_name: ptf_vms6-1
|
|
tbtype: t0
|
|
section: part-2
|
|
|
|
- job: t0_testbedv2
|
|
pool:
|
|
vmImage: 'ubuntu-20.04'
|
|
displayName: "kvmtest-t0 by TestbedV2"
|
|
timeoutInMinutes: 1080
|
|
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
|
|
continueOnError: false
|
|
steps:
|
|
- template: .azure-pipelines/run-test-scheduler-template.yml
|
|
parameters:
|
|
TOPOLOGY: t0
|
|
MIN_WORKER: 2
|
|
MAX_WORKER: 3
|
|
MGMT_BRANCH: 202205
|
|
|
|
- job: t0_2vlans_testbedv2
|
|
pool:
|
|
vmImage: 'ubuntu-20.04'
|
|
displayName: "kvmtest-t0-2vlans by TestbedV2"
|
|
timeoutInMinutes: 1080
|
|
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
|
|
continueOnError: false
|
|
steps:
|
|
- template: .azure-pipelines/run-test-scheduler-template.yml
|
|
parameters:
|
|
TOPOLOGY: t0
|
|
TEST_SET: t0-2vlans
|
|
MAX_WORKER: 1
|
|
DEPLOY_MG_EXTRA_PARAMS: "-e vlan_config=two_vlan_a"
|
|
MGMT_BRANCH: 202205
|
|
|
|
- job:
|
|
pool:
|
|
vmImage: 'ubuntu-20.04'
|
|
displayName: "kvmtest-t0"
|
|
dependsOn:
|
|
- t0_part1
|
|
- t0_part2
|
|
- t0_testbedv2
|
|
- t0_2vlans_testbedv2
|
|
condition: always()
|
|
variables:
|
|
resultOfPart1: $[ dependencies.t0_part1.result ]
|
|
resultOfPart2: $[ dependencies.t0_part2.result ]
|
|
resultOfT0TestbedV2: $[ dependencies.t0_testbedv2.result ]
|
|
resultOfT02VlansTestbedV2: $[ dependencies.t0_2vlans_testbedv2.result ]
|
|
|
|
steps:
|
|
- script: |
|
|
if [ $(resultOfT0TestbedV2) == "Succeeded" ] && [ $(resultOfT02VlansTestbedV2) == "Succeeded" ]; then
|
|
echo "TestbedV2 t0 passed."
|
|
exit 0
|
|
fi
|
|
|
|
if [ $(resultOfPart1) == "Succeeded" ] && [ $(resultOfPart2) == "Succeeded" ]; then
|
|
echo "Classic t0 jobs(both part1 and part2) passed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Both classic and TestbedV2 t0 jobs failed! Please check the detailed information. (Any of them passed, t0 will be considered as passed)"
|
|
exit 1
|
|
|
|
- job: t1_lag_classic
|
|
pool: sonictest-t1-lag
|
|
displayName: "kvmtest-t1-lag classic"
|
|
timeoutInMinutes: 360
|
|
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_CLASSICAL_TEST, 'YES'))
|
|
continueOnError: false
|
|
steps:
|
|
- template: .azure-pipelines/run-test-template.yml
|
|
parameters:
|
|
dut: vlab-03
|
|
tbname: vms-kvm-t1-lag
|
|
ptf_name: ptf_vms6-2
|
|
tbtype: t1-lag
|
|
|
|
- job: t1_lag_testbedv2
|
|
pool:
|
|
vmImage: 'ubuntu-20.04'
|
|
displayName: "kvmtest-t1-lag by TestbedV2"
|
|
timeoutInMinutes: 600
|
|
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
|
|
continueOnError: false
|
|
steps:
|
|
- template: .azure-pipelines/run-test-scheduler-template.yml
|
|
parameters:
|
|
TOPOLOGY: t1-lag
|
|
MIN_WORKER: 2
|
|
MAX_WORKER: 3
|
|
MGMT_BRANCH: 202205
|
|
|
|
- job:
|
|
pool:
|
|
vmImage: 'ubuntu-20.04'
|
|
displayName: "kvmtest-t1-lag"
|
|
dependsOn:
|
|
- t1_lag_classic
|
|
- t1_lag_testbedv2
|
|
condition: always()
|
|
continueOnError: false
|
|
variables:
|
|
resultOfClassic: $[ dependencies.t1_lag_classic.result ]
|
|
resultOfTestbedV2: $[ dependencies.t1_lag_testbedv2.result ]
|
|
steps:
|
|
- script: |
|
|
if [ $(resultOfTestbedV2) == "Succeeded" ]; then
|
|
echo "TestbedV2 t1-lag passed."
|
|
exit 0
|
|
fi
|
|
|
|
if [ $(resultOfClassic) == "Succeeded" ]; then
|
|
echo "Classic t1-lag passed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Both classic and TestbedV2 t1-lag jobs failed! Please check the detailed information. (Any of them passed, t1-lag will be considered as passed)"
|
|
exit 1
|
|
|
|
- job:
|
|
pool: sonictest-sonic-t0
|
|
displayName: "kvmtest-t0-sonic"
|
|
timeoutInMinutes: 360
|
|
|
|
steps:
|
|
- template: .azure-pipelines/run-test-template.yml
|
|
parameters:
|
|
dut: vlab-02
|
|
tbname: vms-kvm-t0-64-32
|
|
ptf_name: ptf_vms6-1
|
|
tbtype: t0-sonic
|
|
vmtype: vsonic
|