blob: e8041de9ab4ebc956cf3f5a09393bf39e5d654c2 [file] [log] [blame]
Suchitra Vemuriddb27792018-08-23 15:29:42 -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
Suchitra Vemuriddb27792018-08-23 15:29:42 -070015node ("${TestNodeName}") {
Luca Preteb3029bd2018-08-28 16:31:39 -070016 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} ${configRepoUrl}/${configBaseDir}"
Luca Prete43f52cd2018-08-28 16:36:36 -070021 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml"
Suchitra Vemuriddb27792018-08-23 15:29:42 -070022 }
Luca Preteb3029bd2018-08-28 16:31:39 -070023 stage('Clean up') {
24 timeout(10) {
25 sh returnStdout: true, script: """
26 rm -rf helm-charts cord-tester
27 git clone -b ${branch} ${configRepoUrl}/helm-charts
28 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
29 for hchart in \$(helm list -q);
30 do
31 echo "Purging chart: \${hchart}"
32 helm delete --purge "\${hchart}"
33 done
Suchitra Vemuriddb27792018-08-23 15:29:42 -070034 """
Luca Preteb3029bd2018-08-28 16:31:39 -070035 timeout(5) {
36 waitUntil {
37 helm_deleted = sh returnStdout: true, script: """
38 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
39 helm ls | wc -l
Suchitra Vemuriddb27792018-08-23 15:29:42 -070040 """
Luca Preteb3029bd2018-08-28 16:31:39 -070041 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 -v kube-system | wc -l
49 """
50 return kubectl_deleted.toInteger() == 0
Suchitra Vemuriddb27792018-08-23 15:29:42 -070051 }
52 }
53 }
54 }
Luca Preteb3029bd2018-08-28 16:31:39 -070055 dir ("helm-charts") {
56 stage('Install Voltha Kafka') {
57 timeout(10) {
58 sh returnStdout: true, script: """
59 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
60 helm install --name voltha-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false incubator/kafka
Suchitra Vemuriddb27792018-08-23 15:29:42 -070061 """
Luca Preteb3029bd2018-08-28 16:31:39 -070062 }
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 voltha-kafka | grep -i running | grep 1/1 | wc -l
68 """
69 return kafka_instances_running.toInteger() == 2
70 }
71 }
72 }
73 stage('Install voltha') {
74 timeout(10) {
75 sh returnStdout: true, script: """
76 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
77 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
78 helm dep build voltha
79 helm install -n voltha -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcd-operator.customResources.createEtcdClusterCRD=false voltha
80 helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha
81 """
82 }
83 timeout(10) {
84 waitUntil {
85 voltha_completed = sh returnStdout: true, script: """
86 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
87 kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
88 """
89 return voltha_completed.toInteger() == 8
90 }
91 }
92 }
93 stage('Install CORD Kafka') {
94 timeout(10) {
95 sh returnStdout: true, script: """
96 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
97 helm install --name cord-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false incubator/kafka
98 """
99 }
100 timeout(10) {
101 waitUntil {
102 kafka_instances_running = sh returnStdout: true, script: """
103 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
104 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
105 """
106 return kafka_instances_running.toInteger() == 2
107 }
108 }
109 }
110 stage('Install ONOS') {
111 timeout(10) {
112 sh returnStdout: true, script: """
113 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
114 helm install -n onos -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -f configs/onos.yaml onos
115 """
116 }
117 timeout(10) {
118 waitUntil {
119 onos_completed = sh returnStdout: true, script: """
120 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Luca Preteb1ae41b2018-08-28 16:47:54 -0700121 kubectl get pods | grep -i onos | grep -i running | grep 1/1 | wc -l
Luca Preteb3029bd2018-08-28 16:31:39 -0700122 """
123 return onos_completed.toInteger() == 1
124 }
125 }
126 }
127 stage('Install xos-core') {
128 timeout(10) {
129 sh returnStdout: true, script: """
130 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
131 helm dep update xos-core
132 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core xos-core
133 """
134 }
135 timeout(10) {
136 waitUntil {
137 xos_core_completed = sh returnStdout: true, script: """
138 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
139 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
140 """
141 return xos_core_completed.toInteger() == 7
142 }
143 }
144 }
145 stage('Install att-workflow') {
146 timeout(10) {
147 sh returnStdout: true, script: """
148 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
149 helm dep update xos-profiles/att-workflow
150 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n att-workflow xos-profiles/att-workflow
151 """
152 }
153 timeout(10) {
154 waitUntil {
155 att_workflow_tosca_completed = sh returnStdout: true, script: """
156 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
157 kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
158 """
159 return att_workflow_tosca_completed.toInteger() == 1
160 }
161 }
162 }
163 stage('Install base-kubernetes') {
164 timeout(10) {
165 sh returnStdout: true, script: """
166 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
167 helm dep update xos-profiles/base-kubernetes
168 helm install -f ../${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes xos-profiles/base-kubernetes
169 """
170 }
171 timeout(10) {
172 waitUntil {
173 base_kubernetes_tosca_running = sh returnStdout: true, script: """
174 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
175 kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
176 """
177 return base_kubernetes_tosca_running.toInteger() == 1
178 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700179 }
180 }
181 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700182 stage('Reinstall OLT software') {
183 for(int i=0; i < deployment_config.olts.size(); i++) {
184 sh returnStdout: true, script: """
185 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'
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700186 """
Luca Preteb3029bd2018-08-28 16:31:39 -0700187 timeout(5) {
188 waitUntil {
189 olt_sw_present = sh returnStdout: true, script: """
190 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'
191 """
192 return olt_sw_present.toInteger() == 0
193 }
194 }
195 sh returnStdout: true, script: """
196 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
197 """
198 timeout(5) {
199 waitUntil {
200 olt_sw_present = sh returnStdout: true, script: """
201 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'
202 """
203 return olt_sw_present.toInteger() == 1
204 }
205 }
206 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
207 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
208 sh returnStdout: true, script: """
209 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'
210 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
211 """
212 }
213 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700214 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700215 stage('Restart OLT processes') {
216 for(int i=0; i < deployment_config.olts.size(); i++) {
217 timeout(5) {
218 sh returnStdout: true, script: """
219 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
220 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
221 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
222 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'
223 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
224 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
225 sleep 5
226 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
227 """
228 }
229 timeout(15) {
230 waitUntil {
231 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'"
232 return onu_discovered.toInteger() > 0
233 }
234 }
235 }
236 }
237 stage('Download cord-tester repo') {
238 timeout(2) {
239 sh returnStdout: true, script: """
240 git clone -b ${branch} ${configRepoUrl}/cord-tester
241 """
242 }
243 }
244 stage('Validate installed PODs') {
245 timeout(10) {
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700246 sh """
Luca Preteb3029bd2018-08-28 16:31:39 -0700247 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
248 cd $WORKSPACE/cord-tester/src/test/robot/
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700249 rm -rf Log/ || true
250 pybot -d Log -T SanityK8POD.robot || true
251 """
Luca Preteb3029bd2018-08-28 16:31:39 -0700252 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700253 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700254 stage('Configurations and Tests') {
255 timeout(10) {
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700256 sh """
Luca Preteb3029bd2018-08-28 16:31:39 -0700257 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
258 cd $WORKSPACE/cord-tester/src/test/cord-api/Properties/
259 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.nodes[0].ip}\'/\" RestApiProperties.py
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700260 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py
261 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
262 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Luca Preteb3029bd2018-08-28 16:31:39 -0700263 cd $WORKSPACE/cord-tester/src/test/cord-api/Tests/
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700264 rm -rf Log/ || true
265 pybot -d Log -T FabricConfig.txt || true
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700266 sleep 5
267 pybot -d Log -T OSSVolt.txt || true
268 pybot -d Log -T RealOLT_Test.txt || true
269 """
Luca Preteb3029bd2018-08-28 16:31:39 -0700270 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700271 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700272 stage('Subscriber Validation and Ping Tests') {
273 timeout(30) {
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700274 sh """
Luca Preteb3029bd2018-08-28 16:31:39 -0700275 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
276 cd $WORKSPACE/cord-tester/src/test/cord-api/Tests/
277 pybot -d Log -T -v src_ip:${deployment_config.srcHost.ip} -v src_user:${deployment_config.srcHost.user} -v src_pass:${deployment_config.srcHost.pass} -v dst_user:${deployment_config.dstHost.user} -v dst_pass:${deployment_config.dstHost.pass} -v dst_ip:${deployment_config.dstHost.ip} -v dst_host_ip:${deployment_config.dstHost.hostIp} -v src_gateway:${deployment_config.srcHost.gateway} -v dst_gateway:${deployment_config.dstHost.gateway} -v init_state:awaiting-auth -v INITIAL_STATUS:FAIL -v ENABLE_STATUS:FAIL -v MACIP_STATUS:PASS Subscriber_StatusChecks.txt || true
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700278 """
Luca Preteb3029bd2018-08-28 16:31:39 -0700279 }
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700280 }
Luca Preteb3029bd2018-08-28 16:31:39 -0700281 stage('Publish test results') {
282 sh returnStdout: true, script: """
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700283 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs;
284 mkdir RobotLogs/TestDoc || true
Luca Preteb3029bd2018-08-28 16:31:39 -0700285 cp -r $WORKSPACE/cord-tester/src/test/robot/Log/* $WORKSPACE/RobotLogs || true
286 cp -r $WORKSPACE/cord-tester/src/test/cord-api/Tests/Log/* $WORKSPACE/RobotLogs || true
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700287 """
288 step([$class: 'RobotPublisher',
289 disableArchiveOutput: false,
290 logFileName: 'RobotLogs/log*.html',
291 otherFiles: '',
292 outputFileName: 'RobotLogs/output*.xml',
293 outputPath: '.',
294 passThreshold: 100,
295 reportFileName: 'RobotLogs/report*.html',
Luca Preteb3029bd2018-08-28 16:31:39 -0700296 unstableThreshold: 0
297 ])
298 }
299 currentBuild.result = 'SUCCESS'
300 } catch (err) {
301 currentBuild.result = 'FAILURE'
302 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
303 }
304 echo "RESULT: ${currentBuild.result}"
Suchitra Vemuriddb27792018-08-23 15:29:42 -0700305 }
306}