blob: ab880540a95576bc658792c0a5ef8e27fbe45a53 [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") {
56 stage('Install Voltha Kafka') {
57 timeout(10) {
58 sh returnStdout: true, script: """
59 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Kailash Khalasidef2f4e2018-09-17 10:39:14 -070060 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
61 helm install -f examples/kafka-single.yaml --version 0.8.8 -n voltha-kafka incubator/kafka
Suchitra Vemuriddb27792018-08-23 15:29:42 -070062 """
Luca Preteb3029bd2018-08-28 16:31:39 -070063 }
64 timeout(10) {
65 waitUntil {
66 kafka_instances_running = sh returnStdout: true, script: """
67 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
68 kubectl get pods | grep voltha-kafka | grep -i running | grep 1/1 | wc -l
69 """
70 return kafka_instances_running.toInteger() == 2
71 }
72 }
73 }
74 stage('Install voltha') {
75 timeout(10) {
76 sh returnStdout: true, script: """
77 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
78 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
79 helm dep build voltha
80 helm install -n voltha -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=false voltha
Matteo Scandoloa6e1f9d2018-08-29 17:23:19 -070081 helm upgrade -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha
Luca Preteb3029bd2018-08-28 16:31:39 -070082 """
83 }
84 timeout(10) {
85 waitUntil {
86 voltha_completed = sh returnStdout: true, script: """
87 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
88 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
89 """
90 return voltha_completed.toInteger() == 8
91 }
92 }
93 }
94 stage('Install CORD Kafka') {
95 timeout(10) {
96 sh returnStdout: true, script: """
97 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Kailash Khalasidef2f4e2018-09-17 10:39:14 -070098 helm install -f examples/kafka-single.yaml --version 0.8.8 -n cord-kafka incubator/kafka
Luca Preteb3029bd2018-08-28 16:31:39 -070099 """
100 }
101 timeout(10) {
102 waitUntil {
103 kafka_instances_running = sh returnStdout: true, script: """
104 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
105 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
106 """
107 return kafka_instances_running.toInteger() == 2
108 }
109 }
110 }
111 stage('Install ONOS') {
112 timeout(10) {
113 sh returnStdout: true, script: """
114 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete5a970152018-08-29 15:20:47 -0700115 helm install -n onos -f configs/onos.yaml -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml onos
Luca Preteb3029bd2018-08-28 16:31:39 -0700116 """
117 }
118 timeout(10) {
119 waitUntil {
120 onos_completed = sh returnStdout: true, script: """
121 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb1ae41b2018-08-28 16:47:54 -0700122 kubectl get pods | grep -i onos | grep -i running | grep 1/1 | wc -l
Luca Preteb3029bd2018-08-28 16:31:39 -0700123 """
124 return onos_completed.toInteger() == 1
125 }
126 }
127 }
128 stage('Install xos-core') {
129 timeout(10) {
130 sh returnStdout: true, script: """
131 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
132 helm dep update xos-core
133 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core xos-core
134 """
135 }
136 timeout(10) {
137 waitUntil {
138 xos_core_completed = sh returnStdout: true, script: """
139 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
140 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
141 """
142 return xos_core_completed.toInteger() == 7
143 }
144 }
145 }
146 stage('Install att-workflow') {
147 timeout(10) {
148 sh returnStdout: true, script: """
149 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
150 helm dep update xos-profiles/att-workflow
151 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n att-workflow xos-profiles/att-workflow
152 """
153 }
154 timeout(10) {
155 waitUntil {
156 att_workflow_tosca_completed = sh returnStdout: true, script: """
157 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
158 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
159 """
160 return att_workflow_tosca_completed.toInteger() == 1
161 }
162 }
163 }
164 stage('Install base-kubernetes') {
165 timeout(10) {
166 sh returnStdout: true, script: """
167 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
168 helm dep update xos-profiles/base-kubernetes
169 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes xos-profiles/base-kubernetes
170 """
171 }
172 timeout(10) {
173 waitUntil {
174 base_kubernetes_tosca_running = sh returnStdout: true, script: """
175 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
176 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
177 """
178 return base_kubernetes_tosca_running.toInteger() == 1
179 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700180 }
181 }
182 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700183 stage('Reinstall OLT software') {
184 for(int i=0; i < deployment_config.olts.size(); i++) {
185 sh returnStdout: true, script: """
186 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 -0700187 """
Luca Preteb3029bd2018-08-28 16:31:39 -0700188 timeout(5) {
189 waitUntil {
190 olt_sw_present = sh returnStdout: true, script: """
191 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'
192 """
193 return olt_sw_present.toInteger() == 0
194 }
195 }
196 sh returnStdout: true, script: """
197 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
198 """
199 timeout(5) {
200 waitUntil {
201 olt_sw_present = sh returnStdout: true, script: """
202 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'
203 """
204 return olt_sw_present.toInteger() == 1
205 }
206 }
207 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
208 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
209 sh returnStdout: true, script: """
210 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'
211 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
212 """
213 }
214 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700215 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700216 stage('Restart OLT processes') {
217 for(int i=0; i < deployment_config.olts.size(); i++) {
218 timeout(5) {
219 sh returnStdout: true, script: """
220 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
221 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
222 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
223 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'
224 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
225 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
226 sleep 5
227 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
228 """
229 }
230 timeout(15) {
231 waitUntil {
Kailash Khalasi23b693c2018-09-14 14:46:50 -0700232 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 -0700233 return onu_discovered.toInteger() > 0
234 }
235 }
236 }
237 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700238 if ( params.configurePod ) {
Kailash Khalasidef2f4e2018-09-17 10:39:14 -0700239 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700240 stage('Configure R-CORD - Fabric and whitelist') {
241 timeout(1) {
242 waitUntil {
243 out_fabric = sh returnStdout: true, script: """
244 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
245 """
246 return out_fabric.toInteger() == 1
247 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700248 }
249 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700250 stage('Configure R-CORD - Subscriber') {
251 timeout(1) {
252 waitUntil {
253 out_subscriber = sh returnStdout: true, script: """
254 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
255 """
256 return out_subscriber.toInteger() == 1
257 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700258 }
259 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700260 stage('Configure R-CORD - OLT') {
261 timeout(1) {
262 waitUntil {
263 out_olt = sh returnStdout: true, script: """
264 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
265 """
266 return out_olt.toInteger() == 1
267 }
Kailash Khalasic1a90f12018-09-13 13:13:22 -0700268 }
269 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700270 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700271 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700272 currentBuild.result = 'SUCCESS'
273 } catch (err) {
274 currentBuild.result = 'FAILURE'
275 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
276 }
277 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700278 }
279}