Suchitra Vemuri | ddb2779 | 2018-08-23 15:29:42 -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 | helm ls | grep cord-kafka && helm delete --purge cord-kafka || true |
| 49 | helm ls | grep voltha-kafka && helm delete --purge voltha-kafka || true |
| 50 | helm ls | grep att-workflow && helm delete --purge att-workflow || true |
| 51 | """ |
| 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} |
| 59 | ! helm ls | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite|xos-core|cord-kafka|voltha-kafka' |
| 60 | ! 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 | 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 | """ |
| 79 | } |
| 80 | timeout(15) { |
| 81 | waitUntil { |
| 82 | onu_discovered = sh returnStdout: true, script: "sshpass -p onl ssh -l root 10.192.4.218 'cat /broadcom/openolt.log | grep \"onu discover indication\" | wc -l'" |
| 83 | return onu_discovered.toInteger() > 0 |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | stage('Install Kafka') { |
| 90 | timeout(10) { |
| 91 | try { |
| 92 | sh """ |
| 93 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 94 | cd /home/cord/helm-charts |
| 95 | helm install --name cord-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.servers=1 --set zookeeper.persistence.enabled=false incubator/kafka |
| 96 | helm install --name voltha-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.servers=1 --set zookeeper.persistence.enabled=false incubator/kafka |
| 97 | """ |
| 98 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 99 | } |
| 100 | } |
| 101 | stage('Install xos-core') { |
| 102 | timeout(10) { |
| 103 | try { |
| 104 | sh """ |
| 105 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 106 | cd /home/cord/helm-charts |
| 107 | helm dep update xos-core |
| 108 | helm install -n xos-core xos-core |
| 109 | """ |
| 110 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 111 | } |
| 112 | } |
| 113 | stage('Install voltha') { |
| 114 | timeout(10) { |
| 115 | try { |
| 116 | sh """ |
| 117 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 118 | cd /home/cord/helm-charts |
| 119 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 120 | helm dep build voltha |
| 121 | helm install -n voltha --set etcd-operator.customResources.createEtcdClusterCRD=false voltha |
| 122 | helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha |
| 123 | """ |
| 124 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 125 | } |
| 126 | } |
| 127 | stage('Install ONOS-Voltha and ONOS-Fabric') { |
| 128 | timeout(10) { |
| 129 | try { |
| 130 | sh """ |
| 131 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 132 | cd /home/cord/helm-charts |
| 133 | helm install -n onos-fabric -f configs/onos-fabric.yaml onos |
| 134 | helm install -n onos-voltha -f configs/onos-voltha.yaml onos |
| 135 | """ |
| 136 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 137 | } |
| 138 | } |
| 139 | stage('Install ATT Workflow') { |
| 140 | timeout(10) { |
| 141 | try { |
| 142 | sh """ |
| 143 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 144 | cd /home/cord/helm-charts |
| 145 | helm install -n att-workflow xos-profiles/att-workflow |
| 146 | """ |
| 147 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 148 | } |
| 149 | } |
| 150 | stage('Wait for PODs to complete') { |
| 151 | timeout(5) { |
| 152 | waitUntil { |
| 153 | try { |
| 154 | sh """ |
| 155 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 156 | kubectl get pods | grep -i tosca-loader | grep -i complete |
| 157 | kubectl get pods | grep -i chameleon | grep -i running |
| 158 | kubectl get pods | grep -i onos-fabric | grep -i running |
| 159 | kubectl get pods | grep -i cord-kafka | grep -i running |
| 160 | kubectl get pods | grep -i voltha-kafka | grep -i running |
| 161 | kubectl get pods --namespace=voltha | grep -i voltha- | grep -i running |
| 162 | kubectl get pods --namespace=voltha | grep -i onos-voltha | grep -i running |
| 163 | """ |
| 164 | return true |
| 165 | } catch (exception) { |
| 166 | return false |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | stage('Download cord-tester repo') { |
| 172 | timeout(10) { |
| 173 | try { |
| 174 | sh """ |
| 175 | rm -rf /home/cord/cord-tester |
| 176 | cd /home/cord/ |
| 177 | git clone -b ${branch} https://gerrit.opencord.org/cord-tester |
| 178 | """ |
| 179 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 180 | } |
| 181 | } |
| 182 | stage('Validate installed PODs') { |
| 183 | timeout(10) { |
| 184 | try { |
| 185 | sh """ |
| 186 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 187 | cd /home/cord/cord-tester/src/test/robot/ |
| 188 | rm -rf Log/ || true |
| 189 | pybot -d Log -T SanityK8POD.robot || true |
| 190 | """ |
| 191 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 192 | } |
| 193 | } |
| 194 | /* stage('Configurations and Tests') { |
| 195 | timeout(10) { |
| 196 | try { |
| 197 | sh """ |
| 198 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 199 | cd /home/cord/cord-tester/src/test/cord-api/Properties/ |
| 200 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.node1.ip}\'/\" RestApiProperties.py |
| 201 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py |
| 202 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 203 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 204 | cd /home/cord/cord-tester/src/test/cord-api/Tests/ |
| 205 | rm -rf Log/ || true |
| 206 | pybot -d Log -T FabricConfig.txt || true |
| 207 | pybot -d Log -T AttWorkFlowDriver.txt || true |
| 208 | sleep 5 |
| 209 | pybot -d Log -T OSSVolt.txt || true |
| 210 | pybot -d Log -T RealOLT_Test.txt || true |
| 211 | """ |
| 212 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 213 | } |
| 214 | } |
| 215 | stage('Subscriber Validation and Ping Tests') { |
| 216 | timeout(20) { |
| 217 | try { |
| 218 | sh """ |
| 219 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 220 | cd /home/cord/cord-tester/src/test/cord-api/Tests/ |
| 221 | 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:FAIL -v MACIP_STATUS:PASS Subscriber_StatusChecks.txt || true |
| 222 | """ |
| 223 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 224 | } |
| 225 | } |
| 226 | stage('Publish') { |
| 227 | try { |
| 228 | sh """ |
| 229 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 230 | mkdir RobotLogs/TestDoc || true |
| 231 | cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
| 232 | cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true |
| 233 | """ |
| 234 | step([$class: 'RobotPublisher', |
| 235 | disableArchiveOutput: false, |
| 236 | logFileName: 'RobotLogs/log*.html', |
| 237 | otherFiles: '', |
| 238 | outputFileName: 'RobotLogs/output*.xml', |
| 239 | outputPath: '.', |
| 240 | passThreshold: 100, |
| 241 | reportFileName: 'RobotLogs/report*.html', |
| 242 | unstableThreshold: 0]) |
| 243 | } catch(error) {} |
| 244 | }*/ |
| 245 | //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 246 | } |
| 247 | } |