blob: 78f63d9d00d7c18404b35787eaa5048a662289a5 [file] [log] [blame]
Kailash Khalasi164dc142018-09-14 11:49:08 -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
15node ("${TestNodeName}") {
16 timeout (100) {
17 try {
18 stage ("Parse deployment configuration file") {
19 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
20 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"
Kailash Khalasi164dc142018-09-14 11:49:08 -070022 }
23 stage('Clean up') {
24 timeout(10) {
25 sh returnStdout: true, script: """
26 rm -rf helm-charts cord-tester
27 git clone -b ${branch} ${cordRepoUrl}/helm-charts
28 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
29 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
30 do
31 echo "Purging chart: \${hchart}"
32 helm delete --purge "\${hchart}"
33 done
34 """
35 timeout(5) {
36 waitUntil {
37 helm_deleted = sh returnStdout: true, script: """
38 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
39 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
40 """
41 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 &&
48 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
49 """
50 return kubectl_deleted.toInteger() == 0
51 }
You Wang004ff242018-09-25 13:26:21 -070052 }/*
Matteo Scandolo5bb2c772018-09-21 11:49:57 -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 }
You Wang004ff242018-09-25 13:26:21 -070061 }*/
Kailash Khalasi164dc142018-09-14 11:49:08 -070062 }
63 }
64 dir ("helm-charts") {
Kailash Khalasi100cf462018-09-20 10:24:57 -070065 stage('Install CORD Kafka') {
66 timeout(10) {
67 sh returnStdout: true, script: """
68 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
69 helm install -f examples/kafka-single.yaml --version 0.8.8 -n cord-kafka incubator/kafka
70 """
71 }
72 timeout(10) {
73 waitUntil {
74 kafka_instances_running = sh returnStdout: true, script: """
75 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
76 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
77 """
78 return kafka_instances_running.toInteger() == 2
79 }
80 }
You Wang004ff242018-09-25 13:26:21 -070081 }/*
Kailash Khalasi100cf462018-09-20 10:24:57 -070082 stage('Install Logging Infrastructure') {
83 timeout(10) {
84 sh returnStdout: true, script: """
85 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
86 helm dep update logging
87 helm install -f examples/logging-single.yaml -n logging logging
88 scripts/wait_for_pods.sh
89 """
90 }
91 }
92 stage('Install Monitoring Infrastructure') {
93 timeout(10) {
94 sh returnStdout: true, script: """
95 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
96 helm dep update nem-monitoring
97 helm install -n nem-monitoring nem-monitoring
98 scripts/wait_for_pods.sh
99 """
100 }
You Wang004ff242018-09-25 13:26:21 -0700101 }*/
Kailash9b513182018-11-16 09:36:20 -0800102 stage('Install etcd-cluster') {
103 timeout(10) {
104 sh returnStdout: true, script: """
105 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
106 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.0 -n etcd-operator stable/etcd-operator
107 """
108 }
109 timeout(10) {
110 waitUntil {
111 etcd_running = sh returnStdout: true, script: """
112 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
113 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
114 """
Kailash4da70162018-11-16 12:58:33 -0800115 return etcd_running.toInteger() == 3
Kailash9b513182018-11-16 09:36:20 -0800116 }
117 }
118 }
Kailash Khalasi164dc142018-09-14 11:49:08 -0700119 stage('Install voltha') {
120 timeout(10) {
121 sh returnStdout: true, script: """
122 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
123 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
124 helm dep build voltha
Kailash9b513182018-11-16 09:36:20 -0800125 helm install -n voltha -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml voltha
Kailash Khalasi164dc142018-09-14 11:49:08 -0700126 """
127 }
128 timeout(10) {
129 waitUntil {
130 voltha_completed = sh returnStdout: true, script: """
131 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
132 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
133 """
134 return voltha_completed.toInteger() == 8
135 }
136 }
137 }
138 stage('Install ONOS') {
139 timeout(10) {
140 sh returnStdout: true, script: """
141 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
142 helm install -n onos -f configs/onos.yaml -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml onos
143 """
144 }
145 timeout(10) {
146 waitUntil {
147 onos_completed = sh returnStdout: true, script: """
148 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
You Wangd37e1822018-11-09 13:39:10 -0800149 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
Kailash Khalasi164dc142018-09-14 11:49:08 -0700150 """
151 return onos_completed.toInteger() == 1
152 }
153 }
154 }
155 stage('Install xos-core') {
156 timeout(10) {
157 sh returnStdout: true, script: """
158 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
159 helm dep update xos-core
160 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core 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
168 """
You Wang004ff242018-09-25 13:26:21 -0700169 return xos_core_completed.toInteger() == 6
Kailash Khalasi164dc142018-09-14 11:49:08 -0700170 }
171 }
172 }
173 stage('Install rcord-lite') {
174 timeout(10) {
175 sh returnStdout: true, script: """
176 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
177 helm dep update xos-profiles/rcord-lite
178 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n rcord-lite xos-profiles/rcord-lite
179 """
180 }
181 timeout(10) {
182 waitUntil {
183 rcord_tosca_completed = sh returnStdout: true, script: """
184 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
185 kubectl get pods | grep -i tosca-loader | grep -i completed | wc -l
186 """
187 return rcord_tosca_completed.toInteger() == 1
188 }
189 }
190 }
191 }
192 stage('Reinstall OLT software') {
193 for(int i=0; i < deployment_config.olts.size(); i++) {
194 sh returnStdout: true, script: """
195 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'
196 """
197 timeout(5) {
198 waitUntil {
199 olt_sw_present = sh returnStdout: true, script: """
200 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'
201 """
202 return olt_sw_present.toInteger() == 0
203 }
204 }
205 sh returnStdout: true, script: """
206 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
207 """
208 timeout(5) {
209 waitUntil {
210 olt_sw_present = sh returnStdout: true, script: """
211 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'
212 """
213 return olt_sw_present.toInteger() == 1
214 }
215 }
216 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
217 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
218 sh returnStdout: true, script: """
219 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'
220 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
221 """
222 }
223 }
224 }
225 stage('Restart OLT processes') {
226 for(int i=0; i < deployment_config.olts.size(); i++) {
227 timeout(5) {
228 sh returnStdout: true, script: """
229 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
230 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'pkill bal_core_dist' || true
231 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'pkill openolt' || true
232 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /broadcom/bal.log'
233 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /broadcom/openolt.log'
234 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cd /broadcom; ./bal_core_dist -C :55001 < /dev/tty1 > ./bal.log 2>&1 &'
235 sleep 5
236 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cd /broadcom; ./openolt -C 127.0.0.1:55001 < /dev/tty1 > ./openolt.log 2>&1 &'
237 """
238 }
239 timeout(15) {
240 waitUntil {
Kailash Khalasi23b693c2018-09-14 14:46:50 -0700241 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 /broadcom/openolt.log | grep \"oper_state: up\" | wc -l'"
Kailash Khalasi164dc142018-09-14 11:49:08 -0700242 return onu_discovered.toInteger() > 0
243 }
244 }
245 }
246 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700247 if ( params.configurePod ) {
248 dir ("${configBaseDir}/${configToscaDir}/${profile}") {
Kailash Khalasi164dc142018-09-14 11:49:08 -0700249 stage('Configure R-CORD - Fabric and whitelist') {
250 timeout(1) {
251 waitUntil {
252 out_fabric = sh returnStdout: true, script: """
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700253 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
Kailash Khalasi164dc142018-09-14 11:49:08 -0700254 """
255 return out_fabric.toInteger() == 1
256 }
257 }
258 }
259 stage('Configure R-CORD - Subscriber') {
260 timeout(1) {
261 waitUntil {
262 out_subscriber = sh returnStdout: true, script: """
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700263 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
Kailash Khalasi164dc142018-09-14 11:49:08 -0700264 """
265 return out_subscriber.toInteger() == 1
266 }
267 }
268 }
269 stage('Configure R-CORD - OLT') {
270 timeout(1) {
271 waitUntil {
272 out_olt = sh returnStdout: true, script: """
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700273 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
Kailash Khalasi164dc142018-09-14 11:49:08 -0700274 """
275 return out_olt.toInteger() == 1
276 }
277 }
278 }
279 }
280 }
281 currentBuild.result = 'SUCCESS'
282 } catch (err) {
283 currentBuild.result = 'FAILURE'
284 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
285 }
286 echo "RESULT: ${currentBuild.result}"
287 }
288}