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 | 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} |
Suchitra Vemuri | 22caabd | 2018-08-07 14:55:10 -0700 | [diff] [blame] | 58 | ! helm ls | grep -E 'onos-voltha|onos-fabric|voltha |rcord-lite|xos-core|cord-kafka|voltha-kafka' |
Suchitra Vemuri | f126e7e | 2018-08-01 11:31:11 -0700 | [diff] [blame] | 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 |
Suchitra Vemuri | 22caabd | 2018-08-07 14:55:10 -0700 | [diff] [blame] | 106 | helm install -n hippie-oss xos-services/hippie-oss |
Suchitra Vemuri | f126e7e | 2018-08-01 11:31:11 -0700 | [diff] [blame] | 107 | """ |
| 108 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 109 | } |
| 110 | } |
| 111 | stage('Install voltha') { |
| 112 | timeout(10) { |
| 113 | try { |
| 114 | sh """ |
| 115 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 116 | cd /home/cord/helm-charts |
| 117 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 118 | helm dep build voltha |
| 119 | helm install -n voltha --set etcd-operator.customResources.createEtcdClusterCRD=false voltha |
| 120 | helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha |
| 121 | """ |
| 122 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 123 | } |
| 124 | } |
| 125 | stage('Install ONOS-Voltha and ONOS-Fabric') { |
| 126 | timeout(10) { |
| 127 | try { |
| 128 | sh """ |
| 129 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 130 | cd /home/cord/helm-charts |
| 131 | helm install -n onos-fabric -f configs/onos-fabric.yaml onos |
| 132 | helm install -n onos-voltha -f configs/onos-voltha.yaml onos |
| 133 | sleep 60 |
| 134 | """ |
| 135 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 136 | } |
| 137 | } |
| 138 | stage('Wait for PODs to complete') { |
| 139 | timeout(5) { |
| 140 | waitUntil { |
| 141 | try { |
| 142 | sh """ |
| 143 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 144 | kubectl get pods | grep -i tosca-loader | grep -i complete |
| 145 | kubectl get pods | grep -i chameleon | grep -i running |
| 146 | kubectl get pods | grep -i onos-fabric | grep -i running |
| 147 | kubectl get pods --namespace=voltha | grep -i voltha- | grep -i running |
| 148 | kubectl get pods --namespace=voltha | grep -i onos-voltha | grep -i running |
| 149 | """ |
| 150 | return true |
| 151 | } catch (exception) { |
| 152 | return false |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | stage('Download cord-tester repo') { |
| 158 | timeout(10) { |
| 159 | try { |
| 160 | sh """ |
| 161 | rm -rf /home/cord/cord-tester |
| 162 | cd /home/cord/ |
| 163 | git clone -b ${branch} https://gerrit.opencord.org/cord-tester |
| 164 | """ |
| 165 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 166 | } |
| 167 | } |
| 168 | stage('Validate installed PODs') { |
| 169 | timeout(10) { |
| 170 | try { |
| 171 | sh """ |
| 172 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 173 | cd /home/cord/cord-tester/src/test/robot/ |
| 174 | rm -rf Log/ || true |
Suchitra Vemuri | 22caabd | 2018-08-07 14:55:10 -0700 | [diff] [blame] | 175 | pybot -d Log -T SanityK8POD.robot || true |
Suchitra Vemuri | f126e7e | 2018-08-01 11:31:11 -0700 | [diff] [blame] | 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 |
Suchitra Vemuri | 22caabd | 2018-08-07 14:55:10 -0700 | [diff] [blame] | 192 | pybot -d Log -T FabricConfig.txt || true |
| 193 | pybot -d Log -T HippieOSS.txt || true |
| 194 | pybot -d Log -T OSSVolt.txt || true |
| 195 | pybot -d Log -T RealOLT_Test.txt || true |
Suchitra Vemuri | f126e7e | 2018-08-01 11:31:11 -0700 | [diff] [blame] | 196 | """ |
| 197 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 198 | } |
| 199 | } |
| 200 | stage('Publish') { |
| 201 | try { |
| 202 | sh """ |
| 203 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 204 | mkdir RobotLogs/TestDoc || true |
Suchitra Vemuri | 22caabd | 2018-08-07 14:55:10 -0700 | [diff] [blame] | 205 | cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
Suchitra Vemuri | f126e7e | 2018-08-01 11:31:11 -0700 | [diff] [blame] | 206 | cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true |
| 207 | """ |
| 208 | step([$class: 'RobotPublisher', |
| 209 | disableArchiveOutput: false, |
| 210 | logFileName: 'RobotLogs/log*.html', |
| 211 | otherFiles: '', |
| 212 | outputFileName: 'RobotLogs/output*.xml', |
| 213 | outputPath: '.', |
| 214 | passThreshold: 100, |
| 215 | reportFileName: 'RobotLogs/report*.html', |
| 216 | unstableThreshold: 0]) |
| 217 | } catch(error) {} |
| 218 | } |
| 219 | //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 220 | } |
| 221 | } |