blob: ebe85d57516e9cf879e6d469f9fc255a2d887f65 [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") {
19 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir}"
20 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 }
44 timeout(5) {
45 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 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080054 timout(5) {
55 dir ("helm-charts") {
56 stage("Cleanup SR-IOV CNI and SR-IOV Network Device Plugin") {
57 sh returnStdout: true, script: """
58 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
59 kubectl delete -f mcord/cni-config/
60 """
61 }
62 }
63 }
Luca Prete45401c82019-01-15 15:31:22 -080064 }
Luca Prete62a48c82019-01-16 10:40:01 -080065 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080066 sh returnStdout: true, script: """
67 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
68 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080069 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080070 helm repo update
71 """
72 timeout(1) {
73 waitUntil {
74 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 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080082 dir ("helm-charts") {
83 stage('Install SR-IOV CNI and SR-IOV Network Device Plugin') {
Luca Prete45401c82019-01-15 15:31:22 -080084 sh returnStdout: true, script: """
85 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen992665b2019-01-17 10:21:32 -080086 kubectl apply -f mcord/cni-config/02-network-crd.yaml
87 kubectl apply -f mcord/cni-config/
Luca Prete45401c82019-01-15 15:31:22 -080088 """
89 }
90 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080091
92 stage("Install M-CORD Control Plane Services") {
93 sh returnStdout: true, script: """
94 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
95 helm install -n mcord-control-plane -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane
96 """
Luca Prete45401c82019-01-15 15:31:22 -080097 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080098
99 stage("Install M-CORD Data Plane Services") {
100 sh returnStdout: true, script: """
101 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
102 helm install -n mcord-data-plane -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-data-plane
103 """
Luca Prete45401c82019-01-15 15:31:22 -0800104 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800105
106 // stage('Install CORD Kafka') {
107 // timeout(10) {
108 // sh returnStdout: true, script: """
109 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
110 // 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
111 // """
112 // }
113 // timeout(10) {
114 // waitUntil {
115 // kafka_instances_running = sh returnStdout: true, script: """
116 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
117 // kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
118 // """
119 // return kafka_instances_running.toInteger() == 2
120 // }
121 // }
122 // }
123 // stage('Install Logging Infrastructure') {
124 // timeout(10) {
125 // sh returnStdout: true, script: """
126 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
127 // 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
128 // helm-repo-tools/wait_for_pods.sh
129 // """
130 // }
131 // }
132 // stage('Install Monitoring Infrastructure') {
133 // timeout(10) {
134 // sh returnStdout: true, script: """
135 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
136 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
137 // helm-repo-tools/wait_for_pods.sh
138 // """
139 // }
140 // }
141 // stage('Install ONOS') {
142 // timeout(10) {
143 // sh returnStdout: true, script: """
144 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
145 // helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
146 // """
147 // }
148 // timeout(10) {
149 // waitUntil {
150 // onos_completed = sh returnStdout: true, script: """
151 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
152 // kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
153 // """
154 // return onos_completed.toInteger() == 1
155 // }
156 // }
157 // }
158 // stage('Install xos-core') {
159 // timeout(10) {
160 // sh returnStdout: true, script: """
161 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
162 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
163 // """
164 // }
165 // timeout(10) {
166 // waitUntil {
167 // xos_core_completed = sh returnStdout: true, script: """
168 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
169 // kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
170 // """
171 // return xos_core_completed.toInteger() == 6
172 // }
173 // }
174 // }
Luca Prete45401c82019-01-15 15:31:22 -0800175
176 if ( params.configurePod ) {
177 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
178 stage('Configure R-CORD - Fabric and whitelist') {
179 timeout(1) {
180 waitUntil {
181 out_fabric = sh returnStdout: true, script: """
182 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
183 """
184 return out_fabric.toInteger() == 1
185 }
186 }
187 }
188 stage('Configure R-CORD - Subscriber') {
189 timeout(1) {
190 waitUntil {
191 out_subscriber = sh returnStdout: true, script: """
192 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
193 """
194 return out_subscriber.toInteger() == 1
195 }
196 }
197 }
198 stage('Configure R-CORD - OLT') {
199 timeout(1) {
200 waitUntil {
201 out_olt = sh returnStdout: true, script: """
202 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
203 """
204 return out_olt.toInteger() == 1
205 }
206 }
207 }
208 }
209 }
210 currentBuild.result = 'SUCCESS'
211 } catch (err) {
212 currentBuild.result = 'FAILURE'
213 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
214 }
215 echo "RESULT: ${currentBuild.result}"
216 }
217}