blob: 7ba3c8e0222ce5902ba2d6ae9251ba506dd52992 [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
Kailash15d80652019-01-03 10:49:28 -080074 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
Luca Prete31eda022018-12-21 13:49:44 -080075 """
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
Luca Prete31eda022018-12-21 13:49:44 -0800126 helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
127 """
128 }
129 timeout(10) {
130 waitUntil {
131 voltha_completed = sh returnStdout: true, script: """
132 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
133 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800134 """
Luca Prete31eda022018-12-21 13:49:44 -0800135 return voltha_completed.toInteger() == 8
Kailash4321b4d2018-12-18 13:11:08 -0800136 }
137 }
Luca Prete31eda022018-12-21 13:49:44 -0800138 }
139 stage('Install ONOS') {
140 timeout(10) {
141 sh returnStdout: true, script: """
142 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
143 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
144 """
145 }
146 timeout(10) {
147 waitUntil {
148 onos_completed = sh returnStdout: true, script: """
149 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
150 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800151 """
Luca Prete31eda022018-12-21 13:49:44 -0800152 return onos_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800153 }
154 }
Luca Prete31eda022018-12-21 13:49:44 -0800155 }
156 stage('Install xos-core') {
157 timeout(10) {
158 sh returnStdout: true, script: """
159 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
160 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
161 """
162 }
163 timeout(10) {
164 waitUntil {
165 xos_core_completed = sh returnStdout: true, script: """
166 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
167 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800168 """
Luca Prete31eda022018-12-21 13:49:44 -0800169 return xos_core_completed.toInteger() == 6
Kailash4321b4d2018-12-18 13:11:08 -0800170 }
171 }
Luca Prete31eda022018-12-21 13:49:44 -0800172 }
173 stage('Install seba-services') {
174 timeout(10) {
175 sh returnStdout: true, script: """
176 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
177 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
178 """
179 }
180 timeout(10) {
181 waitUntil {
182 att_workflow_tosca_completed = sh returnStdout: true, script: """
183 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
184 kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800185 """
Luca Prete31eda022018-12-21 13:49:44 -0800186 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800187 }
188 }
Luca Prete31eda022018-12-21 13:49:44 -0800189 }
190 stage('Install base-kubernetes') {
191 timeout(10) {
192 sh returnStdout: true, script: """
193 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
194 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes
195 """
196 }
197 timeout(10) {
198 waitUntil {
199 base_kubernetes_tosca_running = sh returnStdout: true, script: """
200 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
201 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800202 """
Luca Prete31eda022018-12-21 13:49:44 -0800203 return base_kubernetes_tosca_running.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800204 }
205 }
Luca Prete31eda022018-12-21 13:49:44 -0800206 }
207 stage('Install att workflow') {
208 timeout(10) {
209 sh returnStdout: true, script: """
210 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
211 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow cord/att-workflow
212 """
Kailash58255ca2018-12-19 09:48:46 -0800213 }
Luca Prete31eda022018-12-21 13:49:44 -0800214 timeout(10) {
215 waitUntil {
216 att_workflow_tosca_completed = sh returnStdout: true, script: """
217 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
218 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
Kailash58255ca2018-12-19 09:48:46 -0800219 """
Luca Prete31eda022018-12-21 13:49:44 -0800220 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800221 }
222 }
223 }
224
Kailash9b56c862018-11-29 08:45:25 -0800225 if ( params.reinstallOlt ) {
226 stage('Reinstall OLT software') {
227 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700228 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800229 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 -0700230 """
Kailash9b56c862018-11-29 08:45:25 -0800231 timeout(5) {
232 waitUntil {
233 olt_sw_present = sh returnStdout: true, script: """
234 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'
235 """
236 return olt_sw_present.toInteger() == 0
237 }
238 }
239 sh returnStdout: true, script: """
240 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
241 """
242 timeout(5) {
243 waitUntil {
244 olt_sw_present = sh returnStdout: true, script: """
245 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'
246 """
247 return olt_sw_present.toInteger() == 1
248 }
249 }
250 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
251 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
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} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
254 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
255 """
256 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700257 }
258 }
Kailash9b56c862018-11-29 08:45:25 -0800259 stage('Restart OLT processes') {
260 for(int i=0; i < deployment_config.olts.size(); i++) {
261 timeout(5) {
262 sh returnStdout: true, script: """
263 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
264 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
265 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
266 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'
267 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
268 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
269 sleep 5
270 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
271 """
272 }
273 timeout(15) {
274 waitUntil {
275 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'"
276 return onu_discovered.toInteger() > 0
277 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700278 }
279 }
280 }
281 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700282 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700283 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700284 stage('Configure R-CORD - Fabric and whitelist') {
285 timeout(1) {
286 waitUntil {
287 out_fabric = sh returnStdout: true, script: """
288 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
289 """
290 return out_fabric.toInteger() == 1
291 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700292 }
293 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700294 stage('Configure R-CORD - Subscriber') {
295 timeout(1) {
296 waitUntil {
297 out_subscriber = sh returnStdout: true, script: """
298 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
299 """
300 return out_subscriber.toInteger() == 1
301 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700302 }
303 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700304 stage('Configure R-CORD - OLT') {
305 timeout(1) {
306 waitUntil {
307 out_olt = sh returnStdout: true, script: """
308 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
309 """
310 return out_olt.toInteger() == 1
311 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700312 }
313 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700314 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700315 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800316 if ( params.installBBSim ) {
Luca Prete31eda022018-12-21 13:49:44 -0800317 stage('Install BBSim') {
318 timeout(10) {
319 sh returnStdout: true, script: """
320 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
321 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
322 """
323 }
324 timeout(10) {
325 waitUntil {
326 bbsim_running = sh returnStdout: true, script: """
327 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
328 kubectl get pods -n voltha | grep -i bbsim | wc -l
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800329 """
Luca Prete31eda022018-12-21 13:49:44 -0800330 return bbsim_running.toInteger() == 1
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800331 }
332 }
333 }
334 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
335 stage('Configure BBSim - OLT') {
336 timeout(1) {
337 waitUntil {
338 out_olt = sh returnStdout: true, script: """
339 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
340 """
341 return out_olt.toInteger() == 1
342 }
343 }
344 }
345 }
346 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700347 currentBuild.result = 'SUCCESS'
348 } catch (err) {
349 currentBuild.result = 'FAILURE'
350 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
351 }
352 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700353 }
354}