blob: bd27d8f9def7df5a44279f4b63937d0ddbf8d393 [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) {
Wei-Yu Chen213821c2019-01-17 10:21:32 -080045 dir ("helm-charts") {
46 stage("Cleanup SR-IOV CNI and SR-IOV Network Device Plugin") {
47 sh returnStdout: true, script: """
48 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chenfa2aa092019-01-17 10:46:36 -080049 kubectl delete -f mcord/cni-config/05-sriov-device-plugin.yaml
50 kubectl delete -f mcord/cni-config/04-sriov-device-plugin-configmap.yaml
51 kubectl delete -f mcord/cni-config/03-network-definition.yaml
52 kubectl delete -f mcord/cni-config/02-network-crd.yaml
53 kubectl delete -f mcord/cni-config/01-cni-service-account.yaml
Wei-Yu Chen213821c2019-01-17 10:21:32 -080054 """
55 }
56 }
57 }
Luca Prete45401c82019-01-15 15:31:22 -080058 timeout(5) {
59 waitUntil {
60 kubectl_deleted = sh returnStdout: true, script: """
61 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
62 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
63 """
64 return kubectl_deleted.toInteger() == 0
65 }
66 }
67 }
68 }
Luca Prete62a48c82019-01-16 10:40:01 -080069 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080070 sh returnStdout: true, script: """
71 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
72 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080073 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080074 helm repo update
75 """
76 timeout(1) {
77 waitUntil {
78 cord_repo_present = sh returnStdout: true, script: """
79 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
80 helm repo list | grep cord | wc -l
81 """
82 return cord_repo_present.toInteger() == 1
83 }
84 }
85 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080086 dir ("helm-charts") {
87 stage('Install SR-IOV CNI and SR-IOV Network Device Plugin') {
Luca Prete45401c82019-01-15 15:31:22 -080088 sh returnStdout: true, script: """
89 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen992665b2019-01-17 10:21:32 -080090 kubectl apply -f mcord/cni-config/02-network-crd.yaml
91 kubectl apply -f mcord/cni-config/
Luca Prete45401c82019-01-15 15:31:22 -080092 """
93 }
94 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080095
96 stage("Install M-CORD Control Plane Services") {
97 sh returnStdout: true, script: """
98 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete82b1a852019-01-17 12:07:14 -080099 helm install -n mcord-control-plane -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800100 """
Luca Prete45401c82019-01-15 15:31:22 -0800101 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800102
103 stage("Install M-CORD Data Plane Services") {
104 sh returnStdout: true, script: """
105 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
106 helm install -n mcord-data-plane -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-data-plane
107 """
Luca Prete45401c82019-01-15 15:31:22 -0800108 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800109
110 // stage('Install CORD Kafka') {
111 // timeout(10) {
112 // sh returnStdout: true, script: """
113 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
114 // 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
115 // """
116 // }
117 // timeout(10) {
118 // waitUntil {
119 // kafka_instances_running = sh returnStdout: true, script: """
120 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
121 // kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
122 // """
123 // return kafka_instances_running.toInteger() == 2
124 // }
125 // }
126 // }
127 // stage('Install Logging Infrastructure') {
128 // timeout(10) {
129 // sh returnStdout: true, script: """
130 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
131 // 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
132 // helm-repo-tools/wait_for_pods.sh
133 // """
134 // }
135 // }
136 // stage('Install Monitoring Infrastructure') {
137 // timeout(10) {
138 // sh returnStdout: true, script: """
139 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
140 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
141 // helm-repo-tools/wait_for_pods.sh
142 // """
143 // }
144 // }
145 // stage('Install ONOS') {
146 // timeout(10) {
147 // sh returnStdout: true, script: """
148 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
149 // helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
150 // """
151 // }
152 // timeout(10) {
153 // waitUntil {
154 // onos_completed = sh returnStdout: true, script: """
155 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
156 // kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
157 // """
158 // return onos_completed.toInteger() == 1
159 // }
160 // }
161 // }
162 // stage('Install xos-core') {
163 // timeout(10) {
164 // sh returnStdout: true, script: """
165 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
166 // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
167 // """
168 // }
169 // timeout(10) {
170 // waitUntil {
171 // xos_core_completed = sh returnStdout: true, script: """
172 // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
173 // kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
174 // """
175 // return xos_core_completed.toInteger() == 6
176 // }
177 // }
178 // }
Luca Prete45401c82019-01-15 15:31:22 -0800179
180 if ( params.configurePod ) {
181 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
182 stage('Configure R-CORD - Fabric and whitelist') {
183 timeout(1) {
184 waitUntil {
185 out_fabric = sh returnStdout: true, script: """
186 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
187 """
188 return out_fabric.toInteger() == 1
189 }
190 }
191 }
192 stage('Configure R-CORD - Subscriber') {
193 timeout(1) {
194 waitUntil {
195 out_subscriber = sh returnStdout: true, script: """
196 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
197 """
198 return out_subscriber.toInteger() == 1
199 }
200 }
201 }
202 stage('Configure R-CORD - OLT') {
203 timeout(1) {
204 waitUntil {
205 out_olt = sh returnStdout: true, script: """
206 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
207 """
208 return out_olt.toInteger() == 1
209 }
210 }
211 }
212 }
213 }
214 currentBuild.result = 'SUCCESS'
215 } catch (err) {
216 currentBuild.result = 'FAILURE'
217 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
218 }
219 echo "RESULT: ${currentBuild.result}"
220 }
221}