Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | pod_config = null |
| 16 | |
| 17 | node ("${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 |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 128 | pybot -d Log -T SanityK8POD.robot || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 129 | """ |
| 130 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 131 | } |
| 132 | }*/ |
| 133 | stage('Wait for PODs to complete') { |
| 134 | /* |
| 135 | timeout(5) { |
| 136 | try { |
| 137 | sh """ |
| 138 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 139 | chameleon=\$(kubectl get pods | grep chameleon | cut -d' ' -f1) |
| 140 | echo \$chameleon |
| 141 | kubectl delete pod \$chameleon |
| 142 | """ |
| 143 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 144 | }*/ |
| 145 | timeout(5) { |
| 146 | waitUntil { |
| 147 | try { |
| 148 | sh """ |
| 149 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 150 | kubectl get pods | grep -i tosca-loader | grep -i complete |
| 151 | kubectl get pods | grep -i chameleon | grep -i running |
| 152 | kubectl get pods | grep -i onos-fabric | grep -i running |
| 153 | kubectl get pods --namespace=voltha | grep -i voltha- | grep -i running |
| 154 | kubectl get pods --namespace=voltha | grep -i onos-voltha | grep -i running |
| 155 | """ |
| 156 | return true |
| 157 | } catch (exception) { |
| 158 | return false |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | stage('Restart OLT processes') { |
| 164 | timeout(5) { |
| 165 | try { |
| 166 | sh """ |
| 167 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 168 | sshpass -p onl ssh -l root 10.192.4.218 'pkill bal_core_dist' || true |
| 169 | sshpass -p onl ssh -l root 10.192.4.218 'pkill openolt' || true |
| 170 | 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 &' |
| 171 | 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 &' |
| 172 | sleep 120 |
| 173 | """ |
| 174 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 175 | } |
| 176 | } |
| 177 | stage('Download cord-tester repo') { |
| 178 | timeout(10) { |
| 179 | try { |
| 180 | sh """ |
| 181 | rm -rf /home/cord/cord-tester |
| 182 | cd /home/cord/ |
| 183 | git clone -b ${branch} https://gerrit.opencord.org/cord-tester |
| 184 | """ |
| 185 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 186 | } |
| 187 | } |
| 188 | stage('Validate Helm Chart Install') { |
| 189 | timeout(10) { |
| 190 | try { |
| 191 | sh """ |
| 192 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 193 | cd /home/cord/cord-tester/src/test/robot/ |
| 194 | rm -rf Log/ || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 195 | pybot -d Log -T SanityK8POD.robot || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 196 | """ |
| 197 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 198 | } |
| 199 | } |
| 200 | stage('Configuration and Tests') { |
| 201 | timeout(10) { |
| 202 | try { |
| 203 | sh """ |
| 204 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 205 | cd /home/cord/cord-tester/src/test/cord-api/Properties/ |
| 206 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.node1.ip}\'/\" RestApiProperties.py |
| 207 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py |
| 208 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 209 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 210 | cd /home/cord/cord-tester/src/test/cord-api/Tests/ |
| 211 | rm -rf Log/ || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 212 | pybot -d Log -T FabricConfig.txt || true |
| 213 | pybot -d Log -T RealOLT_Test.txt || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 214 | sleep 120 |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 215 | pybot -d Log -T Subscriber_TopDown.txt || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 216 | """ |
| 217 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 218 | } |
| 219 | } |
| 220 | stage('Publish') { |
| 221 | try { |
| 222 | sh """ |
| 223 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 224 | mkdir RobotLogs/TestDoc || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 225 | cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
Suchitra Vemuri | d9cffa8 | 2018-07-25 14:06:47 -0700 | [diff] [blame] | 226 | cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true |
| 227 | """ |
| 228 | step([$class: 'RobotPublisher', |
| 229 | disableArchiveOutput: false, |
| 230 | logFileName: 'RobotLogs/log*.html', |
| 231 | otherFiles: '', |
| 232 | outputFileName: 'RobotLogs/output*.xml', |
| 233 | outputPath: '.', |
| 234 | passThreshold: 100, |
| 235 | reportFileName: 'RobotLogs/report*.html', |
| 236 | unstableThreshold: 0]) |
| 237 | } catch(error) {} |
| 238 | } |
| 239 | //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 240 | } |
| 241 | } |