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