blob: 77a0e09edfaefa21562122fba8dcd6736ebf3ea9 [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
18node {
19 // Need this so that deployment_config has global scope when it's read later
20 deployment_config = null
21 localDeploymentConfigFile = null
22 localKindVolthaValuesFile = null
23 localSadisConfigFile = null
24}
25
26pipeline {
27
28 /* no label, executor is determined by JJB */
29 agent {
30 label "${params.buildNode}"
31 }
32 options {
33 timeout(time: 60, unit: 'MINUTES')
34 }
35
36 environment {
37 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
38 VOLTCONFIG="$HOME/.volt/config-minimal"
Andy Bavier6ba9f9c2019-12-12 17:54:53 -070039 PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Andy Bavier61c5b2a2019-11-12 12:08:19 -070040 TYPE="minimal"
41 FANCY=0
42 //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
43 ONOS_SSH_PORT=30115
44 ONOS_API_PORT=30120
45 }
46
47 stages {
48 stage ('Initialize') {
49 steps {
hwchiu1f0b0fe2019-12-06 11:45:23 -080050 sh returnStdout: false, script: """
Andy Bavier61c5b2a2019-11-12 12:08:19 -070051 test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down
52 cd $WORKSPACE
53 rm -rf $WORKSPACE/*
54 """
55 script {
56 if (env.configRepo && ! env.localConfigDir) {
57 env.localConfigDir = "$WORKSPACE"
hwchiu1f0b0fe2019-12-06 11:45:23 -080058 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configRepo}"
Andy Bavier61c5b2a2019-11-12 12:08:19 -070059 }
60 localDeploymentConfigFile = "${env.localConfigDir}/${params.deploymentConfigFile}"
61 localKindVolthaValuesFile = "${env.localConfigDir}/${params.kindVolthaValuesFile}"
62 localSadisConfigFile = "${env.localConfigDir}/${params.sadisConfigFile}"
Andy Bavier61c5b2a2019-11-12 12:08:19 -070063 }
64 }
65 }
66
Andy Bavier06d816c2019-11-19 11:40:48 -070067 stage('Repo') {
68 steps {
69 checkout(changelog: true,
70 poll: false,
71 scm: [$class: 'RepoScm',
72 manifestRepositoryUrl: "${params.manifestUrl}",
73 manifestBranch: "${params.manifestBranch}",
74 currentBranch: true,
75 destinationDir: 'voltha',
76 forceSync: true,
77 resetFirst: true,
78 quiet: true,
79 jobs: 4,
80 showAllChanges: true]
81 )
82 }
83 }
84
Andy Bavier61c5b2a2019-11-12 12:08:19 -070085 stage('Get Patch') {
86 when {
87 expression { params.withPatchset }
88 }
89 steps {
Andy Bavier61c5b2a2019-11-12 12:08:19 -070090 sh returnStdout: false, script: """
91 cd voltha
92 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
93 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
94 """
95 }
96 }
97
Andy Bavier9a376602019-11-13 11:53:37 -070098 stage('Check config files') {
99 steps {
Andy Bavier85ab0942019-11-13 14:43:25 -0700100 script {
101 try {
102 deployment_config = readYaml file: "${localDeploymentConfigFile}"
103 } catch (err) {
104 echo "Error reading ${localDeploymentConfigFile}"
105 throw err
106 }
107 sh returnStdout: false, script: """
108 if [ ! -e ${localKindVolthaValuesFile} ]; then echo "${localKindVolthaValuesFile} not found"; exit 1; fi
109 if [ ! -e ${localSadisConfigFile} ]; then echo "${localSadisConfigFile} not found"; exit 1; fi
110 """
Andy Bavier9a376602019-11-13 11:53:37 -0700111 }
Andy Bavier9a376602019-11-13 11:53:37 -0700112 }
113 }
114
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700115 stage('Create KinD Cluster') {
116 steps {
117 sh returnStdout: false, script: """
118 git clone https://github.com/ciena/kind-voltha.git
119 cd kind-voltha/
120 JUST_K8S=y ./voltha up
121 """
122 }
123 }
124
125 stage('Build and Push Images') {
126 when {
127 expression { params.withPatchset }
128 }
129 steps {
130 sh returnStdout: false, script: """
131 if ! [[ "${gerritProject}" =~ ^(voltha-system-tests)\$ ]]; then
132 make -C $WORKSPACE/voltha/${gerritProject} DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
133 docker images | grep citest
134 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}")
135 do
136 echo "Pushing \$image to nodes"
137 kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2
138 docker rmi \$image:citest \$image:latest || true
139 done
140 fi
141 """
142 }
143 }
144
145 stage('Deploy Voltha') {
146 environment {
147 WITH_SIM_ADAPTERS="n"
148 WITH_RADIUS="y"
149 DEPLOY_K8S="n"
150 VOLTHA_LOG_LEVEL="debug"
151 }
152 steps {
153 script {
154 if ( params.withPatchset ) {
155 sh returnStdout: false, script: """
156 export EXTRA_HELM_FLAGS='-f ${localKindVolthaValuesFile} '
157
158 IMAGES=""
159 if [ "${gerritProject}" = "voltha-go" ]; then
Zack Williamse65b1ee2019-12-09 15:57:16 -0700160 IMAGES="rw_core ro_core "
161 elif [ "${gerritProject}" = "ofagent-py" ]; then
162 IMAGES="ofagent "
Matteo Scandolo70800a32020-01-06 11:55:27 -0800163 elif [ "${gerritProject}" = "voltha-onos" ]; then
164 IMAGES="onos "
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700165 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
166 IMAGES="adapter_open_olt "
167 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
168 IMAGES="adapter_open_onu "
169 elif [ "${gerritProject}" = "voltha-api-server" ]; then
170 IMAGES="afrouter afrouterd "
171 else
172 echo "No images to push"
173 fi
174
175 for I in \$IMAGES
176 do
177 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
178 done
179
180 cd $WORKSPACE/kind-voltha/
181 echo \$EXTRA_HELM_FLAGS
182 ./voltha up
183 """
184 } else {
185 sh returnStdout: false, script: """
186 export EXTRA_HELM_FLAGS='-f ${localKindVolthaValuesFile} '
187 cd $WORKSPACE/kind-voltha/
188 echo \$EXTRA_HELM_FLAGS
189 ./voltha up
190 """
191 }
192 }
193 }
194 }
195
Scott Bakerfb0284c2019-12-12 17:22:38 -0800196 stage('Deploy Kafka Dump Chart') {
197 steps {
198 script {
199 sh returnStdout: false, script: """
200 helm repo add cord https://charts.opencord.org
201 helm repo update
202 helm install -n voltha-kafka-dump cord/voltha-kafka-dump
203 """
204 }
205 }
206 }
207
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700208 stage('Push Tech-Profile') {
209 when {
210 expression { params.profile != "Default" }
211 }
212 steps {
213 sh returnStdout: false, script: """
214 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
215 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 -0700216 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 -0700217 """
218 }
219 }
220
221 stage('Push Sadis-config') {
222 steps {
223 sh returnStdout: false, script: """
224 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}
225 """
226 }
227 }
228
229 stage('Reinstall OLT software') {
230 when {
231 expression { params.reinstallOlt }
232 }
233 steps {
234 script {
235 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800236 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true"
237 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'killall dev_mgmt_daemon' || true"
238 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 -0700239 waitUntil {
240 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
241 return olt_sw_present.toInteger() == 0
242 }
hwchiu1f0b0fe2019-12-06 11:45:23 -0800243 sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700244 waitUntil {
245 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
246 return olt_sw_present.toInteger() == 1
247 }
248 if ( olt.fortygig ) {
249 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
hwchiu1f0b0fe2019-12-06 11:45:23 -0800250 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 -0700251 }
252 }
253 }
254 }
255 }
256
257 stage('Restart OLT processes') {
258 steps {
259 script {
260 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800261 sh returnStdout: false, script: """
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700262 ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700263 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true
Andy Bavierb502a372019-11-22 01:05:04 +0000264 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'killall dev_mgmt_daemon' || true
Andy Bavierfc4dcc42019-11-18 15:33:52 -0700265 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/openolt.log'
Andy Bavierbecaa8e2020-01-08 11:49:57 -0700266 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 +0000267 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service dev_mgmt_daemon start &'
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700268 sleep 5
269 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt start &'
270 """
271 waitUntil {
272 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'"
273 return onu_discovered.toInteger() > 0
274 }
275 }
276 }
277 }
278 }
279
280 stage('Run E2E Tests') {
281 environment {
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700282 ROBOT_CONFIG_FILE="${localDeploymentConfigFile}"
Andy Bavier96c428f2019-12-17 11:27:45 -0700283 ROBOT_MISC_ARGS="${params.extraRobotArgs} --removekeywords wuks -d $WORKSPACE/RobotLogs"
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700284 ROBOT_FILE="Voltha_PODTests.robot"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700285 }
286 steps {
287 sh returnStdout: false, script: """
288 cd voltha
289 git clone -b ${branch} ${cordRepoUrl}/cord-tester
290 git clone -b ${branch} ${cordRepoUrl}/voltha # VOL-2104 recommends we get rid of this
291 mkdir -p $WORKSPACE/RobotLogs
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700292 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700293 """
294 }
295 }
296 }
297
298 post {
299 always {
hwchiu1f0b0fe2019-12-06 11:45:23 -0800300 sh returnStdout: false, script: """
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700301 set +e
302 cp kind-voltha/install-minimal.log $WORKSPACE/
303 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
304 kubectl get nodes -o wide
305 kubectl get pods -o wide
306 kubectl get pods -n voltha -o wide
307 ## get default pod logs
308 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
309 do
310 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
311 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
312 else
313 kubectl logs \$pod> $WORKSPACE/\$pod.log;
314 fi
315 done
316 ## get voltha pod logs
317 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
318 do
319 if [[ \$pod == *"-api-"* ]]; then
320 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
321 elif [[ \$pod == "bbsim-"* ]]; then
322 kubectl logs \$pod -n voltha -p > $WORKSPACE/\$pod.log;
323 else
324 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
325 fi
326 done
Scott Bakerfb0284c2019-12-12 17:22:38 -0800327 ## collect events, the chart should be running by now
328 kubectl get pods | grep -i voltha-kafka-dump | grep -i running
329 if [[ \$? == 0 ]]; then
330 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
331 fi
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700332 """
Andy Bavier6ebf3182019-11-21 13:47:21 -0700333 script {
334 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800335 sh returnStdout: false, script: """
Andy Bavier6ebf3182019-11-21 13:47:21 -0700336 sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log || true
337 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 -0700338 sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log || true
339 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 -0700340 """
341 }
342 }
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700343 step([$class: 'RobotPublisher',
344 disableArchiveOutput: false,
345 logFileName: 'RobotLogs/log*.html',
346 otherFiles: '',
347 outputFileName: 'RobotLogs/output*.xml',
348 outputPath: '.',
349 passThreshold: 80,
350 reportFileName: 'RobotLogs/report*.html',
351 unstableThreshold: 0]);
352 archiveArtifacts artifacts: '*.log'
353 }
354 }
355}