blob: 547aa69934b4a502d19e140ec3c5244a87a6b224 [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}"
Kailash093f55b2018-12-19 09:33:49 -080021 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
Luca Prete22613652018-12-17 14:17:43 -080022 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
23 }
24 stage('Clean up') {
25 timeout(10) {
26 sh returnStdout: true, script: """
27 rm -rf cord-tester
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 stage('Add CORD repository') {
56 sh returnStdout: true, script: """
57 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
58 helm repo add cord https://charts.opencord.org
59 helm repo update
60 """
61 timeout(1) {
62 waitUntil {
63 cord_repo_present = sh returnStdout: true, script: """
64 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
65 helm repo list | grep cord | wc -l
66 """
67 return cord_repo_present.toInteger() == 1
68 }
69 }
70 }
71 stage('Install CORD Platform') {
72 sh returnStdout: true, script: """
73 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
You Wangbe85ad72018-12-18 14:18:32 -080074 helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n cord-platform --version 6.1.0 cord/cord-platform
Luca Prete22613652018-12-17 14:17:43 -080075 """
76 timeout(1) {
77 waitUntil {
78 cord_helm_installed = sh returnStdout: true, script: """
79 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
80 helm ls | grep -i cord-platform | wc -l
81 """
82 return cord_helm_installed.toInteger() == 1
83 }
84 }
85 }
86 stage('Install SEBA Profile') {
87 sh returnStdout: true, script: """
88 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
You Wangbe85ad72018-12-18 14:18:32 -080089 helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba --version 1.0.0 cord/seba
Luca Prete22613652018-12-17 14:17:43 -080090 """
91 timeout(1) {
92 waitUntil {
93 seba_helm_installed = sh returnStdout: true, script: """
94 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
95 helm ls | grep -i seba | wc -l
96 """
97 return seba_helm_installed.toInteger() == 1
98 }
99 }
100 }
101 stage('Install ATT workflow') {
102 sh returnStdout: true, script: """
103 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
You Wangbe85ad72018-12-18 14:18:32 -0800104 helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n att-workflow --version 1.0.0 cord/att-workflow
Luca Prete22613652018-12-17 14:17:43 -0800105 """
106 timeout(1) {
107 waitUntil {
108 attworkflow_helm_installed = sh returnStdout: true, script: """
109 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
110 helm ls | grep -i att-workflow | wc -l
111 """
112 return attworkflow_helm_installed.toInteger() == 1
113 }
114 }
115 }
116 stage('Check containers are running') {
117 timeout(20) {
118 waitUntil {
Kailash093f55b2018-12-19 09:33:49 -0800119 sh returnStdout: true, script: """
Luca Prete22613652018-12-17 14:17:43 -0800120 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Kailash093f55b2018-12-19 09:33:49 -0800121 helm-repo-tools/wait_for_pods.sh
Luca Prete22613652018-12-17 14:17:43 -0800122 """
Luca Prete22613652018-12-17 14:17:43 -0800123 pods_completed = sh returnStdout: true, script: """
124 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Kailash392f4f42018-12-18 13:41:43 -0800125 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 -0800126 """
127 return pods_completed.toInteger() == 3
128 }
129 }
130 }
131 if ( params.reinstallOlt ) {
132 stage('Reinstall OLT software') {
133 for(int i=0; i < deployment_config.olts.size(); i++) {
134 sh returnStdout: true, script: """
135 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'
136 """
137 timeout(5) {
138 waitUntil {
139 olt_sw_present = sh returnStdout: true, script: """
140 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'
141 """
142 return olt_sw_present.toInteger() == 0
143 }
144 }
145 sh returnStdout: true, script: """
146 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
147 """
148 timeout(5) {
149 waitUntil {
150 olt_sw_present = sh returnStdout: true, script: """
151 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'
152 """
153 return olt_sw_present.toInteger() == 1
154 }
155 }
156 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
157 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
158 sh returnStdout: true, script: """
159 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'
160 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
161 """
162 }
163 }
164 }
165 stage('Restart OLT processes') {
166 for(int i=0; i < deployment_config.olts.size(); i++) {
167 timeout(5) {
168 sh returnStdout: true, script: """
169 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
170 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
171 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
172 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'
173 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
174 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
175 sleep 5
176 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
177 """
178 }
179 timeout(15) {
180 waitUntil {
181 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'"
182 return onu_discovered.toInteger() > 0
183 }
184 }
185 }
186 }
187 }
188 if ( params.configurePod ) {
189 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
190 stage('Configure R-CORD - Fabric and whitelist') {
191 timeout(1) {
192 waitUntil {
193 out_fabric = sh returnStdout: true, script: """
194 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
195 """
196 return out_fabric.toInteger() == 1
197 }
198 }
199 }
200 stage('Configure R-CORD - Subscriber') {
201 timeout(1) {
202 waitUntil {
203 out_subscriber = sh returnStdout: true, script: """
204 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
205 """
206 return out_subscriber.toInteger() == 1
207 }
208 }
209 }
210 stage('Configure R-CORD - OLT') {
211 timeout(1) {
212 waitUntil {
213 out_olt = sh returnStdout: true, script: """
214 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
215 """
216 return out_olt.toInteger() == 1
217 }
218 }
219 }
220 }
221 }
222 if ( params.installBBSim ) {
223 dir ("helm-charts") {
224 stage('Install BBSim') {
225 timeout(10) {
226 sh returnStdout: true, script: """
227 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
You Wangbe85ad72018-12-18 14:18:32 -0800228 helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber}
Luca Prete22613652018-12-17 14:17:43 -0800229 """
230 }
231 timeout(10) {
232 waitUntil {
233 base_kubernetes_tosca_running = sh returnStdout: true, script: """
234 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
235 kubectl get pods -n voltha | grep -i bbsim | wc -l
236 """
237 return base_kubernetes_tosca_running.toInteger() == 1
238 }
239 }
240 }
241 }
242 dir ("${configBaseDir}/${configToscaDir}/bbsim") {
243 stage('Configure BBSim - OLT') {
244 timeout(1) {
245 waitUntil {
246 out_olt = sh returnStdout: true, script: """
247 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
248 """
249 return out_olt.toInteger() == 1
250 }
251 }
252 }
253 }
254 }
255 currentBuild.result = 'SUCCESS'
256 } catch (err) {
257 currentBuild.result = 'FAILURE'
258 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
259 }
260 echo "RESULT: ${currentBuild.result}"
261 }
262}