Suchitra Vemuri | 5d95aa9 | 2018-07-24 17:22:16 -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} |
| 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('Install Kafka') { |
| 70 | timeout(10) { |
| 71 | try { |
| 72 | sh """ |
| 73 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 74 | cd /home/cord/helm-charts |
| 75 | helm install --name cord-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.servers=1 --set zookeeper.persistence.enabled=false incubator/kafka |
| 76 | helm install --name voltha-kafka --set replicas=1 --set persistence.enabled=false --set zookeeper.servers=1 --set zookeeper.persistence.enabled=false incubator/kafka |
| 77 | Sleep 120 |
| 78 | """ |
| 79 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 80 | } |
| 81 | } |
| 82 | stage('Install xos-core and rcord-lite') { |
| 83 | timeout(10) { |
| 84 | try { |
| 85 | sh """ |
| 86 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 87 | cd /home/cord/helm-charts |
| 88 | helm dep update xos-core |
| 89 | helm install -n xos-core xos-core |
| 90 | helm dep update xos-profiles/rcord-lite |
| 91 | helm install -n rcord-lite xos-profiles/rcord-lite |
| 92 | """ |
| 93 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 94 | } |
| 95 | } |
| 96 | stage('Install voltha') { |
| 97 | timeout(10) { |
| 98 | try { |
| 99 | sh """ |
| 100 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 101 | cd /home/cord/helm-charts |
| 102 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 103 | helm dep build voltha |
| 104 | helm install -n voltha --set etcd-operator.customResources.createEtcdClusterCRD=false voltha |
| 105 | helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha |
| 106 | """ |
| 107 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 108 | } |
| 109 | } |
| 110 | stage('Install ONOS-Voltha and ONOS-Fabric') { |
| 111 | timeout(10) { |
| 112 | try { |
| 113 | sh """ |
| 114 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 115 | cd /home/cord/helm-charts |
| 116 | helm install -n onos-fabric -f configs/onos-fabric.yaml onos |
| 117 | helm install -n onos-voltha -f configs/onos-voltha.yaml onos |
| 118 | sleep 60 |
| 119 | """ |
| 120 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 121 | } |
| 122 | } |
| 123 | stage('Wait for PODs to complete') { |
| 124 | timeout(5) { |
| 125 | waitUntil { |
| 126 | try { |
| 127 | sh """ |
| 128 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 129 | kubectl get pods | grep -i tosca-loader | grep -i complete |
| 130 | kubectl get pods | grep -i chameleon | grep -i running |
| 131 | kubectl get pods | grep -i onos-fabric | grep -i running |
| 132 | kubectl get pods --namespace=voltha | grep -i voltha- | grep -i running |
| 133 | kubectl get pods --namespace=voltha | grep -i onos-voltha | grep -i running |
| 134 | """ |
| 135 | return true |
| 136 | } catch (exception) { |
| 137 | return false |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | stage('Restart OLT processes') { |
| 143 | timeout(5) { |
| 144 | try { |
| 145 | sh """ |
| 146 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 147 | sshpass -p onl ssh -l root 10.192.4.218 'pkill bal_core_dist' |
| 148 | sshpass -p onl ssh -l root 10.192.4.218 'pkill openolt' |
| 149 | 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 &' |
| 150 | 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 &' |
| 151 | sleep 180 |
| 152 | """ |
| 153 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 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 |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 174 | pybot -d Log -T SanityK8POD.robot || true |
Suchitra Vemuri | 5d95aa9 | 2018-07-24 17:22:16 -0700 | [diff] [blame] | 175 | """ |
| 176 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 177 | } |
| 178 | } |
| 179 | stage('Configurations and Tests') { |
| 180 | timeout(10) { |
| 181 | try { |
| 182 | sh """ |
| 183 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 184 | cd /home/cord/cord-tester/src/test/cord-api/Properties/ |
| 185 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.node1.ip}\'/\" RestApiProperties.py |
| 186 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py |
| 187 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 188 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 189 | cd /home/cord/cord-tester/src/test/cord-api/Tests/ |
| 190 | rm -rf Log/ || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 191 | pybot -d Log -T FabricConfig.txt || true |
| 192 | pybot -d Log -T HippieOSS.txt || true |
| 193 | pybot -d Log -T OSSVolt.txt || true |
| 194 | pybot -d Log -T RealOLT_Test.txt || true |
Suchitra Vemuri | 5d95aa9 | 2018-07-24 17:22:16 -0700 | [diff] [blame] | 195 | """ |
| 196 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 197 | } |
| 198 | } |
| 199 | stage('Publish') { |
| 200 | try { |
| 201 | sh """ |
| 202 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 203 | mkdir RobotLogs/TestDoc || true |
Kailash Khalasi | e9ad83c | 2018-08-07 11:22:36 -0700 | [diff] [blame] | 204 | cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
Suchitra Vemuri | 5d95aa9 | 2018-07-24 17:22:16 -0700 | [diff] [blame] | 205 | cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true |
| 206 | """ |
| 207 | step([$class: 'RobotPublisher', |
| 208 | disableArchiveOutput: false, |
| 209 | logFileName: 'RobotLogs/log*.html', |
| 210 | otherFiles: '', |
| 211 | outputFileName: 'RobotLogs/output*.xml', |
| 212 | outputPath: '.', |
| 213 | passThreshold: 100, |
| 214 | reportFileName: 'RobotLogs/report*.html', |
| 215 | unstableThreshold: 0]) |
| 216 | } catch(error) {} |
| 217 | } |
| 218 | //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 219 | } |
| 220 | } |