Suchitra Vemuri | c365ebe | 2018-06-01 00:04: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 | |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 15 | node ("${TestNodeName}") { |
| 16 | timeout (time: 240) { |
| 17 | stage ("Parse deployment configuration file") { |
| 18 | sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}' |
| 19 | sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}' |
| 20 | deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}" |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 21 | } |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 22 | |
| 23 | stage('Export pod config') { |
| 24 | timeout(10) { |
| 25 | try { |
| 26 | sh """ |
| 27 | cd /home/cord |
| 28 | rm -rf /home/cord/helm-charts |
| 29 | git clone -b ${branch} https://gerrit.opencord.org/helm-charts |
| 30 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 31 | kubectl get pods |
| 32 | """ |
| 33 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 34 | } |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 35 | } |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 36 | stage('Clean up') { |
| 37 | timeout(10) { |
Kailash Khalasi | c1a90f1 | 2018-09-13 13:13:22 -0700 | [diff] [blame] | 38 | sh returnStdout: true, script: """ |
| 39 | rm -rf helm-charts cord-tester |
| 40 | git clone -b ${branch} ${cordRepoUrl}/helm-charts |
| 41 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 42 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 43 | do |
| 44 | echo "Purging chart: \${hchart}" |
| 45 | helm delete --purge "\${hchart}" |
| 46 | done |
| 47 | """ |
| 48 | timeout(5) { |
| 49 | waitUntil { |
| 50 | helm_deleted = sh returnStdout: true, script: """ |
| 51 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 52 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 53 | """ |
| 54 | return helm_deleted.toInteger() == 0 |
| 55 | } |
| 56 | } |
| 57 | timeout(5) { |
| 58 | waitUntil { |
| 59 | kubectl_deleted = sh returnStdout: true, script: """ |
| 60 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 61 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 62 | """ |
| 63 | return kubectl_deleted.toInteger() == 0 |
| 64 | } |
| 65 | } |
| 66 | } |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 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/voltha |
| 88 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 89 | helm dep build |
| 90 | cd /home/cord/helm-charts |
| 91 | helm install -n voltha --set etcd-operator.customResources.createEtcdClusterCRD=false voltha |
| 92 | helm upgrade --set etcd-operator.customResources.createEtcdClusterCRD=true voltha ./voltha |
| 93 | """ |
| 94 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 95 | } |
| 96 | } |
| 97 | stage('Install ONOS-Voltha and ONOS-Fabric') { |
| 98 | timeout(10) { |
| 99 | try { |
| 100 | sh """ |
| 101 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
| 102 | cd /home/cord/helm-charts |
| 103 | helm install -n onos-fabric -f configs/onos-fabric.yaml onos |
| 104 | helm install -n onos-voltha -f configs/onos-voltha.yaml onos |
Suchitra Vemuri | 9c4ffec | 2018-06-08 17:27:47 -0700 | [diff] [blame] | 105 | sleep 60 |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 106 | """ |
| 107 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 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/ |
You Wang | 0a38207 | 2018-09-28 13:29:26 -0700 | [diff] [blame] | 116 | git clone -b ${branch} https://gerrit.opencord.org/cord-tester |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 117 | """ |
| 118 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 119 | } |
| 120 | } |
Suchitra Vemuri | 9c4ffec | 2018-06-08 17:27:47 -0700 | [diff] [blame] | 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 |
You Wang | 0a38207 | 2018-09-28 13:29:26 -0700 | [diff] [blame] | 128 | pybot -d Log -T -l log-SanityK8POD SanityK8POD.robot || true |
Suchitra Vemuri | 9c4ffec | 2018-06-08 17:27:47 -0700 | [diff] [blame] | 129 | """ |
| 130 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 131 | } |
| 132 | } |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 133 | stage('Verify E2E XOS') { |
| 134 | timeout(10) { |
| 135 | try { |
| 136 | sh """ |
| 137 | export KUBECONFIG=/home/cord/${deployment_config.pod_config} |
Suchitra Vemuri | 94760d1 | 2018-06-11 15:03:56 -0700 | [diff] [blame] | 138 | chameleon=\$(kubectl get pods | grep chameleon | cut -d' ' -f1) |
| 139 | echo \$chameleon |
| 140 | kubectl delete pod \$chameleon |
| 141 | sleep 120 |
Suchitra Vemuri | 9c4ffec | 2018-06-08 17:27:47 -0700 | [diff] [blame] | 142 | kubectl get pods |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 143 | cd /home/cord/cord-tester/src/test/cord-api/Properties/ |
| 144 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'${deployment_config.node1.ip}\'/\" RestApiProperties.py |
| 145 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'30006\'/\" RestApiProperties.py |
| 146 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 147 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 148 | cd /home/cord/cord-tester/src/test/cord-api/Tests |
| 149 | rm -rf Log/ || true |
You Wang | 0a38207 | 2018-09-28 13:29:26 -0700 | [diff] [blame] | 150 | pybot -d Log -T -l log-VOLTDevice_Test VOLTDevice_Test.txt || true |
| 151 | pybot -d Log -T -l log-RCORDLite_E2ETest RCORDLite_E2ETest.txt || true |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 152 | """ |
| 153 | } catch(error) { currentBuild.result = 'FAILURE' } |
| 154 | } |
| 155 | } |
| 156 | stage('Publish') { |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 157 | try { |
| 158 | sh """ |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 159 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs; |
| 160 | mkdir RobotLogs/TestDoc || true |
Suchitra Vemuri | 9c4ffec | 2018-06-08 17:27:47 -0700 | [diff] [blame] | 161 | cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 162 | cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 163 | """ |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 164 | step([$class: 'RobotPublisher', |
| 165 | disableArchiveOutput: false, |
| 166 | logFileName: 'RobotLogs/log*.html', |
| 167 | otherFiles: '', |
| 168 | outputFileName: 'RobotLogs/output*.xml', |
| 169 | outputPath: '.', |
| 170 | passThreshold: 100, |
| 171 | reportFileName: 'RobotLogs/report*.html', |
| 172 | unstableThreshold: 0]) |
| 173 | } catch(error) {} |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 174 | } |
Suchitra Vemuri | 2c1896a | 2018-06-04 23:43:16 -0700 | [diff] [blame] | 175 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 176 | } |
Suchitra Vemuri | c365ebe | 2018-06-01 00:04:16 -0700 | [diff] [blame] | 177 | } |