blob: d6b1b6c3bcebeb6118c4c74a63276ecc418baa4b [file] [log] [blame]
Luca Prete45401c82019-01-15 15:31:22 -08001// 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
15node ("${TestNodeName}") {
16 timeout (100) {
17 try {
18 stage ("Parse deployment configuration file") {
Matteo Scandolo9f8056b2019-01-17 10:33:51 -080019 sh returnStdout: true, script: "rm -rf helm-charts helm-repo-tools ${configBaseDir}"
Luca Prete45401c82019-01-15 15:31:22 -080020 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
Wei-Yu Chen992665b2019-01-17 10:21:32 -080021 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-charts"
Luca Prete45401c82019-01-15 15:31:22 -080022 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
23 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
24 }
25 stage('Clean up') {
26 timeout(10) {
27 sh returnStdout: true, script: """
28 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
29 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
30 do
31 echo "Purging chart: \${hchart}"
32 helm delete --purge "\${hchart}"
33 done
34 """
35 timeout(5) {
36 waitUntil {
37 helm_deleted = sh returnStdout: true, script: """
38 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
39 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
40 """
41 return helm_deleted.toInteger() == 0
42 }
43 }
Wei-Yu Chen9de5f162019-01-17 10:40:38 -080044 timeout(5) {
Luca Prete45401c82019-01-15 15:31:22 -080045 waitUntil {
46 kubectl_deleted = sh returnStdout: true, script: """
47 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
48 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
49 """
50 return kubectl_deleted.toInteger() == 0
51 }
52 }
53 }
54 }
Luca Prete62a48c82019-01-16 10:40:01 -080055 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080056 sh returnStdout: true, script: """
57 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080058 helm init --upgrade --force-upgrade
Luca Prete45401c82019-01-15 15:31:22 -080059 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080060 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080061 helm repo update
62 """
63 timeout(1) {
64 waitUntil {
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080065 tillerpod_running = sh returnStdout: true, script: """
66 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
67 kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l
68 """
69 return tillerpod_running.toInteger() == 1
70 }
71 }
72 timeout(1) {
73 waitUntil {
Luca Prete45401c82019-01-15 15:31:22 -080074 cord_repo_present = sh returnStdout: true, script: """
75 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
76 helm repo list | grep cord | wc -l
77 """
78 return cord_repo_present.toInteger() == 1
79 }
80 }
81 }
Matteo Scandolo08aea472019-01-23 11:45:37 -080082
83 stage('Install etcd-cluster') {
84 timeout(10) {
85 sh returnStdout: true, script: """
86 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
87 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.3 -n etcd-operator stable/etcd-operator
88 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcdNodePort=32379 cord/etcd-cluster
89 """
90 }
91 timeout(10) {
92 waitUntil {
93 etcd_running = sh returnStdout: true, script: """
94 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
95 kubectl get pods | grep etcd | grep -i running | grep 1/1 | wc -l
96 """
97 return etcd_running.toInteger() == 6
98 }
99 }
100 }
101
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800102 stage("Install M-CORD Control Plane Services") {
103 sh returnStdout: true, script: """
104 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen7f8c4dd2019-01-17 15:32:03 -0800105 helm install -n mcord-control-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800106 """
Luca Prete45401c82019-01-15 15:31:22 -0800107 }
Wei-Yu Chen037762d2019-01-24 11:12:39 -0800108
109 stage('Check M-CORD Control Plane available') {
110 timeout(20) {
111 control_plane = sh returnStdout: true, script: """
112 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
113 kubectl -n epc get pods | grep Running | grep 1/1 | wc -l
114 """
115 // We have 4 pods: cassandra, hss, mme and ngic-cp
116 return control_plane.toInteger() == 4
117 }
Luca Prete45401c82019-01-15 15:31:22 -0800118 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800119
120 // stage('Install CORD Kafka') {
121 // timeout(10) {
122 // sh returnStdout: true, script: """
123 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
124 // helm install --version 0.8.8 --set configurationOverrides."offsets\\.topic\\.replication\\.factor"=1 --set configurationOverrides."log\\.retention\\.hours"=4 --set configurationOverrides."log\\.message\\.timestamp\\.type"="LogAppendTime" --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false -n cord-kafka incubator/kafka
125 // """
126 // }
127 // timeout(10) {
128 // waitUntil {
129 // kafka_instances_running = sh returnStdout: true, script: """
130 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
131 // kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
132 // """
133 // return kafka_instances_running.toInteger() == 2
134 // }
135 // }
136 // }
137 // stage('Install Logging Infrastructure') {
138 // timeout(10) {
139 // sh returnStdout: true, script: """
140 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
141 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set elasticsearch.cluster.env.MINIMUM_MASTER_NODES="1" --set elasticsearch.client.replicas=1 --set elasticsearch.master.replicas=2 --set elasticsearch.master.persistence.enabled=false --set elasticsearch.data.replicas=1 --set elasticsearch.data.persistence.enabled=false -n logging cord/logging
142 // helm-repo-tools/wait_for_pods.sh
143 // """
144 // }
145 // }
146 // stage('Install Monitoring Infrastructure') {
147 // timeout(10) {
148 // sh returnStdout: true, script: """
149 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
150 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
151 // helm-repo-tools/wait_for_pods.sh
152 // """
153 // }
154 // }
155 // stage('Install ONOS') {
156 // timeout(10) {
157 // sh returnStdout: true, script: """
158 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
159 // helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
160 // """
161 // }
162 // timeout(10) {
163 // waitUntil {
164 // onos_completed = sh returnStdout: true, script: """
165 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
166 // kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
167 // """
168 // return onos_completed.toInteger() == 1
169 // }
170 // }
171 // }
172 // stage('Install xos-core') {
173 // timeout(10) {
174 // sh returnStdout: true, script: """
175 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
176 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
177 // """
178 // }
179 // timeout(10) {
180 // waitUntil {
181 // xos_core_completed = sh returnStdout: true, script: """
182 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
183 // kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
184 // """
185 // return xos_core_completed.toInteger() == 6
186 // }
187 // }
188 // }
Luca Prete45401c82019-01-15 15:31:22 -0800189
190 if ( params.configurePod ) {
191 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
192 stage('Configure R-CORD - Fabric and whitelist') {
193 timeout(1) {
194 waitUntil {
195 out_fabric = sh returnStdout: true, script: """
196 curl -s -H "xos-username:admin@opencord.org" -H "xos-password:letmein" -X POST --data-binary @${configFileName}-fabric.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
197 """
198 return out_fabric.toInteger() == 1
199 }
200 }
201 }
202 stage('Configure R-CORD - Subscriber') {
203 timeout(1) {
204 waitUntil {
205 out_subscriber = sh returnStdout: true, script: """
206 curl -s -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-subscriber.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
207 """
208 return out_subscriber.toInteger() == 1
209 }
210 }
211 }
212 stage('Configure R-CORD - OLT') {
213 timeout(1) {
214 waitUntil {
215 out_olt = sh returnStdout: true, script: """
216 curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-olt.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
217 """
218 return out_olt.toInteger() == 1
219 }
220 }
221 }
222 }
223 }
224 currentBuild.result = 'SUCCESS'
225 } catch (err) {
226 currentBuild.result = 'FAILURE'
227 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
228 }
229 echo "RESULT: ${currentBuild.result}"
230 }
231}