blob: 02fd8140449315d4ed0d29b4daa9f85b25e7a3bd [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") {
19 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: """
Kailash4321b4d2018-12-18 13:11:08 -080026 rm -rf cord-tester
You Wangd6c5e8c2018-08-29 12:49:51 -070027 git clone -b ${branch} ${cordRepoUrl}/helm-charts
Luca Preteb3029bd2018-08-28 16:31:39 -070028 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete5a970152018-08-29 15:20:47 -070029 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
Luca Preteb3029bd2018-08-28 16:31:39 -070030 do
31 echo "Purging chart: \${hchart}"
32 helm delete --purge "\${hchart}"
33 done
Suchitra Vemuriddb27792018-08-23 15:29:42 -070034 """
Luca Preteb3029bd2018-08-28 16:31:39 -070035 timeout(5) {
36 waitUntil {
37 helm_deleted = sh returnStdout: true, script: """
38 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070039 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
Suchitra Vemuriddb27792018-08-23 15:29:42 -070040 """
Luca Preteb3029bd2018-08-28 16:31:39 -070041 return helm_deleted.toInteger() == 0
42 }
43 }
44 timeout(5) {
45 waitUntil {
46 kubectl_deleted = sh returnStdout: true, script: """
47 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb4966672018-08-29 16:49:48 -070048 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 -070049 """
50 return kubectl_deleted.toInteger() == 0
Suchitra Vemuriddb27792018-08-23 15:29:42 -070051 }
52 }
Luca Prete79fbc602018-09-24 15:33:31 -070053 // timeout(5) {
54 // waitUntil {
55 // kubectl_deleted = sh returnStdout: true, script: """
56 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
57 // kubectl get statefulset --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
58 // """
59 // return kubectl_deleted.toInteger() == 0
60 // }
61 // }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070062 }
63 }
Kailash4321b4d2018-12-18 13:11:08 -080064 stage('Add CORD repository') {
65 sh returnStdout: true, script: """
66 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
67 helm repo add cord https://charts.opencord.org
68 helm repo update
69 """
70 timeout(1) {
71 waitUntil {
72 cord_repo_present = sh returnStdout: true, script: """
73 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
74 helm repo list | grep cord | wc -l
Kailash Khalasi100cf462018-09-20 10:24:57 -070075 """
Kailash4321b4d2018-12-18 13:11:08 -080076 return cord_repo_present.toInteger() == 1
Matteo Scandolo2f8271f2018-12-12 15:54:54 -080077 }
78 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070079 }
Kailash4321b4d2018-12-18 13:11:08 -080080 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
85 """
86 }
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 }
95 }
96 }
97 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
103 """
104 }
105 }
106 stage('Install Monitoring Infrastructure') {
107 timeout(10) {
108 sh returnStdout: true, script: """
109 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
110 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
111 scripts/wait_for_pods.sh
112 """
113 }
114 }
115 stage('Install etcd-cluster') {
116 timeout(10) {
117 sh returnStdout: true, script: """
118 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
119 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
120 """
121 }
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 }
130 }
131 }
132 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 ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
139 """
140 }
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 }
149 }
150 }
151 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 ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
156 """
157 }
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 }
166 }
167 }
168 stage('Install xos-core') {
169 timeout(10) {
170 sh returnStdout: true, script: """
171 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
172 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
173 """
174 }
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 }
183 }
184 }
185 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 ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
190 """
191 }
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 ../${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 ../${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 }
234 }
235 }
236
Kailash9b56c862018-11-29 08:45:25 -0800237 if ( params.reinstallOlt ) {
238 stage('Reinstall OLT software') {
239 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700240 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800241 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 -0700242 """
Kailash9b56c862018-11-29 08:45:25 -0800243 timeout(5) {
244 waitUntil {
245 olt_sw_present = sh returnStdout: true, script: """
246 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'
247 """
248 return olt_sw_present.toInteger() == 0
249 }
250 }
251 sh returnStdout: true, script: """
252 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
253 """
254 timeout(5) {
255 waitUntil {
256 olt_sw_present = sh returnStdout: true, script: """
257 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'
258 """
259 return olt_sw_present.toInteger() == 1
260 }
261 }
262 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
263 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
264 sh returnStdout: true, script: """
265 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'
266 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
267 """
268 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700269 }
270 }
Kailash9b56c862018-11-29 08:45:25 -0800271 stage('Restart OLT processes') {
272 for(int i=0; i < deployment_config.olts.size(); i++) {
273 timeout(5) {
274 sh returnStdout: true, script: """
275 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
276 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
277 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
278 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'
279 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
280 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
281 sleep 5
282 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
283 """
284 }
285 timeout(15) {
286 waitUntil {
287 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'"
288 return onu_discovered.toInteger() > 0
289 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700290 }
291 }
292 }
293 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700294 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700295 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700296 stage('Configure R-CORD - Fabric and whitelist') {
297 timeout(1) {
298 waitUntil {
299 out_fabric = sh returnStdout: true, script: """
300 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
301 """
302 return out_fabric.toInteger() == 1
303 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700304 }
305 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700306 stage('Configure R-CORD - Subscriber') {
307 timeout(1) {
308 waitUntil {
309 out_subscriber = sh returnStdout: true, script: """
310 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
311 """
312 return out_subscriber.toInteger() == 1
313 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700314 }
315 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700316 stage('Configure R-CORD - OLT') {
317 timeout(1) {
318 waitUntil {
319 out_olt = sh returnStdout: true, script: """
320 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
321 """
322 return out_olt.toInteger() == 1
323 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700324 }
325 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700326 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700327 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800328 if ( params.installBBSim ) {
329 dir ("helm-charts") {
330 stage('Install BBSim') {
331 timeout(10) {
332 sh returnStdout: true, script: """
333 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
334 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
335 """
336 }
337 timeout(10) {
338 waitUntil {
339 base_kubernetes_tosca_running = sh returnStdout: true, script: """
340 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
341 kubectl get pods -n voltha | grep -i bbsim | wc -l
342 """
343 return base_kubernetes_tosca_running.toInteger() == 1
344 }
345 }
346 }
347 }
348 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
349 stage('Configure BBSim - OLT') {
350 timeout(1) {
351 waitUntil {
352 out_olt = sh returnStdout: true, script: """
353 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
354 """
355 return out_olt.toInteger() == 1
356 }
357 }
358 }
359 }
360 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700361 currentBuild.result = 'SUCCESS'
362 } catch (err) {
363 currentBuild.result = 'FAILURE'
364 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
365 }
366 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700367 }
368}