blob: 8b8142b0ff9aaa84e1f0893915c7f944e772c0ab [file] [log] [blame]
Luca Prete22613652018-12-17 14:17:43 -08001// 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}.yaml"
22 }
23 stage('Clean up') {
24 timeout(10) {
25 sh returnStdout: true, script: """
26 rm -rf cord-tester
27 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
28 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
29 do
30 echo "Purging chart: \${hchart}"
31 helm delete --purge "\${hchart}"
32 done
33 """
34 timeout(5) {
35 waitUntil {
36 helm_deleted = sh returnStdout: true, script: """
37 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
38 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
39 """
40 return helm_deleted.toInteger() == 0
41 }
42 }
43 timeout(5) {
44 waitUntil {
45 kubectl_deleted = sh returnStdout: true, script: """
46 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
47 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
48 """
49 return kubectl_deleted.toInteger() == 0
50 }
51 }
52 }
53 }
54 stage('Add CORD repository') {
55 sh returnStdout: true, script: """
56 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
57 helm repo add cord https://charts.opencord.org
58 helm repo update
59 """
60 timeout(1) {
61 waitUntil {
62 cord_repo_present = sh returnStdout: true, script: """
63 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
64 helm repo list | grep cord | wc -l
65 """
66 return cord_repo_present.toInteger() == 1
67 }
68 }
69 }
70 stage('Install CORD Platform') {
71 sh returnStdout: true, script: """
72 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete45c393b2018-12-18 12:18:14 -080073 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n cord-platform --version 6.1.0 cord/cord-platform
Luca Prete22613652018-12-17 14:17:43 -080074 """
75 timeout(1) {
76 waitUntil {
77 cord_helm_installed = sh returnStdout: true, script: """
78 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
79 helm ls | grep -i cord-platform | wc -l
80 """
81 return cord_helm_installed.toInteger() == 1
82 }
83 }
84 }
85 stage('Install SEBA Profile') {
86 sh returnStdout: true, script: """
87 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
88 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba --version 1.0.0 cord/seba
89 """
90 timeout(1) {
91 waitUntil {
92 seba_helm_installed = sh returnStdout: true, script: """
93 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
94 helm ls | grep -i seba | wc -l
95 """
96 return seba_helm_installed.toInteger() == 1
97 }
98 }
99 }
100 stage('Install ATT workflow') {
101 sh returnStdout: true, script: """
102 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
103 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n att-workflow --version 1.0.0 cord/att-workflow
104 """
105 timeout(1) {
106 waitUntil {
107 attworkflow_helm_installed = sh returnStdout: true, script: """
108 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
109 helm ls | grep -i att-workflow | wc -l
110 """
111 return attworkflow_helm_installed.toInteger() == 1
112 }
113 }
114 }
115 stage('Check containers are running') {
116 timeout(20) {
117 waitUntil {
118 pods_running = sh returnStdout: true, script: """
119 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Kailash392f4f42018-12-18 13:41:43 -0800120 kubectl get pods --all-namespaces | grep -i running | grep -E -v 'docker-registry|mavenrepo|ponnet|kube-system' | wc -l
Luca Prete22613652018-12-17 14:17:43 -0800121 """
Kailash392f4f42018-12-18 13:41:43 -0800122 return pods_running.toInteger() == 51
Luca Prete22613652018-12-17 14:17:43 -0800123 }
124 waitUntil {
125 pods_completed = sh returnStdout: true, script: """
126 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Kailash392f4f42018-12-18 13:41:43 -0800127 kubectl get pods --all-namespaces | grep -i completed | grep -E -v 'docker-registry|mavenrepo|ponnet|kube-system' | wc -l
Luca Prete22613652018-12-17 14:17:43 -0800128 """
129 return pods_completed.toInteger() == 3
130 }
131 }
132 }
133 if ( params.reinstallOlt ) {
134 stage('Reinstall OLT software') {
135 for(int i=0; i < deployment_config.olts.size(); i++) {
136 sh returnStdout: true, script: """
137 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'
138 """
139 timeout(5) {
140 waitUntil {
141 olt_sw_present = sh returnStdout: true, script: """
142 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'
143 """
144 return olt_sw_present.toInteger() == 0
145 }
146 }
147 sh returnStdout: true, script: """
148 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
149 """
150 timeout(5) {
151 waitUntil {
152 olt_sw_present = sh returnStdout: true, script: """
153 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'
154 """
155 return olt_sw_present.toInteger() == 1
156 }
157 }
158 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
159 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
160 sh returnStdout: true, script: """
161 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'
162 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
163 """
164 }
165 }
166 }
167 stage('Restart OLT processes') {
168 for(int i=0; i < deployment_config.olts.size(); i++) {
169 timeout(5) {
170 sh returnStdout: true, script: """
171 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
172 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
173 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
174 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'
175 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
176 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
177 sleep 5
178 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
179 """
180 }
181 timeout(15) {
182 waitUntil {
183 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'"
184 return onu_discovered.toInteger() > 0
185 }
186 }
187 }
188 }
189 }
190 if ( params.configurePod ) {
191 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
192 stage('Configure R-CORD - Fabric and whitelist') {
193 timeout(1) {
194 waitUntil {
195 out_fabric = sh returnStdout: true, script: """
196 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
197 """
198 return out_fabric.toInteger() == 1
199 }
200 }
201 }
202 stage('Configure R-CORD - Subscriber') {
203 timeout(1) {
204 waitUntil {
205 out_subscriber = sh returnStdout: true, script: """
206 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
207 """
208 return out_subscriber.toInteger() == 1
209 }
210 }
211 }
212 stage('Configure R-CORD - OLT') {
213 timeout(1) {
214 waitUntil {
215 out_olt = sh returnStdout: true, script: """
216 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
217 """
218 return out_olt.toInteger() == 1
219 }
220 }
221 }
222 }
223 }
224 if ( params.installBBSim ) {
225 dir ("helm-charts") {
226 stage('Install BBSim') {
227 timeout(10) {
228 sh returnStdout: true, script: """
229 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
230 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
231 """
232 }
233 timeout(10) {
234 waitUntil {
235 base_kubernetes_tosca_running = sh returnStdout: true, script: """
236 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
237 kubectl get pods -n voltha | grep -i bbsim | wc -l
238 """
239 return base_kubernetes_tosca_running.toInteger() == 1
240 }
241 }
242 }
243 }
244 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
245 stage('Configure BBSim - OLT') {
246 timeout(1) {
247 waitUntil {
248 out_olt = sh returnStdout: true, script: """
249 curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @bbsim-16.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
250 """
251 return out_olt.toInteger() == 1
252 }
253 }
254 }
255 }
256 }
257 currentBuild.result = 'SUCCESS'
258 } catch (err) {
259 currentBuild.result = 'FAILURE'
260 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
261 }
262 echo "RESULT: ${currentBuild.result}"
263 }
264}