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 | 1a5f9ff | 2019-02-07 10:18:55 -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}" |
Wei-Yu Chen | ab221cb | 2019-02-15 14:59:31 -0800 | [diff] [blame] | 23 | |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 24 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 25 | } |
| 26 | stage('Clean up') { |
| 27 | timeout(10) { |
| 28 | sh returnStdout: true, script: """ |
| 29 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 53d303a | 2019-02-19 15:15:27 -0800 | [diff] [blame^] | 30 | helm init --upgrade --force-upgrade |
| 31 | """ |
| 32 | |
| 33 | timeout(1) { |
| 34 | waitUntil { |
| 35 | tillerpod_running = sh returnStdout: true, script: """ |
| 36 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 37 | kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l |
| 38 | """ |
| 39 | return tillerpod_running.toInteger() == 1 |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | sh returnStdout: true, script: """ |
| 44 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 45 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 46 | do |
| 47 | echo "Purging chart: \${hchart}" |
| 48 | helm delete --purge "\${hchart}" |
| 49 | done |
| 50 | """ |
| 51 | timeout(5) { |
| 52 | waitUntil { |
| 53 | helm_deleted = sh returnStdout: true, script: """ |
| 54 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 55 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 56 | """ |
| 57 | return helm_deleted.toInteger() == 0 |
| 58 | } |
| 59 | } |
Wei-Yu Chen | 9de5f16 | 2019-01-17 10:40:38 -0800 | [diff] [blame] | 60 | timeout(5) { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 61 | waitUntil { |
| 62 | kubectl_deleted = sh returnStdout: true, script: """ |
| 63 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 64 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 65 | """ |
| 66 | return kubectl_deleted.toInteger() == 0 |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 71 | stage('Add Helm repositories') { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 72 | sh returnStdout: true, script: """ |
| 73 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 74 | helm repo add cord https://charts.opencord.org |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 75 | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 76 | helm repo update |
| 77 | """ |
| 78 | timeout(1) { |
| 79 | waitUntil { |
Wei-Yu Chen | 76dd793 | 2019-01-18 14:14:23 -0800 | [diff] [blame] | 80 | tillerpod_running = sh returnStdout: true, script: """ |
| 81 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 82 | kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l |
| 83 | """ |
| 84 | return tillerpod_running.toInteger() == 1 |
| 85 | } |
| 86 | } |
| 87 | timeout(1) { |
| 88 | waitUntil { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 89 | cord_repo_present = sh returnStdout: true, script: """ |
| 90 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 91 | helm repo list | grep cord | wc -l |
| 92 | """ |
| 93 | return cord_repo_present.toInteger() == 1 |
| 94 | } |
| 95 | } |
| 96 | } |
Matteo Scandolo | 08aea47 | 2019-01-23 11:45:37 -0800 | [diff] [blame] | 97 | |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 98 | stage("Install M-CORD Control Plane Services") { |
| 99 | sh returnStdout: true, script: """ |
| 100 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 101 | helm install -n mcord-control-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set spgwu_s1u_ip=${dataplane_s1u_ip} --set accelleran_hostname=${accelleran_bbu_ip} cord/mcord-control-plane |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 102 | """ |
Wei-Yu Chen | 037762d | 2019-01-24 11:12:39 -0800 | [diff] [blame] | 103 | |
Wei-Yu Chen | 037762d | 2019-01-24 11:12:39 -0800 | [diff] [blame] | 104 | timeout(20) { |
| 105 | control_plane = sh returnStdout: true, script: """ |
| 106 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 107 | kubectl -n epc get pods | grep -i running | grep 1/1 | wc -l |
Wei-Yu Chen | 037762d | 2019-01-24 11:12:39 -0800 | [diff] [blame] | 108 | """ |
| 109 | // We have 4 pods: cassandra, hss, mme and ngic-cp |
| 110 | return control_plane.toInteger() == 4 |
| 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 | |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 114 | // TODO: Use --namespace wowz to create the namespace |
| 115 | stage("Install CDN Remote Services") { |
| 116 | sh returnStdout: true, script: """ |
| 117 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Andy Bavier | 490c819 | 2019-02-15 14:20:25 -0800 | [diff] [blame] | 118 | helm install -n cdn-remote cord/mcord-cdn-remote -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 119 | """ |
| 120 | |
| 121 | timeout(3) { |
| 122 | waitUntil { |
| 123 | mcord_remote_cdn_working = sh returnStdout: true, script: """ |
| 124 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 125 | kubectl -n wowz get pods -o wide | grep -i running | grep 1/1 | wc -l |
| 126 | """ |
| 127 | return mcord_remote_cdn_working.toInteger() == 1 |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 132 | currentBuild.result = 'SUCCESS' |
| 133 | } catch (err) { |
Wei-Yu Chen | ab221cb | 2019-02-15 14:59:31 -0800 | [diff] [blame] | 134 | println err.message |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 135 | currentBuild.result = 'FAILURE' |
| 136 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 137 | } |
| 138 | echo "RESULT: ${currentBuild.result}" |
| 139 | } |
| 140 | } |