blob: 6e3deecf899abf4a2631f154280ef07d5b651540 [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 }
Luca Prete62a48c82019-01-16 10:40:01 -080054 stage('Add Helm repositories') {
Kailash4321b4d2018-12-18 13:11:08 -080055 sh returnStdout: true, script: """
56 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
57 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080058 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Kailash4321b4d2018-12-18 13:11:08 -080059 helm repo update
60 """
61 timeout(1) {
62 waitUntil {
63 cord_repo_present = sh returnStdout: true, script: """
64 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
65 helm repo list | grep cord | wc -l
Kailash Khalasi100cf462018-09-20 10:24:57 -070066 """
Kailash4321b4d2018-12-18 13:11:08 -080067 return cord_repo_present.toInteger() == 1
Matteo Scandolo2f8271f2018-12-12 15:54:54 -080068 }
69 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -070070 }
Luca Prete31eda022018-12-21 13:49:44 -080071 stage('Install CORD Kafka') {
72 timeout(10) {
73 sh returnStdout: true, script: """
74 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Kailash15d80652019-01-03 10:49:28 -080075 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 -080076 """
77 }
78 timeout(10) {
79 waitUntil {
80 kafka_instances_running = sh returnStdout: true, script: """
81 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
82 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -080083 """
Luca Prete31eda022018-12-21 13:49:44 -080084 return kafka_instances_running.toInteger() == 2
Kailash4321b4d2018-12-18 13:11:08 -080085 }
86 }
Luca Prete31eda022018-12-21 13:49:44 -080087 }
88 stage('Install Logging Infrastructure') {
89 timeout(10) {
90 sh returnStdout: true, script: """
91 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
92 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 -080093 helm-repo-tools/wait_for_pods.sh
Luca Prete31eda022018-12-21 13:49:44 -080094 """
95 }
96 }
97 stage('Install Monitoring Infrastructure') {
98 timeout(10) {
99 sh returnStdout: true, script: """
100 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
101 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
Luca Prete48634052018-12-21 15:31:51 -0800102 helm-repo-tools/wait_for_pods.sh
Luca Prete31eda022018-12-21 13:49:44 -0800103 """
104 }
105 }
106 stage('Install etcd-cluster') {
107 timeout(10) {
108 sh returnStdout: true, script: """
109 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
110 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
111 """
112 }
113 timeout(10) {
114 waitUntil {
115 etcd_running = sh returnStdout: true, script: """
116 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
117 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800118 """
Luca Prete31eda022018-12-21 13:49:44 -0800119 return etcd_running.toInteger() == 3
Kailash4321b4d2018-12-18 13:11:08 -0800120 }
121 }
Luca Prete31eda022018-12-21 13:49:44 -0800122 }
123 stage('Install voltha') {
124 timeout(10) {
125 sh returnStdout: true, script: """
126 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete31eda022018-12-21 13:49:44 -0800127 helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha
128 """
129 }
130 timeout(10) {
131 waitUntil {
132 voltha_completed = sh returnStdout: true, script: """
133 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
134 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800135 """
Luca Prete31eda022018-12-21 13:49:44 -0800136 return voltha_completed.toInteger() == 8
Kailash4321b4d2018-12-18 13:11:08 -0800137 }
138 }
Luca Prete31eda022018-12-21 13:49:44 -0800139 }
140 stage('Install ONOS') {
141 timeout(10) {
142 sh returnStdout: true, script: """
143 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
144 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
145 """
146 }
147 timeout(10) {
148 waitUntil {
149 onos_completed = sh returnStdout: true, script: """
150 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
151 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800152 """
Luca Prete31eda022018-12-21 13:49:44 -0800153 return onos_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800154 }
155 }
Luca Prete31eda022018-12-21 13:49:44 -0800156 }
157 stage('Install xos-core') {
158 timeout(10) {
159 sh returnStdout: true, script: """
160 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
161 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
162 """
163 }
164 timeout(10) {
165 waitUntil {
166 xos_core_completed = sh returnStdout: true, script: """
167 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
168 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800169 """
Luca Prete31eda022018-12-21 13:49:44 -0800170 return xos_core_completed.toInteger() == 6
Kailash4321b4d2018-12-18 13:11:08 -0800171 }
172 }
Luca Prete31eda022018-12-21 13:49:44 -0800173 }
174 stage('Install seba-services') {
175 timeout(10) {
176 sh returnStdout: true, script: """
177 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
178 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba-services cord/seba-services
179 """
180 }
181 timeout(10) {
182 waitUntil {
183 att_workflow_tosca_completed = sh returnStdout: true, script: """
184 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
185 kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800186 """
Luca Prete31eda022018-12-21 13:49:44 -0800187 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800188 }
189 }
Luca Prete31eda022018-12-21 13:49:44 -0800190 }
191 stage('Install base-kubernetes') {
192 timeout(10) {
193 sh returnStdout: true, script: """
194 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
195 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes
196 """
197 }
198 timeout(10) {
199 waitUntil {
200 base_kubernetes_tosca_running = sh returnStdout: true, script: """
201 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
202 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
Kailash4321b4d2018-12-18 13:11:08 -0800203 """
Luca Prete31eda022018-12-21 13:49:44 -0800204 return base_kubernetes_tosca_running.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800205 }
206 }
Luca Prete31eda022018-12-21 13:49:44 -0800207 }
208 stage('Install att workflow') {
209 timeout(10) {
210 sh returnStdout: true, script: """
211 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Kailashe22a7e62019-01-03 20:18:57 -0800212 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow --version 1.0.2 cord/att-workflow
Luca Prete31eda022018-12-21 13:49:44 -0800213 """
Kailash58255ca2018-12-19 09:48:46 -0800214 }
Luca Prete31eda022018-12-21 13:49:44 -0800215 timeout(10) {
216 waitUntil {
217 att_workflow_tosca_completed = sh returnStdout: true, script: """
218 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
219 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
Kailash58255ca2018-12-19 09:48:46 -0800220 """
Luca Prete31eda022018-12-21 13:49:44 -0800221 return att_workflow_tosca_completed.toInteger() == 1
Kailash4321b4d2018-12-18 13:11:08 -0800222 }
223 }
224 }
225
Kailash9b56c862018-11-29 08:45:25 -0800226 if ( params.reinstallOlt ) {
227 stage('Reinstall OLT software') {
228 for(int i=0; i < deployment_config.olts.size(); i++) {
Luca Preteb3029bd2018-08-28 16:31:39 -0700229 sh returnStdout: true, script: """
Kailash9b56c862018-11-29 08:45:25 -0800230 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 -0700231 """
Kailash9b56c862018-11-29 08:45:25 -0800232 timeout(5) {
233 waitUntil {
234 olt_sw_present = sh returnStdout: true, script: """
235 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'
236 """
237 return olt_sw_present.toInteger() == 0
238 }
239 }
240 sh returnStdout: true, script: """
241 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
242 """
243 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() == 1
249 }
250 }
251 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
252 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
253 sh returnStdout: true, script: """
254 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'
255 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
256 """
257 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700258 }
259 }
Kailash9b56c862018-11-29 08:45:25 -0800260 stage('Restart OLT processes') {
261 for(int i=0; i < deployment_config.olts.size(); i++) {
262 timeout(5) {
263 sh returnStdout: true, script: """
264 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
265 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
266 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
267 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'
268 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
269 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
270 sleep 5
271 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
272 """
273 }
274 timeout(15) {
275 waitUntil {
276 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'"
277 return onu_discovered.toInteger() > 0
278 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700279 }
280 }
281 }
282 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700283 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700284 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700285 stage('Configure R-CORD - Fabric and whitelist') {
286 timeout(1) {
287 waitUntil {
288 out_fabric = sh returnStdout: true, script: """
289 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
290 """
291 return out_fabric.toInteger() == 1
292 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700293 }
294 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700295 stage('Configure R-CORD - Subscriber') {
296 timeout(1) {
297 waitUntil {
298 out_subscriber = sh returnStdout: true, script: """
299 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
300 """
301 return out_subscriber.toInteger() == 1
302 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700303 }
304 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700305 stage('Configure R-CORD - OLT') {
306 timeout(1) {
307 waitUntil {
308 out_olt = sh returnStdout: true, script: """
309 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
310 """
311 return out_olt.toInteger() == 1
312 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700313 }
314 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700315 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700316 }
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800317 if ( params.installBBSim ) {
Luca Prete31eda022018-12-21 13:49:44 -0800318 stage('Install BBSim') {
319 timeout(10) {
320 sh returnStdout: true, script: """
321 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Kailasha456c692019-01-14 14:38:48 -0800322 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim --version 1.0.0 cord/bbsim --set onus_per_pon_port=${onuNumber}
Luca Prete31eda022018-12-21 13:49:44 -0800323 """
324 }
325 timeout(10) {
326 waitUntil {
327 bbsim_running = sh returnStdout: true, script: """
328 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
329 kubectl get pods -n voltha | grep -i bbsim | wc -l
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800330 """
Luca Prete31eda022018-12-21 13:49:44 -0800331 return bbsim_running.toInteger() == 1
Matteo Scandolo8819edd2018-11-27 13:18:08 -0800332 }
333 }
334 }
335 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
336 stage('Configure BBSim - OLT') {
337 timeout(1) {
338 waitUntil {
339 out_olt = sh returnStdout: true, script: """
340 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
341 """
342 return out_olt.toInteger() == 1
343 }
344 }
345 }
346 }
347 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700348 currentBuild.result = 'SUCCESS'
349 } catch (err) {
350 currentBuild.result = 'FAILURE'
351 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
352 }
353 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700354 }
355}