Skip to content

Commit f9d5959

Browse files
committed
[ci]: run vstest
Signed-off-by: Guohan Lu <lguohan@gmail.com>
1 parent 0dea91c commit f9d5959

6 files changed

+282
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
parameters:
2+
- name: arch
3+
type: string
4+
values:
5+
- amd64
6+
- armhf
7+
- arm64
8+
default: amd64
9+
10+
- name: timeout
11+
type: number
12+
default: 60
13+
14+
- name: swss_artifact_name
15+
type: string
16+
17+
- name: sairedis_artifact_name
18+
type: string
19+
20+
- name: swss_common_artifact_name
21+
type: string
22+
23+
- name: artifact_name
24+
type: string
25+
26+
jobs:
27+
- job:
28+
displayName: ${{ parameters.arch }}
29+
timeoutInMinutes: ${{ parameters.timeout }}
30+
31+
pool:
32+
vmImage: 'ubuntu-20.04'
33+
34+
steps:
35+
- task: DownloadPipelineArtifact@2
36+
inputs:
37+
source: specific
38+
project: build
39+
pipeline: 9
40+
artifact: ${{ parameters.swss_common_artifact_name }}
41+
runVersion: 'latestFromBranch'
42+
runBranch: 'refs/heads/master'
43+
displayName: "Download sonic swss common deb packages"
44+
- task: DownloadPipelineArtifact@2
45+
inputs:
46+
source: specific
47+
project: build
48+
pipeline: 12
49+
artifact: ${{ parameters.sairedis_artifact_name }}
50+
runVersion: 'latestFromBranch'
51+
runBranch: 'refs/heads/master'
52+
displayName: "Download sonic sairedis deb packages"
53+
- task: DownloadPipelineArtifact@2
54+
inputs:
55+
artifact: ${{ parameters.swss_artifact_name }}
56+
displayName: "Download sonic swss artifact"
57+
- task: DownloadPipelineArtifact@2
58+
inputs:
59+
source: specific
60+
project: build
61+
pipeline: 1
62+
artifact: sonic-buildimage.vs
63+
runVersion: 'latestFromBranch'
64+
runBranch: 'refs/heads/master'
65+
displayName: "Download sonic buildimage"
66+
- script: |
67+
echo $(Build.DefinitionName).$(Build.BuildNumber)
68+
69+
docker load < ../target/docker-sonic-vs.gz
70+
71+
mkdir -p .azure-pipelines/docker-sonic-vs/debs
72+
73+
cp -v ../*.deb .azure-pipelines/docker-sonic-vs/debs
74+
75+
pushd .azure-pipelines
76+
77+
docker build --no-cache -t docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) docker-sonic-vs
78+
79+
popd
80+
81+
docker save docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) | gzip -c > $(Build.ArtifactStagingDirectory)/docker-sonic-vs.gz
82+
83+
- publish: $(Build.ArtifactStagingDirectory)/
84+
artifact: ${{ parameters.artifact_name }}
85+
displayName: "Archive sonic docker vs image"

.azure-pipelines/build-template.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
- amd64
66
- armhf
77
- arm64
8+
default: amd64
89

910
- name: pool
1011
type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
#
3+
# build and install team/vrf driver
4+
#
5+
6+
set -e
7+
8+
source /etc/os-release
9+
10+
function build_and_install_kmodule()
11+
{
12+
if sudo modprobe team 2>/dev/null && sudo modprobe vrf 2>/dev/null && sudo modprobe macsec 2>/dev/null; then
13+
echo "The module team, vrf and macsec exist."
14+
return
15+
fi
16+
17+
[ -z "$WORKDIR" ] && WORKDIR=$(mktemp -d)
18+
cd $WORKDIR
19+
20+
KERNEL_RELEASE=$(uname -r)
21+
KERNEL_MAINVERSION=$(echo $KERNEL_RELEASE | cut -d- -f1)
22+
EXTRAVERSION=$(echo $KERNEL_RELEASE | cut -d- -f2)
23+
LOCALVERSION=$(echo $KERNEL_RELEASE | cut -d- -f3)
24+
VERSION=$(echo $KERNEL_MAINVERSION | cut -d. -f1)
25+
PATCHLEVEL=$(echo $KERNEL_MAINVERSION | cut -d. -f2)
26+
SUBLEVEL=$(echo $KERNEL_MAINVERSION | cut -d. -f3)
27+
28+
# Install the required debian packages to build the kernel modules
29+
apt-get install -y build-essential linux-headers-${KERNEL_RELEASE} autoconf pkg-config fakeroot
30+
apt-get install -y flex bison libssl-dev libelf-dev
31+
apt-get install -y libnl-route-3-200 libnl-route-3-dev libnl-cli-3-200 libnl-cli-3-dev libnl-3-dev
32+
33+
# Add the apt source mirrors and download the linux image source code
34+
cp /etc/apt/sources.list /etc/apt/sources.list.bk
35+
sed -i "s/^# deb-src/deb-src/g" /etc/apt/sources.list
36+
apt-get update
37+
apt-get source linux-image-unsigned-$(uname -r) > source.log
38+
39+
# Recover the original apt sources list
40+
cp /etc/apt/sources.list.bk /etc/apt/sources.list
41+
apt-get update
42+
43+
# Build the Linux kernel module drivers/net/team and vrf
44+
cd $(find . -maxdepth 1 -type d | grep -v "^.$")
45+
make allmodconfig
46+
mv .config .config.bk
47+
cp /boot/config-$(uname -r) .config
48+
grep NET_TEAM .config.bk >> .config
49+
echo CONFIG_NET_VRF=m >> .config
50+
echo CONFIG_MACSEC=m >> .config
51+
make VERSION=$VERSION PATCHLEVEL=$PATCHLEVEL SUBLEVEL=$SUBLEVEL EXTRAVERSION=-${EXTRAVERSION} LOCALVERSION=-${LOCALVERSION} modules_prepare
52+
make M=drivers/net/team
53+
mv drivers/net/Makefile drivers/net/Makefile.bak
54+
echo 'obj-$(CONFIG_NET_VRF) += vrf.o' > drivers/net/Makefile
55+
echo 'obj-$(CONFIG_MACSEC) += macsec.o' >> drivers/net/Makefile
56+
make M=drivers/net
57+
58+
# Install the module
59+
TEAM_DIR=$(echo /lib/modules/$(uname -r)/kernel/net/team)
60+
NET_DIR=$(echo /lib/modules/$(uname -r)/kernel/net)
61+
if [ ! -e "$TEAM_DIR/team.ko" ]; then
62+
mkdir -p $TEAM_DIR
63+
cp drivers/net/team/*.ko $TEAM_DIR/
64+
modinfo $TEAM_DIR/team.ko
65+
depmod
66+
modprobe team
67+
fi
68+
if [ ! -e "$NET_DIR/vrf.ko" ]; then
69+
mkdir -p $NET_DIR
70+
cp drivers/net/vrf.ko $NET_DIR/
71+
modinfo $NET_DIR/vrf.ko
72+
depmod
73+
modprobe vrf
74+
fi
75+
if [ ! -e "$NET_DIR/macsec.ko" ]; then
76+
mkdir -p $NET_DIR
77+
cp drivers/net/macsec.ko $NET_DIR/
78+
modinfo $NET_DIR/macsec.ko
79+
depmod
80+
modprobe macsec
81+
fi
82+
83+
cd /tmp
84+
rm -rf $WORKDIR
85+
}
86+
87+
build_and_install_kmodule
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM docker-sonic-vs
2+
3+
ARG docker_container_name
4+
5+
ADD ["debs", "/debs"]
6+
7+
RUN dpkg -i /debs/libswsscommon_1.0.0_amd64.deb
8+
RUN dpkg -i /debs/python-swsscommon_1.0.0_amd64.deb
9+
RUN dpkg -i /debs/python3-swsscommon_1.0.0_amd64.deb
10+
11+
RUN dpkg -i /debs/libsaimetadata_1.0.0_amd64.deb
12+
RUN dpkg -i /debs/libsairedis_1.0.0_amd64.deb
13+
RUN dpkg -i /debs/libsaivs_1.0.0_amd64.deb
14+
RUN dpkg -i /debs/syncd-vs_1.0.0_amd64.deb
15+
16+
RUN dpkg -i /debs/swss_1.0.0_amd64.deb
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
parameters:
2+
- name: timeout
3+
type: number
4+
default: 180
5+
6+
- name: log_artifact_name
7+
type: string
8+
9+
jobs:
10+
- job:
11+
displayName: vstest
12+
timeoutInMinutes: ${{ parameters.timeout }}
13+
14+
pool:
15+
vmImage: 'ubuntu-20.04'
16+
17+
steps:
18+
- task: DownloadPipelineArtifact@2
19+
inputs:
20+
artifact: docker-sonic-vs
21+
displayName: "Download docker sonic vs image"
22+
23+
- task: DownloadPipelineArtifact@2
24+
inputs:
25+
source: specific
26+
project: build
27+
pipeline: 9
28+
artifact: sonic-swss-common.amd64.ubuntu20_04
29+
runVersion: 'latestFromBranch'
30+
runBranch: 'refs/heads/master'
31+
displayName: "Download sonic swss common deb packages"
32+
33+
- script: |
34+
set -x
35+
sudo .azure-pipelines/build_and_install_module.sh
36+
37+
sudo apt-get install -y libhiredis0.14
38+
sudo dpkg -i --force-confask,confnew ../libswsscommon_1.0.0_amd64.deb || apt-get install -f
39+
sudo dpkg -i ../python3-swsscommon_1.0.0_amd64.deb
40+
41+
# install packages for vs test
42+
sudo apt-get install -y net-tools bridge-utils vlan
43+
sudo apt-get install -y python3-pip
44+
sudo pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker==4.4.1 redis==3.3.4 flaky==3.7.0
45+
displayName: "Install dependencies"
46+
47+
- script: |
48+
set -x
49+
sudo docker load -i ../docker-sonic-vs.gz
50+
docker ps
51+
ip netns list
52+
pushd tests
53+
sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
54+
displayName: "Run vs tests"
55+
56+
- task: PublishTestResults@2
57+
inputs:
58+
testResultsFiles: '**/tr.xml'
59+
testRunTitle: vstest
60+
condition: always()
61+
62+
- script: |
63+
cp -r tests/log $(Build.ArtifactStagingDirectory)/
64+
displayName: "Collect logs"
65+
condition: always()
66+
67+
- publish: $(Build.ArtifactStagingDirectory)/
68+
artifact: ${{ parameters.log_artifact_name }}@$(System.JobAttempt)
69+
displayName: "Publish logs"
70+
condition: always()

