blob: b24a47d92cc99a01c42950089d1f38b5735d6b74 [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 Chen1a5f9ff2019-02-07 10:18:55 -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}"
Wei-Yu Chenab221cb2019-02-15 14:59:31 -080023
Luca Prete45401c82019-01-15 15:31:22 -080024 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 Chen53d303a2019-02-19 15:15:27 -080030 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 &&
Wei-Yu Chena17a2792019-02-19 15:31:03 -080037 kubectl -n kube-system get pods | grep tiller-deploy | grep Running | grep 1/1 | wc -l
Wei-Yu Chen53d303a2019-02-19 15:15:27 -080038 """
39 return tillerpod_running.toInteger() == 1
40 }
41 }
42
43 sh returnStdout: true, script: """
44 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Luca Prete45401c82019-01-15 15:31:22 -080045 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 """
Wei-Yu Chena17a2792019-02-19 15:31:03 -080051
Luca Prete45401c82019-01-15 15:31:22 -080052 timeout(5) {
53 waitUntil {
54 helm_deleted = sh returnStdout: true, script: """
55 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
56 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
57 """
58 return helm_deleted.toInteger() == 0
59 }
60 }
Wei-Yu Chen9de5f162019-01-17 10:40:38 -080061 timeout(5) {
Luca Prete45401c82019-01-15 15:31:22 -080062 waitUntil {
63 kubectl_deleted = sh returnStdout: true, script: """
64 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
65 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
66 """
67 return kubectl_deleted.toInteger() == 0
68 }
69 }
70 }
71 }
Luca Prete62a48c82019-01-16 10:40:01 -080072 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080073 sh returnStdout: true, script: """
74 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
75 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080076 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080077 helm repo update
78 """
79 timeout(1) {
80 waitUntil {
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080081 tillerpod_running = sh returnStdout: true, script: """
82 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
83 kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l
84 """
85 return tillerpod_running.toInteger() == 1
86 }
87 }
88 timeout(1) {
89 waitUntil {
Luca Prete45401c82019-01-15 15:31:22 -080090 cord_repo_present = sh returnStdout: true, script: """
91 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
92 helm repo list | grep cord | wc -l
93 """
94 return cord_repo_present.toInteger() == 1
95 }
96 }
97 }
Matteo Scandolo08aea472019-01-23 11:45:37 -080098
Wei-Yu Chen992665b2019-01-17 10:21:32 -080099 stage("Install M-CORD Control Plane Services") {
100 sh returnStdout: true, script: """
101 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -0800102 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 Chen992665b2019-01-17 10:21:32 -0800103 """
Wei-Yu Chen037762d2019-01-24 11:12:39 -0800104
Wei-Yu Chen037762d2019-01-24 11:12:39 -0800105 timeout(20) {
106 control_plane = sh returnStdout: true, script: """
107 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -0800108 kubectl -n epc get pods | grep -i running | grep 1/1 | wc -l
Wei-Yu Chen037762d2019-01-24 11:12:39 -0800109 """
110 // We have 4 pods: cassandra, hss, mme and ngic-cp
111 return control_plane.toInteger() == 4
112 }
Luca Prete45401c82019-01-15 15:31:22 -0800113 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800114
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -0800115 // TODO: Use --namespace wowz to create the namespace
116 stage("Install CDN Remote Services") {
117 sh returnStdout: true, script: """
118 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andy Bavier490c8192019-02-15 14:20:25 -0800119 helm install -n cdn-remote cord/mcord-cdn-remote -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -0800120 """
121
122 timeout(3) {
123 waitUntil {
124 mcord_remote_cdn_working = sh returnStdout: true, script: """
125 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
126 kubectl -n wowz get pods -o wide | grep -i running | grep 1/1 | wc -l
127 """
Wei-Yu Chena17a2792019-02-19 15:31:03 -0800128 return mcord_remote_cdn_working.toInteger() == 2
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -0800129 }
130 }
131 }
132
Luca Prete45401c82019-01-15 15:31:22 -0800133 currentBuild.result = 'SUCCESS'
134 } catch (err) {
Wei-Yu Chenab221cb2019-02-15 14:59:31 -0800135 println err.message
Luca Prete45401c82019-01-15 15:31:22 -0800136 currentBuild.result = 'FAILURE'
137 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
138 }
139 echo "RESULT: ${currentBuild.result}"
140 }
141}