blob: f05d39df91e66c82914a58391eb211f3b775b279 [file] [log] [blame]
Kailashaad71012019-08-27 10:36:53 -07001// Copyright 2017-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// voltha-2.x e2e tests
16// uses kind-voltha to deploy voltha-2.X
17// uses bbsim to simulate OLT/ONUs
18
19pipeline {
20
21 /* no label, executor is determined by JJB */
22 agent {
Zack Williamsb3292082019-10-11 17:15:18 -070023 label "${params.buildNode}"
Kailashaad71012019-08-27 10:36:53 -070024 }
25 options {
Andy Bavier4af02722020-01-15 10:24:24 -070026 timeout(time: 90, unit: 'MINUTES')
27 }
28 environment {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
31 PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
32 TYPE="minimal"
33 FANCY=0
34 WITH_SIM_ADAPTERS="n"
35 WITH_RADIUS="y"
36 WITH_BBSIM="y"
37 DEPLOY_K8S="y"
38 VOLTHA_LOG_LEVEL="DEBUG"
39 CONFIG_SADIS="n"
Andy Baviere234fa52020-02-24 11:32:03 -070040 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
Kailashaad71012019-08-27 10:36:53 -070041 }
42
43 stages {
44
45 stage('Repo') {
46 steps {
Andy Bavier4af02722020-01-15 10:24:24 -070047 step([$class: 'WsCleanup'])
Kailashaad71012019-08-27 10:36:53 -070048 checkout(changelog: false, \
49 poll: false,
50 scm: [$class: 'RepoScm', \
51 manifestRepositoryUrl: "${params.manifestUrl}", \
Zack Williams03ebb272020-03-27 09:42:33 -070052 manifestBranch: "${params.branch}", \
Kailashaad71012019-08-27 10:36:53 -070053 currentBranch: true, \
54 destinationDir: 'voltha', \
55 forceSync: true,
56 resetFirst: true, \
57 quiet: true, \
58 jobs: 4, \
59 showAllChanges: true] \
60 )
61 }
62 }
63 stage('Patch') {
64 steps {
65 sh """
66 pushd voltha
Andy Bavierb35171c2020-03-06 15:47:29 -070067 if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ]
68 then
69 repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
70 else
71 echo "No patchset to download!"
72 fi
Kailashaad71012019-08-27 10:36:53 -070073 popd
74 """
75 }
76 }
77 stage('Create K8s Cluster') {
78 steps {
79 sh """
Kailashaad71012019-08-27 10:36:53 -070080 git clone https://github.com/ciena/kind-voltha.git
Zack Williams03ebb272020-03-27 09:42:33 -070081
82 if [ "${branch}" != "master" ]; then
83 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
84 source "kind-voltha/releases/${branch}"
85 else
86 echo "on master, using default settings for kind-voltha"
87 fi
88
Kailashaad71012019-08-27 10:36:53 -070089 cd kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -070090 JUST_K8S=y ./voltha up
91 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
Kailashaad71012019-08-27 10:36:53 -070092 """
93 }
94 }
95
96 stage('Build Images') {
97 steps {
98 sh """
Andy Bavierb99c3d32020-02-18 11:14:17 -070099 make-local () {
100 make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
101 }
Andy Bavier0ed77062020-02-18 10:09:19 -0700102 if [ "${gerritProject}" = "pyvoltha" ]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -0700103 make -C $WORKSPACE/voltha/pyvoltha/ dist
Andy Bavier0ed77062020-02-18 10:09:19 -0700104 export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/
Andy Bavierb99c3d32020-02-18 11:14:17 -0700105 make-local voltha-openonu-adapter
106 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
107 make -C $WORKSPACE/voltha/voltha-lib-go/ build
108 export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/
109 make-local voltha-go
110 make-local voltha-openolt-adapter
111 elif [ "${gerritProject}" = "voltha-protos" ]; then
112 make -C $WORKSPACE/voltha/voltha-protos/ build
113 export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/
114 make-local voltha-go
115 make-local voltha-openolt-adapter
116 make-local voltha-openonu-adapter
117 make-local ofagent-py
Andy Bavier178c47b2020-04-01 13:05:43 -0700118 elif [ "${gerritProject}" = "voltctl" ]; then
119 make -C $WORKSPACE/voltha/voltctl/ build
Andy Bavier0ed77062020-02-18 10:09:19 -0700120 elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -0700121 make-local ${gerritProject}
Andy Bavier07615f92019-10-03 12:31:18 -0700122 fi
Kailashaad71012019-08-27 10:36:53 -0700123 """
124 }
125 }
126
127 stage('Push Images') {
128 steps {
129 sh '''
Zack Williams03ebb272020-03-27 09:42:33 -0700130 if [ "${branch}" != "master" ]; then
131 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
132 source "kind-voltha/releases/${branch}"
133 else
134 echo "on master, using default settings for kind-voltha"
135 fi
136
Andy Bavier178c47b2020-04-01 13:05:43 -0700137 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|voltctl)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -0700138 export GOROOT=/usr/local/go
139 export GOPATH=\$(pwd)
Andy Bavier07615f92019-10-03 12:31:18 -0700140 docker images | grep citest
141 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; done
142 fi
Kailashaad71012019-08-27 10:36:53 -0700143 '''
144 }
145 }
146 stage('Deploy Voltha') {
147 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700148 sh '''
Zack Williams03ebb272020-03-27 09:42:33 -0700149 if [ "${branch}" != "master" ]; then
150 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
151 source "kind-voltha/releases/${branch}"
152 else
153 echo "on master, using default settings for kind-voltha"
154 fi
155
156 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700157
Andy Bavier4af02722020-01-15 10:24:24 -0700158 IMAGES=""
Kailashaad71012019-08-27 10:36:53 -0700159 if [ "${gerritProject}" = "voltha-go" ]; then
Andy Bavier4af02722020-01-15 10:24:24 -0700160 IMAGES="rw_core ro_core "
161 elif [ "${gerritProject}" = "ofagent-py" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700162 IMAGES="ofagent_py "
163 EXTRA_HELM_FLAGS+="--set use_ofagent_go=false "
Andy Bavier9c412a82020-03-23 12:00:28 -0700164 elif [ "${gerritProject}" = "ofagent-go" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700165 IMAGES="ofagent_go "
Andy Bavier4af02722020-01-15 10:24:24 -0700166 elif [ "${gerritProject}" = "voltha-onos" ]; then
167 IMAGES="onos "
168 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
169 IMAGES="adapter_open_olt "
170 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
171 IMAGES="adapter_open_onu "
172 elif [ "${gerritProject}" = "voltha-api-server" ]; then
173 IMAGES="afrouter afrouterd "
174 elif [ "${gerritProject}" = "bbsim" ]; then
175 IMAGES="bbsim "
Andy Bavierec0c10d2020-02-14 13:06:27 -0700176 elif [ "${gerritProject}" = "pyvoltha" ]; then
177 IMAGES="adapter_open_onu "
Andy Bavierb99c3d32020-02-18 11:14:17 -0700178 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
179 IMAGES="rw_core ro_core adapter_open_olt "
180 elif [ "${gerritProject}" = "voltha-protos" ]; then
181 IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent "
Zack Williams04997502019-10-04 14:32:20 -0700182 else
Andy Bavier4af02722020-01-15 10:24:24 -0700183 echo "No images to push"
Scott Baker9ac23712019-10-02 09:26:50 -0700184 fi
185
Andy Bavier4af02722020-01-15 10:24:24 -0700186 for I in \$IMAGES
187 do
188 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
189 done
190
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700191 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700192 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
193 export VOLTHA_CHART=\$CHART_PATH/voltha
194 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
195 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700196 helm dep update \$VOLTHA_CHART
197 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
198 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
199 fi
200
Andy Bavier178c47b2020-04-01 13:05:43 -0700201 if [ "${gerritProject}" = "voltctl" ]; then
202 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltha/voltctl/VERSION)
203 cp $WORKSPACE/voltha/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
204 md5sum $WORKSPACE/kind-voltha/bin/voltctl
205 fi
206
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700207 cd $WORKSPACE/kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -0700208 echo \$EXTRA_HELM_FLAGS
209 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
210 ./voltha up
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700211 '''
Kailashaad71012019-08-27 10:36:53 -0700212 }
213 }
214
215 stage('Run E2E Tests') {
216 steps {
217 sh '''
Andy Bavier4af02722020-01-15 10:24:24 -0700218 mkdir -p $WORKSPACE/RobotLogs
Andy Bavierdb003082020-02-04 11:57:36 -0700219
220 # By default, all tests tagged 'sanity' are run. This covers basic functionality
221 # like running through the ATT workflow for a single subscriber.
222 export TEST_TAGS=sanity
223
224 # If the Gerrit comment contains a line with "functional tests" then run the full
225 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
226 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
227 REGEX="functional tests"
228 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
229 TEST_TAGS=sanityORfunctional
230 fi
231
232 make -C $WORKSPACE/voltha/voltha-system-tests single-kind || true
Kailashaad71012019-08-27 10:36:53 -0700233 '''
234 }
235 }
236 }
237
238 post {
239 always {
240 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700241 set +e
Andy Bavier4af02722020-01-15 10:24:24 -0700242 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Andy Bavieraec60382019-10-29 15:09:04 -0700243 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
Kailashaad71012019-08-27 10:36:53 -0700244 kubectl get nodes -o wide
245 kubectl get pods -o wide
246 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700247
248 sync
249 pkill kail || true
Andy Bavier178c47b2020-04-01 13:05:43 -0700250 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Andy Bavier4af02722020-01-15 10:24:24 -0700251
252 ## Pull out errors from log files
253 extract_errors_go() {
254 echo
255 echo "Error summary for $1:"
256 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
257 echo
258 }
259
260 extract_errors_python() {
261 echo
262 echo "Error summary for $1:"
263 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
264 echo
265 }
266
267 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
268 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
269 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
270 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
271
Andy Bavier2178d102020-02-06 16:22:11 -0700272 gzip $WORKSPACE/onos-voltha-combined.log
273
Zack Williams03ebb272020-03-27 09:42:33 -0700274
Andy Bavier4af02722020-01-15 10:24:24 -0700275 ## shut down kind-voltha
Zack Williams03ebb272020-03-27 09:42:33 -0700276 if [ "${branch}" != "master" ]; then
277 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
278 source "kind-voltha/releases/${branch}"
279 else
280 echo "on master, using default settings for kind-voltha"
281 fi
282
Andy Bavier4af02722020-01-15 10:24:24 -0700283 cd $WORKSPACE/kind-voltha
284 WAIT_ON_DOWN=y ./voltha down
Kailashaad71012019-08-27 10:36:53 -0700285 '''
286 step([$class: 'RobotPublisher',
287 disableArchiveOutput: false,
288 logFileName: 'RobotLogs/log*.html',
289 otherFiles: '',
290 outputFileName: 'RobotLogs/output*.xml',
291 outputPath: '.',
292 passThreshold: 80,
293 reportFileName: 'RobotLogs/report*.html',
294 unstableThreshold: 0]);
Andy Bavier2178d102020-02-06 16:22:11 -0700295 archiveArtifacts artifacts: '*.log,*.gz'
Kailashaad71012019-08-27 10:36:53 -0700296 }
297 }
298}