blob: f911cc8cb27b45660cf20b4eb24d5d0330d0f3d6 [file] [log] [blame]
Suchitra Vemurid9cffa82018-07-25 14:06:47 -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
25 stage('Export pod config') {
26 timeout(10) {
27 try {
28 sh """
29 cd /home/cord
30 rm -rf /home/cord/helm-charts
31 git clone -b ${branch} https://gerrit.opencord.org/helm-charts
32 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
33 kubectl get pods
34 """
35 } catch(error) { currentBuild.result = 'FAILURE' }
36 }
37 }
38 stage('Clean up') {
39 timeout(10) {
40 try {
41 sh """
42 cd /home/cord/helm-charts
43 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
44 helm ls | grep onos-voltha && helm delete --purge onos-voltha || true
45 helm ls | grep onos-fabric && helm delete --purge onos-fabric || true
46 helm ls | grep voltha && helm delete --purge voltha || true
47 helm ls | grep rcord-lite && helm delete --purge rcord-lite || true
48 helm ls | grep xos-core && helm delete --purge xos-core || true
49 """
50 } catch(error) { currentBuild.result = 'FAILURE' }
51 // Wait for helm delete
52 timeout(5) {
53 waitUntil {
54 try {
55 sh """
56 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
57 ! helm ls | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite|xos-core'
58 ! kubectl get pods --all-namespaces | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite-|xos-'
59 """
60 return true
61 } catch (exception) {
62 return false
63 }
64 }
65 }
66 }
67 }
68 stage('Install xos-core and rcord-lite') {
69 timeout(10) {
70 try {
71 sh """
72 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
73 cd /home/cord/helm-charts
74 helm dep update xos-core
75 helm install -n xos-core xos-core
76 helm dep update xos-profiles/rcord-lite
77 helm install -n rcord-lite xos-profiles/rcord-lite
78 """
79 } catch(error) { currentBuild.result = 'FAILURE' }
80 }
81 }
82 stage('Install voltha') {
83 timeout(10) {
84 try {
85 sh """
86 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
87 cd /home/cord/helm-charts
88 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
89 helm dep build voltha
90 helm install -n voltha --set etcd-operator.customResources.createEtcdClusterCRD=false voltha
91 helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha
92 """
93 } catch(error) { currentBuild.result = 'FAILURE' }
94 }
95 }
96 stage('Install ONOS-Voltha and ONOS-Fabric') {
97 timeout(10) {
98 try {
99 sh """
100 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
101 cd /home/cord/helm-charts
102 helm install -n onos-fabric -f configs/onos-fabric.yaml onos
103 helm install -n onos-voltha -f configs/onos-voltha.yaml onos
104 sleep 60
105 """
106 } catch(error) { currentBuild.result = 'FAILURE' }
107 }
108 }
109 /*
110 stage('Download cord-tester repo') {
111 timeout(10) {
112 try {
113 sh """
114 rm -rf /home/cord/cord-tester
115 cd /home/cord/
116 git clone -b ${branch} https://gerrit.opencord.org/cord-tester
117 """
118 } catch(error) { currentBuild.result = 'FAILURE' }
119 }
120 }
121 stage('Validate Helm Chart Install') {
122 timeout(10) {
123 try {
124 sh """
125 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
126 cd /home/cord/cord-tester/src/test/robot/
127 rm -rf Log/ || true
128 pybot -d Log -T SanityK8POD.robot || all_passed=false
129 #if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
130 """
131 } catch(error) { currentBuild.result = 'FAILURE' }
132 }
133 }*/
134 stage('Wait for PODs to complete') {
135 /*
136 timeout(5) {
137 try {
138 sh """
139 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
140 chameleon=\$(kubectl get pods | grep chameleon | cut -d' ' -f1)
141 echo \$chameleon
142 kubectl delete pod \$chameleon
143 """
144 } catch(error) { currentBuild.result = 'FAILURE' }
145 }*/
146 timeout(5) {
147 waitUntil {
148 try {
149 sh """
150 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
151 kubectl get pods | grep -i tosca-loader | grep -i complete
152 kubectl get pods | grep -i chameleon | grep -i running
153 kubectl get pods | grep -i onos-fabric | grep -i running
154 kubectl get pods --namespace=voltha | grep -i voltha- | grep -i running
155 kubectl get pods --namespace=voltha | grep -i onos-voltha | grep -i running
156 """
157 return true
158 } catch (exception) {
159 return false
160 }
161 }
162 }
163 }
164 stage('Restart OLT processes') {
165 timeout(5) {
166 try {
167 sh """
168 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
169 sshpass -p onl ssh -l root 10.192.4.218 'pkill bal_core_dist' || true
170 sshpass -p onl ssh -l root 10.192.4.218 'pkill openolt' || true
171 sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./bal_core_dist -C 127.0.0.1:40000 -A 127.0.0.1:50000 < /dev/tty1 > ./bal.log 2>&1 &'
172 sshpass -p onl ssh -l root 10.192.4.218 'cd /broadcom; ./openolt -C 127.0.0.1:40000 -A 127.0.0.1:50000 < /dev/tty1 > ./openolt.log 2>&1 &'
173 sleep 120
174 """
175 } catch(error) { currentBuild.result = 'FAILURE' }
176 }
177 }
178 stage('Download cord-tester repo') {
179 timeout(10) {
180 try {
181 sh """
182 rm -rf /home/cord/cord-tester
183 cd /home/cord/
184 git clone -b ${branch} https://gerrit.opencord.org/cord-tester
185 """
186 } catch(error) { currentBuild.result = 'FAILURE' }
187 }
188 }
189 stage('Validate Helm Chart Install') {
190 timeout(10) {
191 try {
192 sh """
193 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
194 cd /home/cord/cord-tester/src/test/robot/
195 rm -rf Log/ || true
196 pybot -d Log -T SanityK8POD.robot || all_passed=false
197 #if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
198 """
199 } catch(error) { currentBuild.result = 'FAILURE' }
200 }
201 }
202 stage('Configuration and Tests') {
203 timeout(10) {
204 try {
205 sh """
206 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
207 cd /home/cord/cord-tester/src/test/cord-api/Properties/
208 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.node1.ip}\'/\" RestApiProperties.py
209 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py
210 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
211 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
212 cd /home/cord/cord-tester/src/test/cord-api/Tests/
213 rm -rf Log/ || true
214 pybot -d Log -T FabricConfig.txt || all_passed=false
215 pybot -d Log -T RealOLT_Test.txt || all_passed=false
216 sleep 120
217 pybot -d Log -T Subscriber_TopDown.txt || all_passed=false
218 #if [ "\\\$all_passed" = true ]; then exit 0; else exit 1; fi
219 """
220 } catch(error) { currentBuild.result = 'FAILURE' }
221 }
222 }
223 stage('Publish') {
224 try {
225 sh """
226 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs;
227 mkdir RobotLogs/TestDoc || true
228 //cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true
229 cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true
230 """
231 step([$class: 'RobotPublisher',
232 disableArchiveOutput: false,
233 logFileName: 'RobotLogs/log*.html',
234 otherFiles: '',
235 outputFileName: 'RobotLogs/output*.xml',
236 outputPath: '.',
237 passThreshold: 100,
238 reportFileName: 'RobotLogs/report*.html',
239 unstableThreshold: 0])
240 } catch(error) {}
241 }
242 //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
243 }
244}