blob: ddcd69fa48ca2cb62bf613d3fb17a9f0e04a41f8 [file] [log] [blame]
Andy Bavier61c5b2a2019-11-12 12:08:19 -07001// Copyright 2019-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// deploy VOLTHA built from patchset on a physical pod and run e2e test
16// uses kind-voltha to deploy voltha-2.X
17
Andy Baviere06dcff2020-02-06 11:36:40 -070018// Need this so that deployment_config has global scope when it's read later
19deployment_config = null
20localDeploymentConfigFile = null
21localKindVolthaValuesFile = null
22localSadisConfigFile = null
23
24// The pipeline assumes these variables are always defined
Zack Williams03ebb272020-03-27 09:42:33 -070025if ( params.manualBranch != "" ) {
Andy Baviere06dcff2020-02-06 11:36:40 -070026 GERRIT_EVENT_COMMENT_TEXT = ""
27 GERRIT_PROJECT = ""
Zack Williams03ebb272020-03-27 09:42:33 -070028 GERRIT_BRANCH = "${params.manualBranch}"
Andy Baviere06dcff2020-02-06 11:36:40 -070029 GERRIT_CHANGE_NUMBER = ""
30 GERRIT_PATCHSET_NUMBER = ""
Andy Bavier61c5b2a2019-11-12 12:08:19 -070031}
32
33pipeline {
34
35 /* no label, executor is determined by JJB */
36 agent {
37 label "${params.buildNode}"
38 }
39 options {
Andy Bavierb217c2d2020-02-21 14:25:50 -070040 timeout(time: 90, unit: 'MINUTES')
Andy Bavier61c5b2a2019-11-12 12:08:19 -070041 }
42
43 environment {
44 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
45 VOLTCONFIG="$HOME/.volt/config-minimal"
Andy Bavier6ba9f9c2019-12-12 17:54:53 -070046 PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Andy Bavier61c5b2a2019-11-12 12:08:19 -070047 TYPE="minimal"
48 FANCY=0
49 //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
50 ONOS_SSH_PORT=30115
51 ONOS_API_PORT=30120
52 }
53
54 stages {
55 stage ('Initialize') {
56 steps {
hwchiu1f0b0fe2019-12-06 11:45:23 -080057 sh returnStdout: false, script: """
Andy Bavier61c5b2a2019-11-12 12:08:19 -070058 test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down
59 cd $WORKSPACE
60 rm -rf $WORKSPACE/*
61 """
62 script {
63 if (env.configRepo && ! env.localConfigDir) {
64 env.localConfigDir = "$WORKSPACE"
hwchiu1f0b0fe2019-12-06 11:45:23 -080065 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configRepo}"
Andy Bavier61c5b2a2019-11-12 12:08:19 -070066 }
67 localDeploymentConfigFile = "${env.localConfigDir}/${params.deploymentConfigFile}"
68 localKindVolthaValuesFile = "${env.localConfigDir}/${params.kindVolthaValuesFile}"
69 localSadisConfigFile = "${env.localConfigDir}/${params.sadisConfigFile}"
Andy Bavier61c5b2a2019-11-12 12:08:19 -070070 }
71 }
72 }
73
Andy Bavier06d816c2019-11-19 11:40:48 -070074 stage('Repo') {
75 steps {
76 checkout(changelog: true,
77 poll: false,
78 scm: [$class: 'RepoScm',
79 manifestRepositoryUrl: "${params.manifestUrl}",
Zack Williams03ebb272020-03-27 09:42:33 -070080 manifestBranch: "${params.branch}",
Andy Bavier06d816c2019-11-19 11:40:48 -070081 currentBranch: true,
82 destinationDir: 'voltha',
83 forceSync: true,
84 resetFirst: true,
85 quiet: true,
86 jobs: 4,
87 showAllChanges: true]
88 )
89 }
90 }
91
Andy Bavier61c5b2a2019-11-12 12:08:19 -070092 stage('Get Patch') {
93 when {
Zack Williams03ebb272020-03-27 09:42:33 -070094 expression { params.manualBranch != "" }
Andy Bavier61c5b2a2019-11-12 12:08:19 -070095 }
96 steps {
Andy Bavier61c5b2a2019-11-12 12:08:19 -070097 sh returnStdout: false, script: """
98 cd voltha
Andy Bavier5b523532020-02-24 15:31:25 -070099 repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700100 """
101 }
102 }
103
Andy Bavier9a376602019-11-13 11:53:37 -0700104 stage('Check config files') {
105 steps {
Andy Bavier85ab0942019-11-13 14:43:25 -0700106 script {
107 try {
108 deployment_config = readYaml file: "${localDeploymentConfigFile}"
109 } catch (err) {
110 echo "Error reading ${localDeploymentConfigFile}"
111 throw err
112 }
113 sh returnStdout: false, script: """
114 if [ ! -e ${localKindVolthaValuesFile} ]; then echo "${localKindVolthaValuesFile} not found"; exit 1; fi
115 if [ ! -e ${localSadisConfigFile} ]; then echo "${localSadisConfigFile} not found"; exit 1; fi
116 """
Andy Bavier9a376602019-11-13 11:53:37 -0700117 }
Andy Bavier9a376602019-11-13 11:53:37 -0700118 }
119 }
120
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700121 stage('Create KinD Cluster') {
122 steps {
123 sh returnStdout: false, script: """
124 git clone https://github.com/ciena/kind-voltha.git
Zack Williams03ebb272020-03-27 09:42:33 -0700125
126 if [ "${branch}" != "master" ]; then
127 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
128 source "kind-voltha/releases/${branch}"
129 else
130 echo "on master, using default settings for kind-voltha"
131 fi
132
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700133 cd kind-voltha/
134 JUST_K8S=y ./voltha up
135 """
136 }
137 }
138
139 stage('Build and Push Images') {
140 when {
Zack Williams03ebb272020-03-27 09:42:33 -0700141 expression { params.manualBranch != "" }
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700142 }
143 steps {
144 sh returnStdout: false, script: """
Zack Williams03ebb272020-03-27 09:42:33 -0700145
146 if [ "${branch}" != "master" ]; then
147 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
148 source "kind-voltha/releases/${branch}"
149 else
150 echo "on master, using default settings for kind-voltha"
151 fi
152
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700153 if ! [[ "${gerritProject}" =~ ^(voltha-system-tests)\$ ]]; then
154 make -C $WORKSPACE/voltha/${gerritProject} DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
155 docker images | grep citest
156 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}")
157 do
158 echo "Pushing \$image to nodes"
159 kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2
160 docker rmi \$image:citest \$image:latest || true
161 done
162 fi
163 """
164 }
165 }
166
167 stage('Deploy Voltha') {
168 environment {
169 WITH_SIM_ADAPTERS="n"
170 WITH_RADIUS="y"
171 DEPLOY_K8S="n"
172 VOLTHA_LOG_LEVEL="debug"
173 }
174 steps {
175 script {
Andy Baviere06dcff2020-02-06 11:36:40 -0700176 sh returnStdout: false, script: """
Zack Williams03ebb272020-03-27 09:42:33 -0700177 if [ "${branch}" != "master" ]; then
178 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
179 source "kind-voltha/releases/${branch}"
180 else
181 echo "on master, using default settings for kind-voltha"
182 fi
183
184 export EXTRA_HELM_FLAGS+='--set log_agent.enabled=False -f ${localKindVolthaValuesFile} '
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700185
Andy Baviere06dcff2020-02-06 11:36:40 -0700186 IMAGES=""
187 if [ "${gerritProject}" = "voltha-go" ]; then
188 IMAGES="rw_core ro_core "
189 elif [ "${gerritProject}" = "ofagent-py" ]; then
190 IMAGES="ofagent "
191 elif [ "${gerritProject}" = "voltha-onos" ]; then
192 IMAGES="onos "
193 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
194 IMAGES="adapter_open_olt "
195 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
196 IMAGES="adapter_open_onu "
197 elif [ "${gerritProject}" = "voltha-api-server" ]; then
198 IMAGES="afrouter afrouterd "
199 else
200 echo "No images to push"
201 fi
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700202
Andy Baviere06dcff2020-02-06 11:36:40 -0700203 for I in \$IMAGES
204 do
205 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
206 done
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700207
Andy Baviere06dcff2020-02-06 11:36:40 -0700208 cd $WORKSPACE/kind-voltha/
209 echo \$EXTRA_HELM_FLAGS
210 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
211 ./voltha up
212 """
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700213 }
214 }
215 }
216
Scott Bakerfb0284c2019-12-12 17:22:38 -0800217 stage('Deploy Kafka Dump Chart') {
218 steps {
219 script {
220 sh returnStdout: false, script: """
221 helm repo add cord https://charts.opencord.org
222 helm repo update
223 helm install -n voltha-kafka-dump cord/voltha-kafka-dump
224 """
225 }
226 }
227 }
228
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700229 stage('Push Tech-Profile') {
230 when {
231 expression { params.profile != "Default" }
232 }
233 steps {
234 sh returnStdout: false, script: """
235 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
236 kubectl cp $WORKSPACE/voltha/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
Andy Bavier6ebf3182019-11-21 13:47:21 -0700237 kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700238 """
239 }
240 }
241
242 stage('Push Sadis-config') {
243 steps {
244 sh returnStdout: false, script: """
245 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:$ONOS_API_PORT/onos/v1/network/configuration --data @${localSadisConfigFile}
246 """
247 }
248 }
249
250 stage('Reinstall OLT software') {
251 when {
252 expression { params.reinstallOlt }
253 }
254 steps {
255 script {
256 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800257 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true"
258 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'killall dev_mgmt_daemon' || true"
259 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700260 waitUntil {
261 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
262 return olt_sw_present.toInteger() == 0
263 }
hwchiu1f0b0fe2019-12-06 11:45:23 -0800264 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700265 waitUntil {
266 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
267 return olt_sw_present.toInteger() == 1
268 }
269 if ( olt.fortygig ) {
270 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
hwchiu1f0b0fe2019-12-06 11:45:23 -0800271 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'echo port ce128 sp=40000 >> /broadcom/qax.soc ; /opt/bcm68620/svk_init.sh'"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700272 }
273 }
274 }
275 }
276 }
277
278 stage('Restart OLT processes') {
279 steps {
280 script {
281 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800282 sh returnStdout: false, script: """
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700283 ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700284 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true
Andy Bavierb502a372019-11-22 01:05:04 +0000285 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'killall dev_mgmt_daemon' || true
Andy Bavierfc4dcc42019-11-18 15:33:52 -0700286 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/openolt.log'
Andy Bavierbecaa8e2020-01-08 11:49:57 -0700287 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/dev_mgmt_daemon.log'
Andy Bavierb502a372019-11-22 01:05:04 +0000288 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service dev_mgmt_daemon start &'
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700289 sleep 5
290 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt start &'
291 """
292 waitUntil {
293 onu_discovered = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'grep \"onu discover indication\" /var/log/openolt.log | wc -l'"
294 return onu_discovered.toInteger() > 0
295 }
296 }
297 }
298 }
299 }
300
301 stage('Run E2E Tests') {
302 environment {
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700303 ROBOT_CONFIG_FILE="${localDeploymentConfigFile}"
Andy Bavierd3be2bf2020-02-07 17:02:21 -0700304 ROBOT_MISC_ARGS="${params.extraRobotArgs} --removekeywords wuks -d $WORKSPACE/RobotLogs -v container_log_dir:$WORKSPACE "
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700305 ROBOT_FILE="Voltha_PODTests.robot"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700306 }
307 steps {
308 sh returnStdout: false, script: """
309 cd voltha
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700310 mkdir -p $WORKSPACE/RobotLogs
Andy Baviere06dcff2020-02-06 11:36:40 -0700311
312 # If the Gerrit comment contains a line with "functional tests" then run the full
313 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
314 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
315 REGEX="functional tests"
316 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
317 ROBOT_MISC_ARGS+="-i functional"
318 fi
319
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700320 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700321 """
322 }
323 }
Scott Bakerda31d7b2020-01-08 16:35:52 -0800324
325 stage('After-Test Delay') {
Andy Bavier4af02722020-01-15 10:24:24 -0700326 when {
Zack Williams03ebb272020-03-27 09:42:33 -0700327 expression { params.manualBranch != "" }
Andy Bavier4af02722020-01-15 10:24:24 -0700328 }
Scott Bakerda31d7b2020-01-08 16:35:52 -0800329 steps {
330 sh returnStdout: false, script: """
331 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
332 REGEX="hardware test with delay\$"
333 [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]] && sleep 10m || true
334 """
335 }
336 }
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700337 }
338
339 post {
340 always {
Andy Bavier4af02722020-01-15 10:24:24 -0700341 sh returnStdout: false, script: '''
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700342 set +e
343 cp kind-voltha/install-minimal.log $WORKSPACE/
344 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
345 kubectl get nodes -o wide
346 kubectl get pods -o wide
347 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700348
349 sync
350 pkill kail || true
351
352 ## Pull out errors from log files
353 extract_errors_go() {
354 echo
355 echo "Error summary for $1:"
356 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
357 echo
358 }
359
360 extract_errors_python() {
361 echo
362 echo "Error summary for $1:"
363 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
364 echo
365 }
366
367 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
368 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
369 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
370 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
371
Andy Bavier2178d102020-02-06 16:22:11 -0700372 gzip $WORKSPACE/onos-voltha-combined.log
373
Scott Bakerfb0284c2019-12-12 17:22:38 -0800374 ## collect events, the chart should be running by now
375 kubectl get pods | grep -i voltha-kafka-dump | grep -i running
Andy Bavier4af02722020-01-15 10:24:24 -0700376 if [[ $? == 0 ]]; then
Scott Bakerfb0284c2019-12-12 17:22:38 -0800377 kubectl exec -it `kubectl get pods | grep -i voltha-kafka-dump | grep -i running | cut -f1 -d " "` ./voltha-dump-events.sh > $WORKSPACE/voltha-events.log
378 fi
Andy Bavier4af02722020-01-15 10:24:24 -0700379 '''
Andy Bavier6ebf3182019-11-21 13:47:21 -0700380 script {
381 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800382 sh returnStdout: false, script: """
Andy Bavier6ebf3182019-11-21 13:47:21 -0700383 sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log || true
384 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.ip}.log # Remove escape sequences
Andy Bavierbecaa8e2020-01-08 11:49:57 -0700385 sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log || true
386 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log # Remove escape sequences
Andy Bavier6ebf3182019-11-21 13:47:21 -0700387 """
388 }
389 }
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700390 step([$class: 'RobotPublisher',
391 disableArchiveOutput: false,
392 logFileName: 'RobotLogs/log*.html',
393 otherFiles: '',
394 outputFileName: 'RobotLogs/output*.xml',
395 outputPath: '.',
Andy Baviere19b67b2020-02-14 11:29:50 -0700396 passThreshold: 100,
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700397 reportFileName: 'RobotLogs/report*.html',
398 unstableThreshold: 0]);
Andy Bavier2178d102020-02-06 16:22:11 -0700399 archiveArtifacts artifacts: '*.log,*.gz'
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700400 }
401 }
402}