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 | 213821c | 2019-01-17 10:21:32 -0800 | [diff] [blame^] | 44 | timout(5) { |
| 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 |
| 49 | kubectl delete -f mcord/cni-config/ |
| 50 | """ |
| 51 | } |
| 52 | } |
| 53 | } |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 54 | timeout(5) { |
| 55 | waitUntil { |
| 56 | kubectl_deleted = sh returnStdout: true, script: """ |
| 57 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 58 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 59 | """ |
| 60 | return kubectl_deleted.toInteger() == 0 |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 65 | stage('Add Helm repositories') { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 66 | sh returnStdout: true, script: """ |
| 67 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 68 | helm repo add cord https://charts.opencord.org |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 69 | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 70 | 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 Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 82 | dir ("helm-charts") { |
| 83 | stage('Install SR-IOV CNI and SR-IOV Network Device Plugin') { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 84 | sh returnStdout: true, script: """ |
| 85 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 86 | kubectl apply -f mcord/cni-config/02-network-crd.yaml |
| 87 | kubectl apply -f mcord/cni-config/ |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 88 | """ |
| 89 | } |
| 90 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 91 | |
| 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 Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 97 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 98 | |
| 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 Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 104 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 105 | |
| 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 Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 175 | |
| 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 | } |