blob: 6247ca5c3a4ad1bfa19c16524e00f1bd3190e07d [file] [log] [blame]
Luca Pretefe3323a2018-08-23 10:17:32 -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 (240) {
17 try {
18 stage ("Parse deployment configuration file") {
19 sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
20 sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
21 deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}"
22 }
23 stage('Clone POD configurations') {
24 timeout(5) {
25 sh returnStdout: true, script: """
26 rm -rf helm-charts
27 rm -rf config-files
28 git clone -b ${branch} https://gerrit.opencord.org/helm-charts
29 git clone https://bitbucket.org/onfcord/podconfigs.git config-files
30 """
31 }
32 }
33 stage('Clean up') {
34 timeout(10) {
35 sh returnStdout: true, script: """
36 export KUBECONFIG=${deployment_config.kube_config}
37 helm ls | grep att-workflow && helm delete --purge att-workflow || true
38 helm ls | grep base-kubernetes && helm delete --purge base-kubernetes || true
39 helm ls | grep xos-core && helm delete --purge xos-core || true
40 helm ls | grep onos-fabric && helm delete --purge onos-fabric || true
41 helm ls | grep onos-voltha && helm delete --purge onos-voltha || true
42 helm ls | grep voltha && helm delete --purge voltha || true
43 """
44 // Wait for helm delete
45 timeout(5) {
46 waitUntil {
47 helm_deleted = sh returnStdout: true, script: """
48 export KUBECONFIG=${deployment_config.kube_config} &&
49 helm ls | grep -E 'onos-voltha|onos-fabric|voltha\$|base-kubernetes|xos-core|att-workflow' | wc -l
50 """
51 return helm_deleted.toInteger() == 0
52 }
53 }
54 timeout(5) {
55 waitUntil {
56 kubectl_deleted = sh returnStdout: true, script: """
57 export KUBECONFIG=${deployment_config.kube_config} &&
58 kubectl get pods --all-namespaces | grep -E 'onos-voltha|onos-fabric|att-workflow|base-kubernetes-|xos-' | wc -l
59 """
60 voltha_namespace_deleted = sh returnStdout: true, script: """
61 export KUBECONFIG=${deployment_config.kube_config} &&
62 kubectl get namespace | grep voltha | wc -l
63 """
64 return kubectl_deleted.toInteger() + voltha_namespace_deleted.toInteger() == 0
65 }
66 }
67 }
68 }
69 dir ("helm-charts") {
70 // stage('Install Voltha Kafka') {
71 // timeout(10) {
72 // sh returnStdout: true, script: """
73 // export KUBECONFIG=${deployment_config.kube_config}
74 // helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
75 // helm install -f ../config-files/seba-values.yaml --name voltha-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false incubator/kafka
76 // """
77 // }
78 // timeout(10) {
79 // waitUntil {
80 // kafka_instances_running = sh returnStdout: true, script: """
81 // export KUBECONFIG=${deployment_config.kube_config} &&
82 // kubectl get pods | grep voltha-kafka | grep -i running | grep 1/1 | wc -l
83 // """
84 // return kafka_instances_running.toInteger() == 2
85 // }
86 // }
87 // }
88 stage('Install voltha') {
89 timeout(10) {
90 sh returnStdout: true, script: """
91 export KUBECONFIG=${deployment_config.kube_config}
92 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
93 helm dep build voltha
94 helm install -f ../config-files/seba-values.yaml -n voltha voltha
95 """
96 }
97 timeout(10) {
98 waitUntil {
99 voltha_completed = sh returnStdout: true, script: """
100 export KUBECONFIG=${deployment_config.kube_config} &&
101 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
102 """
103 return voltha_completed.toInteger() == 8
104 }
105 }
106 }
107 stage('Install ONOS-Voltha') {
108 timeout(10) {
109 sh returnStdout: true, script: """
110 export KUBECONFIG=${deployment_config.kube_config}
111 helm install -f ../config-files/seba-values.yaml -n onos-voltha -f configs/onos-voltha.yaml onos
112 """
113 }
114 timeout(10) {
115 waitUntil {
116 onos_voltha_completed = sh returnStdout: true, script: """
117 export KUBECONFIG=${deployment_config.kube_config} &&
118 kubectl get pods | grep -i onos-voltha | grep -i running | grep 1/1 | wc -l
119 """
120 return onos_voltha_completed.toInteger() == 1
121 }
122 }
123 }
124 stage('Install ONOS-Fabric') {
125 timeout(10) {
126 sh returnStdout: true, script: """
127 export KUBECONFIG=${deployment_config.kube_config}
128 helm install -f ../config-files/seba-values.yaml -n onos-fabric -f configs/onos-fabric.yaml onos
129 """
130 }
131 timeout(10) {
132 waitUntil {
133 onos_fabric_completed = sh returnStdout: true, script: """
134 export KUBECONFIG=${deployment_config.kube_config} &&
135 kubectl get pods | grep -i onos-fabric | grep -i running | grep 1/1 | wc -l
136 """
137 return onos_fabric_completed.toInteger() == 1
138 }
139 }
140 }
141 stage('Install xos-core') {
142 timeout(10) {
143 sh returnStdout: true, script: """
144 export KUBECONFIG=${deployment_config.kube_config}
145 helm dep update xos-core
146 helm install -f ../config-files/seba-values.yaml -n xos-core xos-core
147 """
148 }
149 timeout(10) {
150 waitUntil {
151 xos_core_completed = sh returnStdout: true, script: """
152 export KUBECONFIG=${deployment_config.kube_config} &&
153 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
154 """
155 return xos_core_completed.toInteger() == 7
156 }
157 }
158 }
159 stage('Install att-workflow') {
160 timeout(10) {
161 sh returnStdout: true, script: """
162 export KUBECONFIG=${deployment_config.kube_config}
163 helm dep update xos-profiles/att-workflow
164 helm install -f ../config-files/seba-values.yaml -n att-workflow xos-profiles/att-workflow
165 """
166 }
167 timeout(10) {
168 waitUntil {
169 att_workflow_tosca_completed = sh returnStdout: true, script: """
170 export KUBECONFIG=${deployment_config.kube_config} &&
171 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
172 """
173 return att_workflow_tosca_completed.toInteger() == 1
174 }
175 }
176 }
177 // stage('Install CORD Kafka') {
178 // timeout(10) {
179 // sh returnStdout: true, script: """
180 // export KUBECONFIG=${deployment_config.kube_config}
181 // helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
182 // helm install -f ../config-files/seba-values.yaml --name cord-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false incubator/kafka
183 // """
184 // }
185 // timeout(10) {
186 // waitUntil {
187 // kafka_instances_running = sh returnStdout: true, script: """
188 // export KUBECONFIG=${deployment_config.kube_config} &&
189 // kubectl get pods | grep cord-kafka | grep -i Running | grep 1/1 | wc -l
190 // """
191 // return kafka_instances_running.toInteger() == 2
192 // }
193 // }
194 // }
195 stage('Install base-kubernetes') {
196 timeout(10) {
197 sh returnStdout: true, script: """
198 export KUBECONFIG=${deployment_config.kube_config}
199 helm dep update xos-profiles/base-kubernetes
200 helm install -f ../config-files/seba-values.yaml -n base-kubernetes xos-profiles/base-kubernetes
201 """
202 }
203 timeout(10) {
204 waitUntil {
205 base_kubernetes_tosca_running = sh returnStdout: true, script: """
206 export KUBECONFIG=${deployment_config.kube_config} &&
207 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
208 """
209 return base_kubernetes_tosca_running.toInteger() == 1
210 }
211 }
212 }
213 }
214 stage('Restart OLT processes') {
215 for(int i=0; i < deployment_config.olts.size(); i++) {
216 timeout(5) {
217 sh returnStdout: true, script: """
218 ssh-keyscan -H ${deployment_config.olts[i].ip} >> /home/ubuntu/.ssh/known_hosts
219 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
220 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
221 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'
222 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
223 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
224 sleep 5
225 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
226 """
227 }
228 timeout(15) {
229 waitUntil {
230 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 \"olt indication, oper_state:up\" | wc -l'"
231 return onu_discovered.toInteger() > 0
232 }
233 }
234 }
235 }
236 dir ("config-files") {
237 stage('Configure R-CORD - Fabric and whitelist') {
238 timeout(1) {
239 waitUntil {
240 out_fabric = sh returnStdout: true, script: """
241 cd tosca/att-workflow &&
242 curl -s -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @pod-configuration.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
243 """
244 return out_fabric.toInteger() == 1
245 }
246 }
247 }
248 stage('Configure R-CORD - Subscriber') {
249 timeout(1) {
250 waitUntil {
251 out_subscriber = sh returnStdout: true, script: """
252 cd tosca/att-workflow &&
253 curl -s -H 'xos-username: admin@opencord.org' -H 'xos-password: letmein' -X POST --data-binary @subscriber.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
254 """
255 return out_subscriber.toInteger() == 1
256 }
257 }
258 }
259 stage('Configure R-CORD - OLT') {
260 timeout(1) {
261 waitUntil {
262 out_olt = sh returnStdout: true, script: """
263 cd tosca/att-workflow &&
264 curl -H 'xos-username: admin@opencord.org' -H 'xos-password: letmein' -X POST --data-binary @pod-olt.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
265 """
266 return out_olt.toInteger() == 1
267 }
268 }
269 }
270 }
271 currentBuild.result = 'SUCCESS'
272 } catch (err) {
273 currentBuild.result = 'FAILURE'
274 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmails}", sendToIndividuals: false])
275 }
276 echo "RESULT: ${currentBuild.result}"
277 }
278}