blob: efa5fd5fdab6cce9c378f4ab5ac34043433c57ea [file] [log] [blame]
Suchitra Vemuric365ebe2018-06-01 00:04:16 -07001// 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
Zack Williams5ce76d42020-02-28 15:45:56 -070015node ("${buildNode}") {
Suchitra Vemuric365ebe2018-06-01 00:04:16 -070016 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 Vemuric365ebe2018-06-01 00:04:16 -070021 }
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -070022
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 Vemuric365ebe2018-06-01 00:04:16 -070035 }
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -070036 stage('Clean up') {
37 timeout(10) {
Kailash Khalasic1a90f12018-09-13 13:13:22 -070038 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 Vemuri2c1896a2018-06-04 23:43:16 -070067 }
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 Vemuri9c4ffec2018-06-08 17:27:47 -0700105 sleep 60
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700106 """
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 Wang0a382072018-09-28 13:29:26 -0700116 git clone -b ${branch} https://gerrit.opencord.org/cord-tester
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700117 """
118 } catch(error) { currentBuild.result = 'FAILURE' }
119 }
120 }
Suchitra Vemuri9c4ffec2018-06-08 17:27:47 -0700121 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
Kailashd38b7cd2018-12-06 14:05:41 -0800128 robot -d Log -T -l log-SanityK8POD SanityK8POD.robot || true
Suchitra Vemuri9c4ffec2018-06-08 17:27:47 -0700129 """
130 } catch(error) { currentBuild.result = 'FAILURE' }
131 }
132 }
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700133 stage('Verify E2E XOS') {
134 timeout(10) {
135 try {
136 sh """
137 export KUBECONFIG=/home/cord/${deployment_config.pod_config}
Suchitra Vemuri94760d12018-06-11 15:03:56 -0700138 chameleon=\$(kubectl get pods | grep chameleon | cut -d' ' -f1)
139 echo \$chameleon
140 kubectl delete pod \$chameleon
141 sleep 120
Suchitra Vemuri9c4ffec2018-06-08 17:27:47 -0700142 kubectl get pods
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700143 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
Kailashd38b7cd2018-12-06 14:05:41 -0800150 robot -d Log -T -l log-VOLTDevice_Test VOLTDevice_Test.txt || true
151 robot -d Log -T -l log-RCORDLite_E2ETest RCORDLite_E2ETest.txt || true
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700152 """
153 } catch(error) { currentBuild.result = 'FAILURE' }
154 }
155 }
156 stage('Publish') {
Suchitra Vemuric365ebe2018-06-01 00:04:16 -0700157 try {
158 sh """
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700159 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs;
160 mkdir RobotLogs/TestDoc || true
Suchitra Vemuri9c4ffec2018-06-08 17:27:47 -0700161 cp -r /home/cord/cord-tester/src/test/robot/Log/* ./RobotLogs || true
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700162 cp -r /home/cord/cord-tester/src/test/cord-api/Tests/Log/* ./RobotLogs || true
Suchitra Vemuric365ebe2018-06-01 00:04:16 -0700163 """
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700164 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 Vemuric365ebe2018-06-01 00:04:16 -0700174 }
Suchitra Vemuri2c1896a2018-06-04 23:43:16 -0700175 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
Suchitra Vemuric365ebe2018-06-01 00:04:16 -0700176 }
Suchitra Vemuric365ebe2018-06-01 00:04:16 -0700177}