azure-pipelines.yml

+23
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ stages:
2020
sairedis_artifact_name: sonic-sairedis
2121
artifact_name: sonic-swss
2222

23+
- stage: BuildArm
24+
dependsOn: Build
25+
condition: succeeded('Build')
26+
jobs:
2327
- template: .azure-pipelines/build-template.yml
2428
parameters:
2529
arch: armhf
@@ -39,3 +43,22 @@ stages:
3943
swss_common_artifact_name: sonic-swss-common.arm64
4044
sairedis_artifact_name: sonic-sairedis.arm64
4145
artifact_name: sonic-swss.arm64
46+
47+
- stage: BuildDocker
48+
dependsOn: Build
49+
condition: succeeded('Build')
50+
jobs:
51+
- template: .azure-pipelines/build-docker-sonic-vs-template.yml
52+
parameters:
53+
swss_common_artifact_name: sonic-swss-common
54+
sairedis_artifact_name: sonic-sairedis
55+
swss_artifact_name: sonic-swss
56+
artifact_name: docker-sonic-vs
57+
58+
- stage: Test
59+
dependsOn: BuildDocker
60+
condition: succeeded('BuildDocker')
61+
jobs:
62+
- template: .azure-pipelines/test-docker-sonic-vs-template.yml
63+
parameters:
64+
log_artifact_name: log

0 commit comments

Comments
 (0)