forked from sonic-net/sonic-swss-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-docker-sonic-vs-template.yml
More file actions
105 lines (92 loc) · 3.48 KB
/
Copy pathtest-docker-sonic-vs-template.yml
File metadata and controls
105 lines (92 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
parameters:
- name: timeout
type: number
default: 360
- name: log_artifact_name
type: string
jobs:
- job:
displayName: vstest
timeoutInMinutes: ${{ parameters.timeout }}
pool: sonic-common
steps:
- checkout: self
clean: true
displayName: "Checkout sonic-swss-common"
- checkout: sonic-swss
clean: true
displayName: "Checkout sonic-swss"
- script: |
set -ex
cd sonic-swss
git checkout $(BUILD_BRANCH)
displayName: Set up sonic-swss branch
- task: DownloadPipelineArtifact@2
inputs:
artifact: docker-sonic-vs
path: $(Build.ArtifactStagingDirectory)/download
displayName: "Download pre-stage built docker-sonic-vs"
- task: DownloadPipelineArtifact@2
inputs:
artifact: sonic-swss-common.amd64.ubuntu20_04
path: $(Build.ArtifactStagingDirectory)/download
displayName: "Download pre-stage built sonic-swss-common.amd64.ubuntu20_04"
- script: |
set -ex
ls -l
sudo sonic-swss-common/.azure-pipelines/build_and_install_module.sh
sudo apt-get install -y libhiredis0.14 libyang0.16
sudo dpkg -i --force-confask,confnew $(Build.ArtifactStagingDirectory)/download/libswsscommon_1.0.0_amd64.deb || apt-get install -f
sudo dpkg -i $(Build.ArtifactStagingDirectory)/download/python3-swsscommon_1.0.0_amd64.deb
# install packages for vs test
sudo apt-get install -y net-tools bridge-utils vlan
sudo apt-get install -y python3-pip
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
displayName: "Install dependencies"
- script: |
set -ex
sudo docker load -i $(Build.ArtifactStagingDirectory)/download/docker-sonic-vs.gz
docker ps
ip netns list
pushd sonic-swss/tests
# run pytests in sets of 20
all_tests=$(ls test_*.py)
all_tests="${all_tests} p4rt"
test_set=()
for test in ${all_tests}; do
test_set+=("${test}")
if [ ${#test_set[@]} -ge 20 ]; then
test_name=$(echo "${test_set[0]}" | cut -d "." -f 1)
echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
container_count=$(docker ps -q -a | wc -l)
if [ ${container_count} -gt 0 ]; then
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
test_set=()
fi
done
if [ ${#test_set[@]} -gt 0 ]; then
test_name=$(echo "${test_set[0]}" | cut -d "." -f 1)
echo "${test_set[*]}" | xargs sudo py.test -v --force-flaky --junitxml="${test_name}_tr.xml" --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
container_count=$(docker ps -q -a | wc -l)
if [ ${container_count} -gt 0 ]; then
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
fi
rm -rf $(Build.ArtifactStagingDirectory)/download
displayName: "Run vs tests"
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/*_tr.xml'
testRunTitle: vstest
condition: always()
- script: |
cp -r sonic-swss/tests/log $(Build.ArtifactStagingDirectory)/
displayName: "Collect logs"
condition: always()
- publish: $(Build.ArtifactStagingDirectory)/
artifact: ${{ parameters.log_artifact_name }}@$(System.JobAttempt)
displayName: "Publish logs"
condition: always()