Skip to content

Commit 8df196e

Browse files
authored
[ci]: add vstest (sonic-net#795)
Signed-off-by: Guohan Lu <[email protected]>
1 parent 3258333 commit 8df196e

7 files changed

+401
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
artifact: ${{ parameters.sairedis_artifact_name }}
47+
displayName: "Download sonic sairedis deb packages"
48+
- task: DownloadPipelineArtifact@2
49+
inputs:
50+
artifact: ${{ parameters.swss_artifact_name }}
51+
displayName: "Download sonic swss artifact"
52+
- task: DownloadPipelineArtifact@2
53+
inputs:
54+
source: specific
55+
project: build
56+
pipeline: 1
57+
artifact: sonic-buildimage.vs
58+
runVersion: 'latestFromBranch'
59+
runBranch: 'refs/heads/master'
60+
displayName: "Download sonic buildimage"
61+
- script: |
62+
echo $(Build.DefinitionName).$(Build.BuildNumber)
63+
64+
docker load < ../target/docker-sonic-vs.gz
65+
66+
mkdir -p .azure-pipelines/docker-sonic-vs/debs
67+
68+
cp -v ../*.deb .azure-pipelines/docker-sonic-vs/debs
69+
70+
pushd .azure-pipelines
71+
72+
docker build --no-cache -t docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) docker-sonic-vs
73+
74+
popd
75+
76+
docker save docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber) | gzip -c > $(Build.ArtifactStagingDirectory)/docker-sonic-vs.gz
77+
displayName: "Build sonic-docker-vs"
78+
79+
- publish: $(Build.ArtifactStagingDirectory)/
80+
artifact: ${{ parameters.artifact_name }}
81+
displayName: "Archive sonic docker vs image"
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
parameters:
2+
- name: arch
3+
type: string
4+
values:
5+
- amd64
6+
- armhf
7+
- arm64
8+
default: amd64
9+
10+
- name: pool
11+
type: string
12+
values:
13+
- sonicbld
14+
- default
15+
default: default
16+
17+
- name: timeout
18+
type: number
19+
default: 60
20+
21+
- name: sonic_slave
22+
type: string
23+
24+
- name: sairedis_artifact_name
25+
type: string
26+
27+
- name: swss_common_artifact_name
28+
type: string
29+
30+
- name: artifact_name
31+
type: string
32+
33+
jobs:
34+
- job:
35+
displayName: ${{ parameters.arch }}
36+
timeoutInMinutes: ${{ parameters.timeout }}
37+
38+
pool:
39+
${{ if ne(parameters.pool, 'default') }}:
40+
name: ${{ parameters.pool }}
41+
${{ if eq(parameters.pool, 'default') }}:
42+
vmImage: 'ubuntu-20.04'
43+
44+
container:
45+
image: sonicdev-microsoft.azurecr.io:443/${{ parameters.sonic_slave }}:latest
46+
47+
steps:
48+
- script: |
49+
sudo apt-get install -y libhiredis0.14 libhiredis-dev
50+
sudo apt-get install -y libzmq5 libzmq3-dev
51+
sudo apt-get install -qq -y \
52+
libhiredis-dev \
53+
libnl-3-dev \
54+
libnl-genl-3-dev \
55+
libnl-route-3-dev \
56+
libnl-nf-3-dev \
57+
swig3.0
58+
sudo apt-get install -y libdbus-1-3
59+
sudo apt-get install -y libteam-dev \
60+
libteam5 \
61+
libteamdctl0
62+
displayName: "Install dependencies"
63+
- task: DownloadPipelineArtifact@2
64+
inputs:
65+
source: specific
66+
project: build
67+
pipeline: 9
68+
artifact: ${{ parameters.swss_common_artifact_name }}
69+
runVersion: 'latestFromBranch'
70+
runBranch: 'refs/heads/master'
71+
displayName: "Download sonic swss common deb packages"
72+
- task: DownloadPipelineArtifact@2
73+
inputs:
74+
artifact: ${{ parameters.sairedis_artifact_name }}
75+
displayName: "Download sonic sairedis deb packages"
76+
- script: |
77+
sudo dpkg -i libswsscommon_1.0.0_${{ parameters.arch }}.deb
78+
sudo dpkg -i libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
79+
sudo dpkg -i libsaivs_*.deb
80+
sudo dpkg -i libsaivs-dev_*.deb
81+
sudo dpkg -i libsairedis_*.deb
82+
sudo dpkg -i libsairedis-dev_*.deb
83+
sudo dpkg -i libsaimetadata_*.deb
84+
sudo dpkg -i libsaimetadata-dev_*.deb
85+
sudo dpkg -i syncd-vs_*.deb
86+
workingDirectory: $(Pipeline.Workspace)
87+
displayName: "Install sonic swss common and sairedis"
88+
- checkout: sonic-swss
89+
path: s
90+
submodules: true
91+
- script: |
92+
./autogen.sh
93+
dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb .
94+
displayName: "Compile sonic swss"
95+
- publish: $(System.DefaultWorkingDirectory)/
96+
artifact: ${{ parameters.artifact_name }}
97+
displayName: "Archive swss debian packages"

.azure-pipelines/build-template.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ jobs:
8383
source: specific
8484
project: build
8585
pipeline: 9
86-
artifacts: ${{ parameters.swss_common_artifact_name }}
86+
artifact: ${{ parameters.swss_common_artifact_name }}
8787
runVersion: 'latestFromBranch'
8888
runBranch: 'refs/heads/master'
8989
displayName: "Download sonic swss common deb packages"
9090
- script: |
91-
sudo dpkg -i ${{ parameters.swss_common_artifact_name }}/libswsscommon_1.0.0_${{ parameters.arch }}.deb
92-
sudo dpkg -i ${{ parameters.swss_common_artifact_name }}/libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
91+
sudo dpkg -i libswsscommon_1.0.0_${{ parameters.arch }}.deb
92+
sudo dpkg -i libswsscommon-dev_1.0.0_${{ parameters.arch }}.deb
9393
workingDirectory: $(Pipeline.Workspace)
9494
displayName: "Install sonic swss Common"
9595
- checkout: self
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,75 @@
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+
- checkout: self
34+
displayName: "Checkout sonic-sairedis"
35+
- checkout: sonic-swss
36+
displayName: "Checkout sonic-swss"
37+
38+
- script: |
39+
set -x
40+
sudo sonic-sairedis/.azure-pipelines/build_and_install_module.sh
41+
42+
sudo apt-get install -y libhiredis0.14
43+
sudo dpkg -i --force-confask,confnew ../libswsscommon_1.0.0_amd64.deb || apt-get install -f
44+
sudo dpkg -i ../python3-swsscommon_1.0.0_amd64.deb
45+
46+
# install packages for vs test
47+
sudo apt-get install -y net-tools bridge-utils vlan
48+
sudo apt-get install -y python3-pip
49+
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
50+
displayName: "Install dependencies"
51+
52+
- script: |
53+
set -x
54+
sudo docker load -i ../docker-sonic-vs.gz
55+
docker ps
56+
ip netns list
57+
pushd sonic-swss/tests
58+
sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
59+
displayName: "Run vs tests"
60+
61+
- task: PublishTestResults@2
62+
inputs:
63+
testResultsFiles: '**/tr.xml'
64+
testRunTitle: vstest
65+
condition: always()
66+
67+
- script: |
68+
cp -r sonic-swss/tests/log $(Build.ArtifactStagingDirectory)/
69+
displayName: "Collect logs"
70+
condition: always()
71+
72+
- publish: $(Build.ArtifactStagingDirectory)/
73+
artifact: ${{ parameters.log_artifact_name }}@$(System.JobAttempt)
74+
displayName: "Publish logs"
75+
condition: always()

0 commit comments

Comments
 (0)