blob: 14789a8415619f6f80abacb686b61b712d8ad143 [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") {
You Wangd6c5e8c2018-08-29 12:49:51 -070019 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
You Wang59ded6c2018-10-05 17:43:44 -070020 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
Suchitra Vemuriddb27792018-08-23 15:29:42 -070021 }
Luca Preteb3029bd2018-08-28 16:31:39 -070022 stage('Clean up') {
23 timeout(10) {
24 sh returnStdout: true, script: """
Luca Preteb3029bd2018-08-28 16:31:39 -070025 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete5a970152018-08-29 15:20:47 -070026 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
Luca Preteb3029bd2018-08-28 16:31:39 -070027 do
28 echo "Purging chart: \${hchart}"
29 helm delete --purge "\${hchart}"
30 done
Suchitra Vemuriddb27792018-08-23 15:29:42 -070031 """
Luca Preteb3029bd2018-08-28 16:31:39 -070032 timeout(5) {
33 waitUntil {
34 helm_deleted = sh returnStdout: true, script: """
35 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070036 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
Suchitra Vemuriddb27792018-08-23 15:29:42 -070037 """
Luca Preteb3029bd2018-08-28 16:31:39 -070038 return helm_deleted.toInteger() == 0
39 }
40 }
41 timeout(5) {
42 waitUntil {
43 kubectl_deleted = sh returnStdout: true, script: """
44 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070045 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 -070046 """
47 return kubectl_deleted.toInteger() == 0
Suchitra Vemuriddb27792018-08-23 15:29:42 -070048 }
49 }
Luca Prete79fbc602018-09-24 15:33:31 -070050 // timeout(5) {
51 // waitUntil {
52 // kubectl_deleted = sh returnStdout: true, script: """
53 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
54 // kubectl get statefulset --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
55 // """
56 // return kubectl_deleted.toInteger() == 0
57 // }
58 // }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070059 }
60 }
Kailash4321b4d2018-12-18 13:11:08 -080061 stage('Add CORD repository') {
62 sh returnStdout: true, script: """
63 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
64 helm repo add cord https://charts.opencord.org
65 helm repo update
66 """
67 timeout(1) {
68 waitUntil {
69 cord_repo_present = sh returnStdout: true, script: """
70 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
71 helm repo list | grep cord | wc -l
Kailash Khalasi100cf462018-09-20 10:24:57 -070072 """
Kailash4321b4d2018-12-18 13:11:08 -080073 return cord_repo_present.toInteger() == 1
Matteo Scandolo2f8271f2018-12-12 15:54:54 -080074 }
75 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070076 }
Luca Prete31eda022018-12-21 13:49:44 -080077 stage('Install CORD Kafka') {
78 timeout(10) {
79 sh returnStdout: true, script: """
80 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
81 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
82 """
83 }
84 timeout(10) {
85 waitUntil {
86 kafka_instances_running = sh returnStdout: true, script: """
87 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
88 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -080089 """
Luca Prete31eda022018-12-21 13:49:44 -080090 return kafka_instances_running.toInteger() == 2
Kailash4321b4d2018-12-18 13:11:08 -080091 }
92 }
Luca Prete31eda022018-12-21 13:49:44 -080093 }
94 stage('Install Logging Infrastructure') {
95 timeout(10) {
96 sh returnStdout: true, script: """
97 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
98 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
99 scripts/wait_for_pods.sh
100 """
101 }
102 }
103 stage('Install Monitoring Infrastructure') {
104 timeout(10) {
105 sh returnStdout: true, script: """
106 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
107 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
108 scripts/wait_for_pods.sh
109 """
110 }
111 }
112 stage('Install etcd-cluster') {
113 timeout(10) {
114 sh returnStdout: true, script: """
115 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
116 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
117 """
118 }
119 timeout(10) {
120 waitUntil {
121 etcd_running = sh returnStdout: true, script: """
122 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
123 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800124 """
Luca Prete31eda022018-12-21 13:49:44 -0800125 return etcd_running.toInteger() == 3
Kailash4321b4d2018-12-18 13:11:08 -0800126 }
127 }
Luca Prete31eda022018-12-21 13:49:44 -0800128 }
129 stage('Install voltha') {
130 timeout(10) {
131 sh returnStdout: true, script: """
132 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
133 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
134 helm dep build voltha
135 helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
136 """
137 }
138 timeout(10) {
139 waitUntil {
140 voltha_completed = sh returnStdout: true, script: """
141 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
142 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800143 """
Luca Prete31eda022018-12-21 13:49:44 -0800144 return voltha_completed.toInteger() == 8
Kailash4321b4d2018-12-18 13:11:08 -0800145 }
146 }
Luca Prete31eda022018-12-21 13:49:44 -0800147 }
148 stage('Install ONOS') {
149 timeout(10) {
150 sh returnStdout: true, script: """
151 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
152 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
153 """
154 }
155 timeout(10) {
156 waitUntil {
157 onos_completed = sh returnStdout: true, script: """
158 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
159 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800160 """
Luca Prete31eda022018-12-21 13:49:44 -0800161 return onos_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800162 }
163 }
Luca Prete31eda022018-12-21 13:49:44 -0800164 }
165 stage('Install xos-core') {
166 timeout(10) {
167 sh returnStdout: true, script: """
168 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
169 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
170 """
171 }
172 timeout(10) {
173 waitUntil {
174 xos_core_completed = sh returnStdout: true, script: """
175 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
176 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800177 """
Luca Prete31eda022018-12-21 13:49:44 -0800178 return xos_core_completed.toInteger() == 6
Kailash4321b4d2018-12-18 13:11:08 -0800179 }
180 }
Luca Prete31eda022018-12-21 13:49:44 -0800181 }
182 stage('Install seba-services') {
183 timeout(10) {
184 sh returnStdout: true, script: """
185 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
186 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
187 """
188 }
189 timeout(10) {
190 waitUntil {
191 att_workflow_tosca_completed = sh returnStdout: true, script: """
192 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
193 kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800194 """
Luca Prete31eda022018-12-21 13:49:44 -0800195 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800196 }
197 }
Luca Prete31eda022018-12-21 13:49:44 -0800198 }
199 stage('Install base-kubernetes') {
200 timeout(10) {
201 sh returnStdout: true, script: """
202 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
203 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes
204 """
205 }
206 timeout(10) {
207 waitUntil {
208 base_kubernetes_tosca_running = sh returnStdout: true, script: """
209 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
210 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800211 """
Luca Prete31eda022018-12-21 13:49:44 -0800212 return base_kubernetes_tosca_running.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800213 }
214 }
Luca Prete31eda022018-12-21 13:49:44 -0800215 }
216 stage('Install att workflow') {
217 timeout(10) {
218 sh returnStdout: true, script: """
219 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
220 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow cord/att-workflow
221 """
Kailash58255ca2018-12-19 09:48:46 -0800222 }
Luca Prete31eda022018-12-21 13:49:44 -0800223 timeout(10) {
224 waitUntil {
225 att_workflow_tosca_completed = sh returnStdout: true, script: """
226 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
227 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
Kailash58255ca2018-12-19 09:48:46 -0800228 """
Luca Prete31eda022018-12-21 13:49:44 -0800229 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800230 }
231 }
232 }
233
Kailash9b56c862018-11-29 08:45:25 -0800234 if ( params.reinstallOlt ) {
235 stage('Reinstall OLT software') {
236 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700237 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800238 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 -0700239 """
Kailash9b56c862018-11-29 08:45:25 -0800240 timeout(5) {
241 waitUntil {
242 olt_sw_present = sh returnStdout: true, script: """
243 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'
244 """
245 return olt_sw_present.toInteger() == 0
246 }
247 }
248 sh returnStdout: true, script: """
249 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
250 """
251 timeout(5) {
252 waitUntil {
253 olt_sw_present = sh returnStdout: true, script: """
254 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'
255 """
256 return olt_sw_present.toInteger() == 1
257 }
258 }
259 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
260 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
261 sh returnStdout: true, script: """
262 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'
263 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
264 """
265 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700266 }
267 }
Kailash9b56c862018-11-29 08:45:25 -0800268 stage('Restart OLT processes') {
269 for(int i=0; i < deployment_config.olts.size(); i++) {
270 timeout(5) {
271 sh returnStdout: true, script: """
272 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
273 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
274 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
275 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'
276 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
277 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
278 sleep 5
279 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
280 """
281 }
282 timeout(15) {
283 waitUntil {
284 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'"
285 return onu_discovered.toInteger() > 0
286 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700287 }
288 }
289 }
290 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700291 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700292 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700293 stage('Configure R-CORD - Fabric and whitelist') {
294 timeout(1) {
295 waitUntil {
296 out_fabric = sh returnStdout: true, script: """
297 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
298 """
299 return out_fabric.toInteger() == 1
300 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700301 }
302 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700303 stage('Configure R-CORD - Subscriber') {
304 timeout(1) {
305 waitUntil {
306 out_subscriber = sh returnStdout: true, script: """
307 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
308 """
309 return out_subscriber.toInteger() == 1
310 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700311 }
312 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700313 stage('Configure R-CORD - OLT') {
314 timeout(1) {
315 waitUntil {
316 out_olt = sh returnStdout: true, script: """
317 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
318 """
319 return out_olt.toInteger() == 1
320 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700321 }
322 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700323 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700324 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800325 if ( params.installBBSim ) {
Luca Prete31eda022018-12-21 13:49:44 -0800326 stage('Install BBSim') {
327 timeout(10) {
328 sh returnStdout: true, script: """
329 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
330 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
331 """
332 }
333 timeout(10) {
334 waitUntil {
335 bbsim_running = sh returnStdout: true, script: """
336 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
337 kubectl get pods -n voltha | grep -i bbsim | wc -l
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800338 """
Luca Prete31eda022018-12-21 13:49:44 -0800339 return bbsim_running.toInteger() == 1
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800340 }
341 }
342 }
343 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
344 stage('Configure BBSim - OLT') {
345 timeout(1) {
346 waitUntil {
347 out_olt = sh returnStdout: true, script: """
348 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
349 """
350 return out_olt.toInteger() == 1
351 }
352 }
353 }
354 }
355 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700356 currentBuild.result = 'SUCCESS'
357 } catch (err) {
358 currentBuild.result = 'FAILURE'
359 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
360 }
361 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700362 }
363}