blob: 4ba6a036285556005e351fd1883146fd28dade37 [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"
21 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
22 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
23 }
24 stage('Clean up') {
25 timeout(10) {
26 sh returnStdout: true, script: """
27 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
28 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
29 do
30 echo "Purging chart: \${hchart}"
31 helm delete --purge "\${hchart}"
32 done
33 """
34 timeout(5) {
35 waitUntil {
36 helm_deleted = sh returnStdout: true, script: """
37 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
38 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
39 """
40 return helm_deleted.toInteger() == 0
41 }
42 }
43 timeout(5) {
44 waitUntil {
45 kubectl_deleted = sh returnStdout: true, script: """
46 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
47 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
48 """
49 return kubectl_deleted.toInteger() == 0
50 }
51 }
52 }
53 }
Luca Prete62a48c82019-01-16 10:40:01 -080054 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080055 sh returnStdout: true, script: """
56 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
57 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080058 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080059 helm repo update
60 """
61 timeout(1) {
62 waitUntil {
63 cord_repo_present = sh returnStdout: true, script: """
64 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
65 helm repo list | grep cord | wc -l
66 """
67 return cord_repo_present.toInteger() == 1
68 }
69 }
70 }
71 stage('Install CORD Kafka') {
72 timeout(10) {
73 sh returnStdout: true, script: """
74 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
75 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
76 """
77 }
78 timeout(10) {
79 waitUntil {
80 kafka_instances_running = sh returnStdout: true, script: """
81 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
82 kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
83 """
84 return kafka_instances_running.toInteger() == 2
85 }
86 }
87 }
88 stage('Install Logging Infrastructure') {
89 timeout(10) {
90 sh returnStdout: true, script: """
91 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
92 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
93 helm-repo-tools/wait_for_pods.sh
94 """
95 }
96 }
97 stage('Install Monitoring Infrastructure') {
98 timeout(10) {
99 sh returnStdout: true, script: """
100 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
101 helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
102 helm-repo-tools/wait_for_pods.sh
103 """
104 }
105 }
106 stage('Install ONOS') {
107 timeout(10) {
108 sh returnStdout: true, script: """
109 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
110 helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
111 """
112 }
113 timeout(10) {
114 waitUntil {
115 onos_completed = sh returnStdout: true, script: """
116 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
117 kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
118 """
119 return onos_completed.toInteger() == 1
120 }
121 }
122 }
123 stage('Install xos-core') {
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 -n xos-core cord/xos-core
128 """
129 }
130 timeout(10) {
131 waitUntil {
132 xos_core_completed = sh returnStdout: true, script: """
133 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
134 kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
135 """
136 return xos_core_completed.toInteger() == 6
137 }
138 }
139 }
140
141 if ( params.configurePod ) {
142 dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
143 stage('Configure R-CORD - Fabric and whitelist') {
144 timeout(1) {
145 waitUntil {
146 out_fabric = sh returnStdout: true, script: """
147 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
148 """
149 return out_fabric.toInteger() == 1
150 }
151 }
152 }
153 stage('Configure R-CORD - Subscriber') {
154 timeout(1) {
155 waitUntil {
156 out_subscriber = sh returnStdout: true, script: """
157 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
158 """
159 return out_subscriber.toInteger() == 1
160 }
161 }
162 }
163 stage('Configure R-CORD - OLT') {
164 timeout(1) {
165 waitUntil {
166 out_olt = sh returnStdout: true, script: """
167 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
168 """
169 return out_olt.toInteger() == 1
170 }
171 }
172 }
173 }
174 }
175 currentBuild.result = 'SUCCESS'
176 } catch (err) {
177 currentBuild.result = 'FAILURE'
178 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
179 }
180 echo "RESULT: ${currentBuild.result}"
181 }
182}