blob: 3f39f0cfbce1eb41dd68498207a6f8c47ebcc071 [file] [log] [blame]
Suchitra Vemurif126e7e2018-08-01 11:31:11 -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
15pod_config = null
16
17node ("${TestNodeName}") {
18 timeout (time: 240) {
19 stage ("Parse deployment configuration file") {
20 sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
21 sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
22 deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}"
23 }
24 stage('Export pod config') {
25 timeout(10) {
26 try {
27 sh """
28 cd /home/cord
29 rm -rf /home/cord/helm-charts
30 git clone -b ${branch} https://gerrit.opencord.org/helm-charts
31 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
32 kubectl get pods
33 """
34 } catch(error) { currentBuild.result = 'FAILURE' }
35 }
36 }
37 stage('Clean up') {
38 timeout(10) {
39 try {
40 sh """
41 cd /home/cord/helm-charts
42 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
43 helm ls | grep onos-voltha && helm delete --purge onos-voltha || true
44 helm ls | grep onos-fabric && helm delete --purge onos-fabric || true
45 helm ls | grep voltha && helm delete --purge voltha || true
46 helm ls | grep rcord-lite && helm delete --purge rcord-lite || true
47 helm ls | grep xos-core && helm delete --purge xos-core || true
48 helm ls | grep cord-kafka && helm delete --purge cord-kafka || true
49 helm ls | grep voltha-kafka && helm delete --purge voltha-kafka || true
Suchitra Vemuria31f5ee2018-08-15 15:32:22 -070050 helm ls | grep hippie && helm delete --purge hippie-oss || true
Suchitra Vemurif126e7e2018-08-01 11:31:11 -070051 """
52 } catch(error) { currentBuild.result = 'FAILURE' }
53 // Wait for helm delete
54 timeout(5) {
55 waitUntil {
56 try {
57 sh """
58 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
Suchitra Vemuri22caabd2018-08-07 14:55:10 -070059 ! helm ls | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite|xos-core|cord-kafka|voltha-kafka'
Suchitra Vemurif126e7e2018-08-01 11:31:11 -070060 ! kubectl get pods --all-namespaces | grep -E 'onos-voltha|onos-fabric|cord-kafka|voltha |rcord-lite-|xos-'
61 """
62 return true
63 } catch (exception) {
64 return false
65 }
66 }
67 }
68 }
69 }
70 stage('Restart OLT processes') {
71 timeout(5) {
72 try {
73 sh """
74 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
75 sshpass -p onl ssh -l root 10.192.4.218 'pkill bal_core_dist || true'
76 sshpass -p onl ssh -l root 10.192.4.218 'pkill openolt || true'
77 sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./bal_core_dist -C :55001 < /dev/tty1 > ./bal.log 2>&1 &'
78 sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./openolt -C 127.0.0.1:55001 < /dev/tty1 > ./openolt.log 2>&1 &'
79 sleep 120
80 """
81 } catch(error) { currentBuild.result = 'FAILURE' }
82 }
83 }
84 stage('Install Kafka') {
85 timeout(10) {
86 try {
87 sh """
88 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
89 cd /home/cord/helm-charts
90 helm install --name cord-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.servers=1 --set zookeeper.persistence.enabled=false incubator/kafka
91 helm install --name voltha-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.servers=1 --set zookeeper.persistence.enabled=false incubator/kafka
92 Sleep 120
93 """
94 } catch(error) { currentBuild.result = 'FAILURE' }
95 }
96 }
97 stage('Install xos-core and rcord-lite') {
98 timeout(10) {
99 try {
100 sh """
101 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
102 cd /home/cord/helm-charts
103 helm dep update xos-core
104 helm install -n xos-core xos-core
105 helm dep update xos-profiles/rcord-lite
106 helm install -n rcord-lite xos-profiles/rcord-lite
Suchitra Vemuri22caabd2018-08-07 14:55:10 -0700107 helm install -n hippie-oss xos-services/hippie-oss
Suchitra Vemurif126e7e2018-08-01 11:31:11 -0700108 """
109 } catch(error) { currentBuild.result = 'FAILURE' }
110 }
111 }
112 stage('Install voltha') {
113 timeout(10) {
114 try {
115 sh """
116 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
117 cd /home/cord/helm-charts
118 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
119 helm dep build voltha
120 helm install -n voltha --set etcd-operator.customResources.createEtcdClusterCRD=false voltha
121 helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha
122 """
123 } catch(error) { currentBuild.result = 'FAILURE' }
124 }
125 }
126 stage('Install ONOS-Voltha and ONOS-Fabric') {
127 timeout(10) {
128 try {
129 sh """
130 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
131 cd /home/cord/helm-charts
132 helm install -n onos-fabric -f configs/onos-fabric.yaml onos
133 helm install -n onos-voltha -f configs/onos-voltha.yaml onos
134 sleep 60
135 """
136 } catch(error) { currentBuild.result = 'FAILURE' }
137 }
138 }
139 stage('Wait for PODs to complete') {
140 timeout(5) {
141 waitUntil {
142 try {
143 sh """
144 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
145 kubectl get pods | grep -i tosca-loader | grep -i complete
146 kubectl get pods | grep -i chameleon | grep -i running
147 kubectl get pods | grep -i onos-fabric | grep -i running
148 kubectl get pods --namespace=voltha | grep -i voltha- | grep -i running
149 kubectl get pods --namespace=voltha | grep -i onos-voltha | grep -i running
150 """
151 return true
152 } catch (exception) {
153 return false
154 }
155 }
156 }
157 }
158 stage('Download cord-tester repo') {
159 timeout(10) {
160 try {
161 sh """
162 rm -rf /home/cord/cord-tester
163 cd /home/cord/
164 git clone -b ${branch} https://gerrit.opencord.org/cord-tester
165 """
166 } catch(error) { currentBuild.result = 'FAILURE' }
167 }
168 }
169 stage('Validate installed PODs') {
170 timeout(10) {
171 try {
172 sh """
173 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
174 cd /home/cord/cord-tester/src/test/robot/
175 rm -rf Log/ || true
Suchitra Vemuri22caabd2018-08-07 14:55:10 -0700176 pybot -d Log -T SanityK8POD.robot || true
Suchitra Vemurif126e7e2018-08-01 11:31:11 -0700177 """
178 } catch(error) { currentBuild.result = 'FAILURE' }
179 }
180 }
181 stage('Configurations and Tests') {
182 timeout(10) {
183 try {
184 sh """
185 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
186 cd /home/cord/cord-tester/src/test/cord-api/Properties/
187 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.node1.ip}\'/\" RestApiProperties.py
188 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py
189 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
190 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
191 cd /home/cord/cord-tester/src/test/cord-api/Tests/
192 rm -rf Log/ || true
Suchitra Vemuri22caabd2018-08-07 14:55:10 -0700193 pybot -d Log -T FabricConfig.txt || true
194 pybot -d Log -T HippieOSS.txt || true
Suchitra Vemuria31f5ee2018-08-15 15:32:22 -0700195 sleep 5
Suchitra Vemuri22caabd2018-08-07 14:55:10 -0700196 pybot -d Log -T OSSVolt.txt || true
197 pybot -d Log -T RealOLT_Test.txt || true
Suchitra Vemurif126e7e2018-08-01 11:31:11 -0700198 """
199 } catch(error) { currentBuild.result = 'FAILURE' }
200 }
201 }
Suchitra Vemuria31f5ee2018-08-15 15:32:22 -0700202 stage('Subscriber Validation and Ping Tests') {
Kailash Khalasi62267102018-08-16 11:38:44 -0700203 timeout(20) {
Suchitra Vemuria31f5ee2018-08-15 15:32:22 -0700204 try {
205 sh """
206 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
207 cd /home/cord/cord-tester/src/test/cord-api/Tests/
Kailash Khalasi62267102018-08-16 11:38:44 -0700208 pybot -d Log -T HippieOSS_instances.txt || true
209 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_ip:${deployment_config.dstHost.hostIp} Subscriber_StatusChecks.txt || true
210 """
Suchitra Vemuria31f5ee2018-08-15 15:32:22 -0700211 } catch(error) { currentBuild.result = 'FAILURE' }
212 }
213 }
Suchitra Vemurif126e7e2018-08-01 11:31:11 -0700214 stage('Publish') {
215 try {
216 sh """
217 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs;
218 mkdir RobotLogs/TestDoc || true
Suchitra Vemuri22caabd2018-08-07 14:55:10 -0700219 cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true
Suchitra Vemurif126e7e2018-08-01 11:31:11 -0700220 cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true
221 """
222 step([$class: 'RobotPublisher',
223 disableArchiveOutput: false,
224 logFileName: 'RobotLogs/log*.html',
225 otherFiles: '',
226 outputFileName: 'RobotLogs/output*.xml',
227 outputPath: '.',
228 passThreshold: 100,
229 reportFileName: 'RobotLogs/report*.html',
230 unstableThreshold: 0])
231 } catch(error) {}
232 }
233 //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
234 }
235}