Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 1 | // 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 | |
| 15 | node ("${TestNodeName}") { |
| 16 | timeout (100) { |
| 17 | try { |
| 18 | stage ("Parse deployment configuration file") { |
Matteo Scandolo | 9f8056b | 2019-01-17 10:33:51 -0800 | [diff] [blame] | 19 | sh returnStdout: true, script: "rm -rf helm-charts helm-repo-tools ${configBaseDir}" |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools" |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 21 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-charts" |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 22 | 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 Chen | 9de5f16 | 2019-01-17 10:40:38 -0800 | [diff] [blame] | 44 | timeout(5) { |
Wei-Yu Chen | 213821c | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 45 | 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 Chen | fa2aa09 | 2019-01-17 10:46:36 -0800 | [diff] [blame] | 49 | 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 Chen | 213821c | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 54 | """ |
| 55 | } |
| 56 | } |
| 57 | } |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 58 | 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 Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 69 | stage('Add Helm repositories') { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 70 | sh returnStdout: true, script: """ |
| 71 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 76dd793 | 2019-01-18 14:14:23 -0800 | [diff] [blame] | 72 | helm init --upgrade --force-upgrade |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 73 | helm repo add cord https://charts.opencord.org |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 74 | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 75 | helm repo update |
| 76 | """ |
| 77 | timeout(1) { |
| 78 | waitUntil { |
Wei-Yu Chen | 76dd793 | 2019-01-18 14:14:23 -0800 | [diff] [blame] | 79 | tillerpod_running = sh returnStdout: true, script: """ |
| 80 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 81 | kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l |
| 82 | """ |
| 83 | return tillerpod_running.toInteger() == 1 |
| 84 | } |
| 85 | } |
| 86 | timeout(1) { |
| 87 | waitUntil { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 88 | cord_repo_present = sh returnStdout: true, script: """ |
| 89 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 90 | helm repo list | grep cord | wc -l |
| 91 | """ |
| 92 | return cord_repo_present.toInteger() == 1 |
| 93 | } |
| 94 | } |
| 95 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 96 | dir ("helm-charts") { |
| 97 | stage('Install SR-IOV CNI and SR-IOV Network Device Plugin') { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 98 | sh returnStdout: true, script: """ |
| 99 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 100 | kubectl apply -f mcord/cni-config/02-network-crd.yaml |
| 101 | kubectl apply -f mcord/cni-config/ |
Wei-Yu Chen | 7f8c4dd | 2019-01-17 15:32:03 -0800 | [diff] [blame] | 102 | sleep 5 |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 103 | """ |
| 104 | } |
| 105 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 106 | |
| 107 | stage("Install M-CORD Control Plane Services") { |
| 108 | sh returnStdout: true, script: """ |
| 109 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 7f8c4dd | 2019-01-17 15:32:03 -0800 | [diff] [blame] | 110 | helm install -n mcord-control-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 111 | """ |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 112 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 113 | |
| 114 | stage("Install M-CORD Data Plane Services") { |
| 115 | sh returnStdout: true, script: """ |
| 116 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 7f8c4dd | 2019-01-17 15:32:03 -0800 | [diff] [blame] | 117 | helm install -n mcord-data-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-data-plane |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 118 | """ |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 119 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 120 | |
| 121 | // stage('Install CORD Kafka') { |
| 122 | // timeout(10) { |
| 123 | // sh returnStdout: true, script: """ |
| 124 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 125 | // 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 |
| 126 | // """ |
| 127 | // } |
| 128 | // timeout(10) { |
| 129 | // waitUntil { |
| 130 | // kafka_instances_running = sh returnStdout: true, script: """ |
| 131 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 132 | // kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l |
| 133 | // """ |
| 134 | // return kafka_instances_running.toInteger() == 2 |
| 135 | // } |
| 136 | // } |
| 137 | // } |
| 138 | // stage('Install Logging Infrastructure') { |
| 139 | // timeout(10) { |
| 140 | // sh returnStdout: true, script: """ |
| 141 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 142 | // 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 |
| 143 | // helm-repo-tools/wait_for_pods.sh |
| 144 | // """ |
| 145 | // } |
| 146 | // } |
| 147 | // stage('Install Monitoring Infrastructure') { |
| 148 | // timeout(10) { |
| 149 | // sh returnStdout: true, script: """ |
| 150 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 151 | // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring |
| 152 | // helm-repo-tools/wait_for_pods.sh |
| 153 | // """ |
| 154 | // } |
| 155 | // } |
| 156 | // stage('Install ONOS') { |
| 157 | // timeout(10) { |
| 158 | // sh returnStdout: true, script: """ |
| 159 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 160 | // helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos |
| 161 | // """ |
| 162 | // } |
| 163 | // timeout(10) { |
| 164 | // waitUntil { |
| 165 | // onos_completed = sh returnStdout: true, script: """ |
| 166 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 167 | // kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l |
| 168 | // """ |
| 169 | // return onos_completed.toInteger() == 1 |
| 170 | // } |
| 171 | // } |
| 172 | // } |
| 173 | // stage('Install xos-core') { |
| 174 | // timeout(10) { |
| 175 | // sh returnStdout: true, script: """ |
| 176 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 177 | // helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core |
| 178 | // """ |
| 179 | // } |
| 180 | // timeout(10) { |
| 181 | // waitUntil { |
| 182 | // xos_core_completed = sh returnStdout: true, script: """ |
| 183 | // export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 184 | // kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l |
| 185 | // """ |
| 186 | // return xos_core_completed.toInteger() == 6 |
| 187 | // } |
| 188 | // } |
| 189 | // } |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 190 | |
| 191 | if ( params.configurePod ) { |
| 192 | dir ("${configBaseDir}/${configToscaDir}/att-workflow") { |
| 193 | stage('Configure R-CORD - Fabric and whitelist') { |
| 194 | timeout(1) { |
| 195 | waitUntil { |
| 196 | out_fabric = sh returnStdout: true, script: """ |
| 197 | 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 |
| 198 | """ |
| 199 | return out_fabric.toInteger() == 1 |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | stage('Configure R-CORD - Subscriber') { |
| 204 | timeout(1) { |
| 205 | waitUntil { |
| 206 | out_subscriber = sh returnStdout: true, script: """ |
| 207 | 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 |
| 208 | """ |
| 209 | return out_subscriber.toInteger() == 1 |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | stage('Configure R-CORD - OLT') { |
| 214 | timeout(1) { |
| 215 | waitUntil { |
| 216 | out_olt = sh returnStdout: true, script: """ |
| 217 | 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 |
| 218 | """ |
| 219 | return out_olt.toInteger() == 1 |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | currentBuild.result = 'SUCCESS' |
| 226 | } catch (err) { |
| 227 | currentBuild.result = 'FAILURE' |
| 228 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 229 | } |
| 230 | echo "RESULT: ${currentBuild.result}" |
| 231 | } |
| 232 | } |