blob: 9c70e3797d6add180c26ac7f88a655fce6e8cc7c [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") {
Luca Preted0709122018-12-21 15:17:37 -080019 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
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: """
Luca Preteb3029bd2018-08-28 16:31:39 -070026 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete5a970152018-08-29 15:20:47 -070027 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
Luca Preteb3029bd2018-08-28 16:31:39 -070028 do
29 echo "Purging chart: \${hchart}"
30 helm delete --purge "\${hchart}"
31 done
Suchitra Vemuriddb27792018-08-23 15:29:42 -070032 """
Luca Preteb3029bd2018-08-28 16:31:39 -070033 timeout(5) {
34 waitUntil {
35 helm_deleted = sh returnStdout: true, script: """
36 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070037 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
Suchitra Vemuriddb27792018-08-23 15:29:42 -070038 """
Luca Preteb3029bd2018-08-28 16:31:39 -070039 return helm_deleted.toInteger() == 0
40 }
41 }
42 timeout(5) {
43 waitUntil {
44 kubectl_deleted = sh returnStdout: true, script: """
45 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070046 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 -070047 """
48 return kubectl_deleted.toInteger() == 0
Suchitra Vemuriddb27792018-08-23 15:29:42 -070049 }
50 }
Luca Prete79fbc602018-09-24 15:33:31 -070051 // timeout(5) {
52 // waitUntil {
53 // kubectl_deleted = sh returnStdout: true, script: """
54 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
55 // kubectl get statefulset --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
56 // """
57 // return kubectl_deleted.toInteger() == 0
58 // }
59 // }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070060 }
61 }
Kailash4321b4d2018-12-18 13:11:08 -080062 stage('Add CORD repository') {
63 sh returnStdout: true, script: """
64 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
65 helm repo add cord https://charts.opencord.org
66 helm repo update
67 """
68 timeout(1) {
69 waitUntil {
70 cord_repo_present = sh returnStdout: true, script: """
71 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
72 helm repo list | grep cord | wc -l
Kailash Khalasi100cf462018-09-20 10:24:57 -070073 """
Kailash4321b4d2018-12-18 13:11:08 -080074 return cord_repo_present.toInteger() == 1
Matteo Scandolo2f8271f2018-12-12 15:54:54 -080075 }
76 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070077 }
Luca Prete31eda022018-12-21 13:49:44 -080078 stage('Install CORD Kafka') {
79 timeout(10) {
80 sh returnStdout: true, script: """
81 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
82 helm install --version 0.8.8 --set configurationOverrides."offsets.topic.replication.factor"=1 --set configurationOverrides."log.retention.hours"=4 --set configurationOverrides."log.message.timestamp.type"="LogAppendTime" --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false -n cord-kafka incubator/kafka
83 """
84 }
85 timeout(10) {
86 waitUntil {
87 kafka_instances_running = sh returnStdout: true, script: """
88 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
89 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -080090 """
Luca Prete31eda022018-12-21 13:49:44 -080091 return kafka_instances_running.toInteger() == 2
Kailash4321b4d2018-12-18 13:11:08 -080092 }
93 }
Luca Prete31eda022018-12-21 13:49:44 -080094 }
95 stage('Install Logging Infrastructure') {
96 timeout(10) {
97 sh returnStdout: true, script: """
98 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
99 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set elasticsearch.cluster.env.MINIMUM_MASTER_NODES="1" --set elasticsearch.client.replicas=1 --set elasticsearch.master.replicas=2 --set elasticsearch.master.persistence.enabled=false --set elasticsearch.data.replicas=1 --set elasticsearch.data.persistence.enabled=false -n logging cord/logging
100 scripts/wait_for_pods.sh
101 """
102 }
103 }
104 stage('Install Monitoring Infrastructure') {
105 timeout(10) {
106 sh returnStdout: true, script: """
107 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
108 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
109 scripts/wait_for_pods.sh
110 """
111 }
112 }
113 stage('Install etcd-cluster') {
114 timeout(10) {
115 sh returnStdout: true, script: """
116 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
117 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
118 """
119 }
120 timeout(10) {
121 waitUntil {
122 etcd_running = sh returnStdout: true, script: """
123 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
124 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800125 """
Luca Prete31eda022018-12-21 13:49:44 -0800126 return etcd_running.toInteger() == 3
Kailash4321b4d2018-12-18 13:11:08 -0800127 }
128 }
Luca Prete31eda022018-12-21 13:49:44 -0800129 }
130 stage('Install voltha') {
131 timeout(10) {
132 sh returnStdout: true, script: """
133 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
134 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
135 helm dep build voltha
136 helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
137 """
138 }
139 timeout(10) {
140 waitUntil {
141 voltha_completed = sh returnStdout: true, script: """
142 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
143 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800144 """
Luca Prete31eda022018-12-21 13:49:44 -0800145 return voltha_completed.toInteger() == 8
Kailash4321b4d2018-12-18 13:11:08 -0800146 }
147 }
Luca Prete31eda022018-12-21 13:49:44 -0800148 }
149 stage('Install ONOS') {
150 timeout(10) {
151 sh returnStdout: true, script: """
152 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
153 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
154 """
155 }
156 timeout(10) {
157 waitUntil {
158 onos_completed = sh returnStdout: true, script: """
159 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
160 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800161 """
Luca Prete31eda022018-12-21 13:49:44 -0800162 return onos_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800163 }
164 }
Luca Prete31eda022018-12-21 13:49:44 -0800165 }
166 stage('Install xos-core') {
167 timeout(10) {
168 sh returnStdout: true, script: """
169 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
170 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
171 """
172 }
173 timeout(10) {
174 waitUntil {
175 xos_core_completed = sh returnStdout: true, script: """
176 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
177 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800178 """
Luca Prete31eda022018-12-21 13:49:44 -0800179 return xos_core_completed.toInteger() == 6
Kailash4321b4d2018-12-18 13:11:08 -0800180 }
181 }
Luca Prete31eda022018-12-21 13:49:44 -0800182 }
183 stage('Install seba-services') {
184 timeout(10) {
185 sh returnStdout: true, script: """
186 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
187 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
188 """
189 }
190 timeout(10) {
191 waitUntil {
192 att_workflow_tosca_completed = sh returnStdout: true, script: """
193 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
194 kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800195 """
Luca Prete31eda022018-12-21 13:49:44 -0800196 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800197 }
198 }
Luca Prete31eda022018-12-21 13:49:44 -0800199 }
200 stage('Install base-kubernetes') {
201 timeout(10) {
202 sh returnStdout: true, script: """
203 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
204 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes
205 """
206 }
207 timeout(10) {
208 waitUntil {
209 base_kubernetes_tosca_running = sh returnStdout: true, script: """
210 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
211 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800212 """
Luca Prete31eda022018-12-21 13:49:44 -0800213 return base_kubernetes_tosca_running.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800214 }
215 }
Luca Prete31eda022018-12-21 13:49:44 -0800216 }
217 stage('Install att workflow') {
218 timeout(10) {
219 sh returnStdout: true, script: """
220 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
221 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow cord/att-workflow
222 """
Kailash58255ca2018-12-19 09:48:46 -0800223 }
Luca Prete31eda022018-12-21 13:49:44 -0800224 timeout(10) {
225 waitUntil {
226 att_workflow_tosca_completed = sh returnStdout: true, script: """
227 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
228 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
Kailash58255ca2018-12-19 09:48:46 -0800229 """
Luca Prete31eda022018-12-21 13:49:44 -0800230 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800231 }
232 }
233 }
234
Kailash9b56c862018-11-29 08:45:25 -0800235 if ( params.reinstallOlt ) {
236 stage('Reinstall OLT software') {
237 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700238 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800239 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 -0700240 """
Kailash9b56c862018-11-29 08:45:25 -0800241 timeout(5) {
242 waitUntil {
243 olt_sw_present = sh returnStdout: true, script: """
244 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'
245 """
246 return olt_sw_present.toInteger() == 0
247 }
248 }
249 sh returnStdout: true, script: """
250 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
251 """
252 timeout(5) {
253 waitUntil {
254 olt_sw_present = sh returnStdout: true, script: """
255 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'
256 """
257 return olt_sw_present.toInteger() == 1
258 }
259 }
260 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
261 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
262 sh returnStdout: true, script: """
263 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'
264 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
265 """
266 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700267 }
268 }
Kailash9b56c862018-11-29 08:45:25 -0800269 stage('Restart OLT processes') {
270 for(int i=0; i < deployment_config.olts.size(); i++) {
271 timeout(5) {
272 sh returnStdout: true, script: """
273 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
274 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
275 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
276 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'
277 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
278 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
279 sleep 5
280 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
281 """
282 }
283 timeout(15) {
284 waitUntil {
285 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'"
286 return onu_discovered.toInteger() > 0
287 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700288 }
289 }
290 }
291 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700292 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700293 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700294 stage('Configure R-CORD - Fabric and whitelist') {
295 timeout(1) {
296 waitUntil {
297 out_fabric = sh returnStdout: true, script: """
298 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
299 """
300 return out_fabric.toInteger() == 1
301 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700302 }
303 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700304 stage('Configure R-CORD - Subscriber') {
305 timeout(1) {
306 waitUntil {
307 out_subscriber = sh returnStdout: true, script: """
308 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
309 """
310 return out_subscriber.toInteger() == 1
311 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700312 }
313 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700314 stage('Configure R-CORD - OLT') {
315 timeout(1) {
316 waitUntil {
317 out_olt = sh returnStdout: true, script: """
318 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
319 """
320 return out_olt.toInteger() == 1
321 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700322 }
323 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700324 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700325 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800326 if ( params.installBBSim ) {
Luca Prete31eda022018-12-21 13:49:44 -0800327 stage('Install BBSim') {
328 timeout(10) {
329 sh returnStdout: true, script: """
330 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
331 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
332 """
333 }
334 timeout(10) {
335 waitUntil {
336 bbsim_running = sh returnStdout: true, script: """
337 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
338 kubectl get pods -n voltha | grep -i bbsim | wc -l
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800339 """
Luca Prete31eda022018-12-21 13:49:44 -0800340 return bbsim_running.toInteger() == 1
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800341 }
342 }
343 }
344 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
345 stage('Configure BBSim - OLT') {
346 timeout(1) {
347 waitUntil {
348 out_olt = sh returnStdout: true, script: """
349 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
350 """
351 return out_olt.toInteger() == 1
352 }
353 }
354 }
355 }
356 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700357 currentBuild.result = 'SUCCESS'
358 } catch (err) {
359 currentBuild.result = 'FAILURE'
360 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
361 }
362 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700363 }
364}