blob: c388ad8dd6e3b76c4a36c406ba125a6dc62d4b2c [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}"
21 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml"
22 }
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 }
52 }
53 }
54 }
55 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 }
Kailash Khalasi164dc142018-09-14 11:49:08 -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
100 helm upgrade -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha
101 """
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 }
Kailash Khalasi164dc142018-09-14 11:49:08 -0700113 stage('Install ONOS') {
114 timeout(10) {
115 sh returnStdout: true, script: """
116 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
117 helm install -n onos -f configs/onos.yaml -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml onos
118 """
119 }
120 timeout(10) {
121 waitUntil {
122 onos_completed = sh returnStdout: true, script: """
123 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
124 kubectl get pods | grep -i onos | grep -i running | grep 1/1 | wc -l
125 """
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 rcord-lite') {
149 timeout(10) {
150 sh returnStdout: true, script: """
151 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
152 helm dep update xos-profiles/rcord-lite
153 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n rcord-lite xos-profiles/rcord-lite
154 """
155 }
156 timeout(10) {
157 waitUntil {
158 rcord_tosca_completed = sh returnStdout: true, script: """
159 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
160 kubectl get pods | grep -i tosca-loader | grep -i completed | wc -l
161 """
162 return rcord_tosca_completed.toInteger() == 1
163 }
164 }
165 }
166 stage('Install hippie-oss') {
167 timeout(10) {
168 sh returnStdout: true, script: """
169 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
170 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n hippie-oss xos-services/hippie-oss
171 """
172 }
173 timeout(10) {
174 waitUntil {
175 hippie_oss_running = sh returnStdout: true, script: """
176 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
177 kubectl get pods | grep -i hippie-oss | grep -i running | grep 1/1 | wc -l
178 """
179 return hippie_oss_running.toInteger() == 1
180 }
181 }
182 }
183 }
184 stage('Reinstall OLT software') {
185 for(int i=0; i < deployment_config.olts.size(); i++) {
186 sh returnStdout: true, script: """
187 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'
188 """
189 timeout(5) {
190 waitUntil {
191 olt_sw_present = sh returnStdout: true, script: """
192 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'
193 """
194 return olt_sw_present.toInteger() == 0
195 }
196 }
197 sh returnStdout: true, script: """
198 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
199 """
200 timeout(5) {
201 waitUntil {
202 olt_sw_present = sh returnStdout: true, script: """
203 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'
204 """
205 return olt_sw_present.toInteger() == 1
206 }
207 }
208 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
209 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
210 sh returnStdout: true, script: """
211 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'
212 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
213 """
214 }
215 }
216 }
217 stage('Restart OLT processes') {
218 for(int i=0; i < deployment_config.olts.size(); i++) {
219 timeout(5) {
220 sh returnStdout: true, script: """
221 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
222 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'pkill bal_core_dist' || true
223 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'pkill openolt' || true
224 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /broadcom/bal.log'
225 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /broadcom/openolt.log'
226 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 &'
227 sleep 5
228 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 &'
229 """
230 }
231 timeout(15) {
232 waitUntil {
Kailash Khalasi23b693c2018-09-14 14:46:50 -0700233 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 -0700234 return onu_discovered.toInteger() > 0
235 }
236 }
237 }
238 }
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700239 if ( params.configurePod ) {
240 dir ("${configBaseDir}/${configToscaDir}/${profile}") {
Kailash Khalasi164dc142018-09-14 11:49:08 -0700241 stage('Configure R-CORD - Fabric and whitelist') {
242 timeout(1) {
243 waitUntil {
244 out_fabric = sh returnStdout: true, script: """
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700245 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 -0700246 """
247 return out_fabric.toInteger() == 1
248 }
249 }
250 }
251 stage('Configure R-CORD - Subscriber') {
252 timeout(1) {
253 waitUntil {
254 out_subscriber = sh returnStdout: true, script: """
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700255 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 -0700256 """
257 return out_subscriber.toInteger() == 1
258 }
259 }
260 }
261 stage('Configure R-CORD - OLT') {
262 timeout(1) {
263 waitUntil {
264 out_olt = sh returnStdout: true, script: """
Kailash Khalasi4d18e202018-09-14 13:32:16 -0700265 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 -0700266 """
267 return out_olt.toInteger() == 1
268 }
269 }
270 }
271 }
272 }
273 currentBuild.result = 'SUCCESS'
274 } catch (err) {
275 currentBuild.result = 'FAILURE'
276 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
277 }
278 echo "RESULT: ${currentBuild.result}"
279 }
280}