blob: 1401c6343443abf9a10279c93203bbc728231adc [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}"
Luca Prete43f52cd2018-08-28 16:36:36 -070021 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml"
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: """
26 rm -rf helm-charts 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 }
53 }
54 }
Luca Preteb3029bd2018-08-28 16:31:39 -070055 dir ("helm-charts") {
Kailash Khalasi100cf462018-09-20 10:24:57 -070056 stage('Install CORD Kafka') {
57 timeout(10) {
58 sh returnStdout: true, script: """
59 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
60 helm install -f examples/kafka-single.yaml --version 0.8.8 -n cord-kafka incubator/kafka
61 """
62 }
63 timeout(10) {
64 waitUntil {
65 kafka_instances_running = sh returnStdout: true, script: """
66 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
67 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
68 """
69 return kafka_instances_running.toInteger() == 2
70 }
71 }
72 }
73 stage('Install Logging Infrastructure') {
74 timeout(10) {
75 sh returnStdout: true, script: """
76 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
77 helm dep update logging
78 helm install -f examples/logging-single.yaml -n logging logging
79 scripts/wait_for_pods.sh
80 """
81 }
82 }
83 stage('Install Monitoring Infrastructure') {
84 timeout(10) {
85 sh returnStdout: true, script: """
86 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
87 helm dep update nem-monitoring
88 helm install -n nem-monitoring nem-monitoring
89 scripts/wait_for_pods.sh
90 """
91 }
92 }
Luca Preteb3029bd2018-08-28 16:31:39 -070093 stage('Install voltha') {
94 timeout(10) {
95 sh returnStdout: true, script: """
96 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
97 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
98 helm dep build voltha
99 helm install -n voltha -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=false voltha
Matteo Scandoloa6e1f9d2018-08-29 17:23:19 -0700100 helm upgrade -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha
Luca Preteb3029bd2018-08-28 16:31:39 -0700101 """
102 }
103 timeout(10) {
104 waitUntil {
105 voltha_completed = sh returnStdout: true, script: """
106 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
107 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
108 """
109 return voltha_completed.toInteger() == 8
110 }
111 }
112 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700113 stage('Install ONOS') {
114 timeout(10) {
115 sh returnStdout: true, script: """
116 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete5a970152018-08-29 15:20:47 -0700117 helm install -n onos -f configs/onos.yaml -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml onos
Luca Preteb3029bd2018-08-28 16:31:39 -0700118 """
119 }
120 timeout(10) {
121 waitUntil {
122 onos_completed = sh returnStdout: true, script: """
123 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb1ae41b2018-08-28 16:47:54 -0700124 kubectl get pods | grep -i onos | grep -i running | grep 1/1 | wc -l
Luca Preteb3029bd2018-08-28 16:31:39 -0700125 """
126 return onos_completed.toInteger() == 1
127 }
128 }
129 }
130 stage('Install xos-core') {
131 timeout(10) {
132 sh returnStdout: true, script: """
133 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
134 helm dep update xos-core
135 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core xos-core
136 """
137 }
138 timeout(10) {
139 waitUntil {
140 xos_core_completed = sh returnStdout: true, script: """
141 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
142 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
143 """
144 return xos_core_completed.toInteger() == 7
145 }
146 }
147 }
148 stage('Install att-workflow') {
149 timeout(10) {
150 sh returnStdout: true, script: """
151 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
152 helm dep update xos-profiles/att-workflow
153 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n att-workflow xos-profiles/att-workflow
154 """
155 }
156 timeout(10) {
157 waitUntil {
158 att_workflow_tosca_completed = sh returnStdout: true, script: """
159 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
160 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
161 """
162 return att_workflow_tosca_completed.toInteger() == 1
163 }
164 }
165 }
166 stage('Install base-kubernetes') {
167 timeout(10) {
168 sh returnStdout: true, script: """
169 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
170 helm dep update xos-profiles/base-kubernetes
171 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes xos-profiles/base-kubernetes
172 """
173 }
174 timeout(10) {
175 waitUntil {
176 base_kubernetes_tosca_running = sh returnStdout: true, script: """
177 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
178 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
179 """
180 return base_kubernetes_tosca_running.toInteger() == 1
181 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700182 }
183 }
184 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700185 stage('Reinstall OLT software') {
186 for(int i=0; i < deployment_config.olts.size(); i++) {
187 sh returnStdout: true, script: """
188 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'
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700189 """
Luca Preteb3029bd2018-08-28 16:31:39 -0700190 timeout(5) {
191 waitUntil {
192 olt_sw_present = sh returnStdout: true, script: """
193 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'
194 """
195 return olt_sw_present.toInteger() == 0
196 }
197 }
198 sh returnStdout: true, script: """
199 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
200 """
201 timeout(5) {
202 waitUntil {
203 olt_sw_present = sh returnStdout: true, script: """
204 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'
205 """
206 return olt_sw_present.toInteger() == 1
207 }
208 }
209 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
210 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
211 sh returnStdout: true, script: """
212 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'
213 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
214 """
215 }
216 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700217 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700218 stage('Restart OLT processes') {
219 for(int i=0; i < deployment_config.olts.size(); i++) {
220 timeout(5) {
221 sh returnStdout: true, script: """
222 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
223 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
224 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
225 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'
226 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
227 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
228 sleep 5
229 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
230 """
231 }
232 timeout(15) {
233 waitUntil {
Kailash Khalasi23b693c2018-09-14 14:46:50 -0700234 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'"
Luca Preteb3029bd2018-08-28 16:31:39 -0700235 return onu_discovered.toInteger() > 0
236 }
237 }
238 }
239 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700240 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700241 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700242 stage('Configure R-CORD - Fabric and whitelist') {
243 timeout(1) {
244 waitUntil {
245 out_fabric = sh returnStdout: true, script: """
246 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
247 """
248 return out_fabric.toInteger() == 1
249 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700250 }
251 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700252 stage('Configure R-CORD - Subscriber') {
253 timeout(1) {
254 waitUntil {
255 out_subscriber = sh returnStdout: true, script: """
256 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
257 """
258 return out_subscriber.toInteger() == 1
259 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700260 }
261 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700262 stage('Configure R-CORD - OLT') {
263 timeout(1) {
264 waitUntil {
265 out_olt = sh returnStdout: true, script: """
266 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
267 """
268 return out_olt.toInteger() == 1
269 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700270 }
271 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700272 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700273 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700274 currentBuild.result = 'SUCCESS'
275 } catch (err) {
276 currentBuild.result = 'FAILURE'
277 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
278 }
279 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700280 }
281}