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