blob: b71ad9c06d71dc39ea6b5af27d2acabf267e5c1b [file] [log] [blame]
Suchitra Vemuriddb27792018-08-23 15:29:42 -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
Suchitra Vemuriddb27792018-08-23 15:29:42 -070015node ("${TestNodeName}") {
Luca Preteb3029bd2018-08-28 16:31:39 -070016 timeout (100) {
17 try {
18 stage ("Parse deployment configuration file") {
Kailash58255ca2018-12-19 09:48:46 -080019 sh returnStdout: true, script: "rm -rf ${configBaseDir} helm-charts"
You Wangd6c5e8c2018-08-29 12:49:51 -070020 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
You Wang59ded6c2018-10-05 17:43:44 -070021 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
Suchitra Vemuriddb27792018-08-23 15:29:42 -070022 }
Luca Preteb3029bd2018-08-28 16:31:39 -070023 stage('Clean up') {
24 timeout(10) {
25 sh returnStdout: true, script: """
You Wangd6c5e8c2018-08-29 12:49:51 -070026 git clone -b ${branch} ${cordRepoUrl}/helm-charts
Luca Preteb3029bd2018-08-28 16:31:39 -070027 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete5a970152018-08-29 15:20:47 -070028 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
Luca Preteb3029bd2018-08-28 16:31:39 -070029 do
30 echo "Purging chart: \${hchart}"
31 helm delete --purge "\${hchart}"
32 done
Suchitra Vemuriddb27792018-08-23 15:29:42 -070033 """
Luca Preteb3029bd2018-08-28 16:31:39 -070034 timeout(5) {
35 waitUntil {
36 helm_deleted = sh returnStdout: true, script: """
37 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070038 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
Suchitra Vemuriddb27792018-08-23 15:29:42 -070039 """
Luca Preteb3029bd2018-08-28 16:31:39 -070040 return helm_deleted.toInteger() == 0
41 }
42 }
43 timeout(5) {
44 waitUntil {
45 kubectl_deleted = sh returnStdout: true, script: """
46 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070047 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
Luca Preteb3029bd2018-08-28 16:31:39 -070048 """
49 return kubectl_deleted.toInteger() == 0
Suchitra Vemuriddb27792018-08-23 15:29:42 -070050 }
51 }
Luca Prete79fbc602018-09-24 15:33:31 -070052 // timeout(5) {
53 // waitUntil {
54 // kubectl_deleted = sh returnStdout: true, script: """
55 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
56 // kubectl get statefulset --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
57 // """
58 // return kubectl_deleted.toInteger() == 0
59 // }
60 // }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070061 }
62 }
Kailash4321b4d2018-12-18 13:11:08 -080063 stage('Add CORD repository') {
64 sh returnStdout: true, script: """
65 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
66 helm repo add cord https://charts.opencord.org
67 helm repo update
68 """
69 timeout(1) {
70 waitUntil {
71 cord_repo_present = sh returnStdout: true, script: """
72 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
73 helm repo list | grep cord | wc -l
Kailash Khalasi100cf462018-09-20 10:24:57 -070074 """
Kailash4321b4d2018-12-18 13:11:08 -080075 return cord_repo_present.toInteger() == 1
Matteo Scandolo2f8271f2018-12-12 15:54:54 -080076 }
77 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070078 }
Kailash58255ca2018-12-19 09:48:46 -080079 dir ("helm-charts") {
80 stage('Install CORD Kafka') {
81 timeout(10) {
82 sh returnStdout: true, script: """
83 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
84 helm install -f examples/kafka-single.yaml --version 0.8.8 -n cord-kafka incubator/kafka
Kailash4321b4d2018-12-18 13:11:08 -080085 """
Kailash58255ca2018-12-19 09:48:46 -080086 }
87 timeout(10) {
88 waitUntil {
89 kafka_instances_running = sh returnStdout: true, script: """
90 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
91 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
92 """
93 return kafka_instances_running.toInteger() == 2
94 }
Kailash4321b4d2018-12-18 13:11:08 -080095 }
96 }
Kailash58255ca2018-12-19 09:48:46 -080097 stage('Install Logging Infrastructure') {
98 timeout(10) {
99 sh returnStdout: true, script: """
100 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
101 helm install -f examples/logging-single.yaml -n logging cord/logging
102 scripts/wait_for_pods.sh
Kailash4321b4d2018-12-18 13:11:08 -0800103 """
Kailash4321b4d2018-12-18 13:11:08 -0800104 }
105 }
Kailash58255ca2018-12-19 09:48:46 -0800106 stage('Install Monitoring Infrastructure') {
107 timeout(10) {
108 sh returnStdout: true, script: """
109 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
110 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
111 scripts/wait_for_pods.sh
Kailash4321b4d2018-12-18 13:11:08 -0800112 """
Kailash4321b4d2018-12-18 13:11:08 -0800113 }
114 }
Kailash58255ca2018-12-19 09:48:46 -0800115 stage('Install etcd-cluster') {
116 timeout(10) {
117 sh returnStdout: true, script: """
118 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
119 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
Kailash4321b4d2018-12-18 13:11:08 -0800120 """
Kailash58255ca2018-12-19 09:48:46 -0800121 }
122 timeout(10) {
123 waitUntil {
124 etcd_running = sh returnStdout: true, script: """
125 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
126 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
127 """
128 return etcd_running.toInteger() == 3
129 }
Kailash4321b4d2018-12-18 13:11:08 -0800130 }
131 }
Kailash58255ca2018-12-19 09:48:46 -0800132 stage('Install voltha') {
133 timeout(10) {
134 sh returnStdout: true, script: """
135 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
136 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
137 helm dep build voltha
138 helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
Kailash4321b4d2018-12-18 13:11:08 -0800139 """
Kailash58255ca2018-12-19 09:48:46 -0800140 }
141 timeout(10) {
142 waitUntil {
143 voltha_completed = sh returnStdout: true, script: """
144 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
145 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
146 """
147 return voltha_completed.toInteger() == 8
148 }
Kailash4321b4d2018-12-18 13:11:08 -0800149 }
150 }
Kailash58255ca2018-12-19 09:48:46 -0800151 stage('Install ONOS') {
152 timeout(10) {
153 sh returnStdout: true, script: """
154 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
155 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
Kailash4321b4d2018-12-18 13:11:08 -0800156 """
Kailash58255ca2018-12-19 09:48:46 -0800157 }
158 timeout(10) {
159 waitUntil {
160 onos_completed = sh returnStdout: true, script: """
161 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
162 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
163 """
164 return onos_completed.toInteger() == 1
165 }
Kailash4321b4d2018-12-18 13:11:08 -0800166 }
167 }
Kailash58255ca2018-12-19 09:48:46 -0800168 stage('Install xos-core') {
169 timeout(10) {
170 sh returnStdout: true, script: """
171 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
172 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
Kailash4321b4d2018-12-18 13:11:08 -0800173 """
Kailash58255ca2018-12-19 09:48:46 -0800174 }
175 timeout(10) {
176 waitUntil {
177 xos_core_completed = sh returnStdout: true, script: """
178 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
179 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
180 """
181 return xos_core_completed.toInteger() == 6
182 }
Kailash4321b4d2018-12-18 13:11:08 -0800183 }
184 }
Kailash58255ca2018-12-19 09:48:46 -0800185 stage('Install seba-services profile') {
186 timeout(10) {
187 sh returnStdout: true, script: """
188 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
189 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
Kailash4321b4d2018-12-18 13:11:08 -0800190 """
Kailash58255ca2018-12-19 09:48:46 -0800191 }
192 timeout(10) {
193 waitUntil {
194 att_workflow_tosca_completed = sh returnStdout: true, script: """
195 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
196 kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
197 """
198 return att_workflow_tosca_completed.toInteger() == 1
199 }
200 }
201 }
202 stage('Install base-kubernetes') {
203 timeout(10) {
204 sh returnStdout: true, script: """
205 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
206 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes
207 """
208 }
209 timeout(10) {
210 waitUntil {
211 base_kubernetes_tosca_running = sh returnStdout: true, script: """
212 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
213 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
214 """
215 return base_kubernetes_tosca_running.toInteger() == 1
216 }
217 }
218 }
219 stage('Install att workflow') {
220 timeout(10) {
221 sh returnStdout: true, script: """
222 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
223 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow cord/att-workflow
224 """
225 }
226 timeout(10) {
227 waitUntil {
228 att_workflow_tosca_completed = sh returnStdout: true, script: """
229 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
230 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
231 """
232 return att_workflow_tosca_completed.toInteger() == 1
233 }
Kailash4321b4d2018-12-18 13:11:08 -0800234 }
235 }
236 }
237
Kailash9b56c862018-11-29 08:45:25 -0800238 if ( params.reinstallOlt ) {
239 stage('Reinstall OLT software') {
240 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700241 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800242 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'
Luca Preteb3029bd2018-08-28 16:31:39 -0700243 """
Kailash9b56c862018-11-29 08:45:25 -0800244 timeout(5) {
245 waitUntil {
246 olt_sw_present = sh returnStdout: true, script: """
247 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
248 """
249 return olt_sw_present.toInteger() == 0
250 }
251 }
252 sh returnStdout: true, script: """
253 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
254 """
255 timeout(5) {
256 waitUntil {
257 olt_sw_present = sh returnStdout: true, script: """
258 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
259 """
260 return olt_sw_present.toInteger() == 1
261 }
262 }
263 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
264 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
265 sh returnStdout: true, script: """
266 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
267 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
268 """
269 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700270 }
271 }
Kailash9b56c862018-11-29 08:45:25 -0800272 stage('Restart OLT processes') {
273 for(int i=0; i < deployment_config.olts.size(); i++) {
274 timeout(5) {
275 sh returnStdout: true, script: """
276 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
277 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist stop' || true
278 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
279 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/bal_core_dist.log'
280 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
281 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
282 sleep 5
283 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
284 """
285 }
286 timeout(15) {
287 waitUntil {
288 onu_discovered = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cat /var/log/openolt.log | grep \"oper_state: up\" | wc -l'"
289 return onu_discovered.toInteger() > 0
290 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700291 }
292 }
293 }
294 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700295 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700296 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700297 stage('Configure R-CORD - Fabric and whitelist') {
298 timeout(1) {
299 waitUntil {
300 out_fabric = sh returnStdout: true, script: """
301 curl -s -H "xos-username:admin@opencord.org" -H "xos-password:letmein" -X POST --data-binary @${configFileName}-fabric.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
302 """
303 return out_fabric.toInteger() == 1
304 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700305 }
306 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700307 stage('Configure R-CORD - Subscriber') {
308 timeout(1) {
309 waitUntil {
310 out_subscriber = sh returnStdout: true, script: """
311 curl -s -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-subscriber.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
312 """
313 return out_subscriber.toInteger() == 1
314 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700315 }
316 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700317 stage('Configure R-CORD - OLT') {
318 timeout(1) {
319 waitUntil {
320 out_olt = sh returnStdout: true, script: """
321 curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-olt.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
322 """
323 return out_olt.toInteger() == 1
324 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700325 }
326 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700327 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700328 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800329 if ( params.installBBSim ) {
330 dir ("helm-charts") {
331 stage('Install BBSim') {
332 timeout(10) {
333 sh returnStdout: true, script: """
334 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Kailash58255ca2018-12-19 09:48:46 -0800335 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800336 """
337 }
338 timeout(10) {
339 waitUntil {
340 base_kubernetes_tosca_running = sh returnStdout: true, script: """
341 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
342 kubectl get pods -n voltha | grep -i bbsim | wc -l
343 """
344 return base_kubernetes_tosca_running.toInteger() == 1
345 }
346 }
347 }
348 }
349 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
350 stage('Configure BBSim - OLT') {
351 timeout(1) {
352 waitUntil {
353 out_olt = sh returnStdout: true, script: """
354 curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @bbsim-16.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
355 """
356 return out_olt.toInteger() == 1
357 }
358 }
359 }
360 }
361 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700362 currentBuild.result = 'SUCCESS'
363 } catch (err) {
364 currentBuild.result = 'FAILURE'
365 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
366 }
367 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700368 }
369}