blob: 4cbd34bad4118889fed28e1892be57199d35ca45 [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 Prete48634052018-12-21 15:31:51 -080019 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir}"
20 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
You Wangd6c5e8c2018-08-29 12:49:51 -070021 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
You Wang59ded6c2018-10-05 17:43:44 -070022 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
Suchitra Vemuriddb27792018-08-23 15:29:42 -070023 }
Luca Preteb3029bd2018-08-28 16:31:39 -070024 stage('Clean up') {
25 timeout(10) {
26 sh returnStdout: true, script: """
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 }
52 }
53 }
Kailash4321b4d2018-12-18 13:11:08 -080054 stage('Add CORD repository') {
55 sh returnStdout: true, script: """
56 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
57 helm repo add cord https://charts.opencord.org
58 helm repo update
59 """
60 timeout(1) {
61 waitUntil {
62 cord_repo_present = sh returnStdout: true, script: """
63 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
64 helm repo list | grep cord | wc -l
Kailash Khalasi100cf462018-09-20 10:24:57 -070065 """
Kailash4321b4d2018-12-18 13:11:08 -080066 return cord_repo_present.toInteger() == 1
Matteo Scandolo2f8271f2018-12-12 15:54:54 -080067 }
68 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070069 }
Luca Prete31eda022018-12-21 13:49:44 -080070 stage('Install CORD Kafka') {
71 timeout(10) {
72 sh returnStdout: true, script: """
73 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
74 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
75 """
76 }
77 timeout(10) {
78 waitUntil {
79 kafka_instances_running = sh returnStdout: true, script: """
80 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
81 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -080082 """
Luca Prete31eda022018-12-21 13:49:44 -080083 return kafka_instances_running.toInteger() == 2
Kailash4321b4d2018-12-18 13:11:08 -080084 }
85 }
Luca Prete31eda022018-12-21 13:49:44 -080086 }
87 stage('Install Logging Infrastructure') {
88 timeout(10) {
89 sh returnStdout: true, script: """
90 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
91 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
Luca Prete48634052018-12-21 15:31:51 -080092 helm-repo-tools/wait_for_pods.sh
Luca Prete31eda022018-12-21 13:49:44 -080093 """
94 }
95 }
96 stage('Install Monitoring Infrastructure') {
97 timeout(10) {
98 sh returnStdout: true, script: """
99 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
100 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
Luca Prete48634052018-12-21 15:31:51 -0800101 helm-repo-tools/wait_for_pods.sh
Luca Prete31eda022018-12-21 13:49:44 -0800102 """
103 }
104 }
105 stage('Install etcd-cluster') {
106 timeout(10) {
107 sh returnStdout: true, script: """
108 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
109 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
110 """
111 }
112 timeout(10) {
113 waitUntil {
114 etcd_running = sh returnStdout: true, script: """
115 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
116 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800117 """
Luca Prete31eda022018-12-21 13:49:44 -0800118 return etcd_running.toInteger() == 3
Kailash4321b4d2018-12-18 13:11:08 -0800119 }
120 }
Luca Prete31eda022018-12-21 13:49:44 -0800121 }
122 stage('Install voltha') {
123 timeout(10) {
124 sh returnStdout: true, script: """
125 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
126 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
127 helm dep build voltha
128 helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
129 """
130 }
131 timeout(10) {
132 waitUntil {
133 voltha_completed = sh returnStdout: true, script: """
134 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
135 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800136 """
Luca Prete31eda022018-12-21 13:49:44 -0800137 return voltha_completed.toInteger() == 8
Kailash4321b4d2018-12-18 13:11:08 -0800138 }
139 }
Luca Prete31eda022018-12-21 13:49:44 -0800140 }
141 stage('Install ONOS') {
142 timeout(10) {
143 sh returnStdout: true, script: """
144 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
145 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
146 """
147 }
148 timeout(10) {
149 waitUntil {
150 onos_completed = sh returnStdout: true, script: """
151 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
152 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800153 """
Luca Prete31eda022018-12-21 13:49:44 -0800154 return onos_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800155 }
156 }
Luca Prete31eda022018-12-21 13:49:44 -0800157 }
158 stage('Install xos-core') {
159 timeout(10) {
160 sh returnStdout: true, script: """
161 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
162 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
163 """
164 }
165 timeout(10) {
166 waitUntil {
167 xos_core_completed = sh returnStdout: true, script: """
168 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
169 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800170 """
Luca Prete31eda022018-12-21 13:49:44 -0800171 return xos_core_completed.toInteger() == 6
Kailash4321b4d2018-12-18 13:11:08 -0800172 }
173 }
Luca Prete31eda022018-12-21 13:49:44 -0800174 }
175 stage('Install seba-services') {
176 timeout(10) {
177 sh returnStdout: true, script: """
178 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
179 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
180 """
181 }
182 timeout(10) {
183 waitUntil {
184 att_workflow_tosca_completed = sh returnStdout: true, script: """
185 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
186 kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800187 """
Luca Prete31eda022018-12-21 13:49:44 -0800188 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800189 }
190 }
Luca Prete31eda022018-12-21 13:49:44 -0800191 }
192 stage('Install base-kubernetes') {
193 timeout(10) {
194 sh returnStdout: true, script: """
195 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
196 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes
197 """
198 }
199 timeout(10) {
200 waitUntil {
201 base_kubernetes_tosca_running = sh returnStdout: true, script: """
202 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
203 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800204 """
Luca Prete31eda022018-12-21 13:49:44 -0800205 return base_kubernetes_tosca_running.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800206 }
207 }
Luca Prete31eda022018-12-21 13:49:44 -0800208 }
209 stage('Install att workflow') {
210 timeout(10) {
211 sh returnStdout: true, script: """
212 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
213 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow cord/att-workflow
214 """
Kailash58255ca2018-12-19 09:48:46 -0800215 }
Luca Prete31eda022018-12-21 13:49:44 -0800216 timeout(10) {
217 waitUntil {
218 att_workflow_tosca_completed = sh returnStdout: true, script: """
219 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
220 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
Kailash58255ca2018-12-19 09:48:46 -0800221 """
Luca Prete31eda022018-12-21 13:49:44 -0800222 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800223 }
224 }
225 }
226
Kailash9b56c862018-11-29 08:45:25 -0800227 if ( params.reinstallOlt ) {
228 stage('Reinstall OLT software') {
229 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700230 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800231 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 -0700232 """
Kailash9b56c862018-11-29 08:45:25 -0800233 timeout(5) {
234 waitUntil {
235 olt_sw_present = sh returnStdout: true, script: """
236 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'
237 """
238 return olt_sw_present.toInteger() == 0
239 }
240 }
241 sh returnStdout: true, script: """
242 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
243 """
244 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() == 1
250 }
251 }
252 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
253 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
254 sh returnStdout: true, script: """
255 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'
256 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
257 """
258 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700259 }
260 }
Kailash9b56c862018-11-29 08:45:25 -0800261 stage('Restart OLT processes') {
262 for(int i=0; i < deployment_config.olts.size(); i++) {
263 timeout(5) {
264 sh returnStdout: true, script: """
265 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
266 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
267 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
268 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'
269 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
270 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
271 sleep 5
272 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
273 """
274 }
275 timeout(15) {
276 waitUntil {
277 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'"
278 return onu_discovered.toInteger() > 0
279 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700280 }
281 }
282 }
283 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700284 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700285 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700286 stage('Configure R-CORD - Fabric and whitelist') {
287 timeout(1) {
288 waitUntil {
289 out_fabric = sh returnStdout: true, script: """
290 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
291 """
292 return out_fabric.toInteger() == 1
293 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700294 }
295 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700296 stage('Configure R-CORD - Subscriber') {
297 timeout(1) {
298 waitUntil {
299 out_subscriber = sh returnStdout: true, script: """
300 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
301 """
302 return out_subscriber.toInteger() == 1
303 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700304 }
305 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700306 stage('Configure R-CORD - OLT') {
307 timeout(1) {
308 waitUntil {
309 out_olt = sh returnStdout: true, script: """
310 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
311 """
312 return out_olt.toInteger() == 1
313 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700314 }
315 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700316 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700317 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800318 if ( params.installBBSim ) {
Luca Prete31eda022018-12-21 13:49:44 -0800319 stage('Install BBSim') {
320 timeout(10) {
321 sh returnStdout: true, script: """
322 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
323 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
324 """
325 }
326 timeout(10) {
327 waitUntil {
328 bbsim_running = sh returnStdout: true, script: """
329 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
330 kubectl get pods -n voltha | grep -i bbsim | wc -l
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800331 """
Luca Prete31eda022018-12-21 13:49:44 -0800332 return bbsim_running.toInteger() == 1
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800333 }
334 }
335 }
336 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
337 stage('Configure BBSim - OLT') {
338 timeout(1) {
339 waitUntil {
340 out_olt = sh returnStdout: true, script: """
341 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
342 """
343 return out_olt.toInteger() == 1
344 }
345 }
346 }
347 }
348 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700349 currentBuild.result = 'SUCCESS'
350 } catch (err) {
351 currentBuild.result = 'FAILURE'
352 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
353 }
354 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700355 }
356}