blob: ef37d1e82bc191c31b3f2720e4a3d9fe08808767 [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}"
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 Chen9de5f162019-01-17 10:40:38 -080044 timeout(5) {
Luca Prete45401c82019-01-15 15:31:22 -080045 waitUntil {
46 kubectl_deleted = sh returnStdout: true, script: """
47 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
48 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
49 """
50 return kubectl_deleted.toInteger() == 0
51 }
52 }
53 }
54 }
Luca Prete62a48c82019-01-16 10:40:01 -080055 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080056 sh returnStdout: true, script: """
57 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080058 helm init --upgrade --force-upgrade
Luca Prete45401c82019-01-15 15:31:22 -080059 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080060 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080061 helm repo update
62 """
63 timeout(1) {
64 waitUntil {
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080065 tillerpod_running = sh returnStdout: true, script: """
66 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
67 kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l
68 """
69 return tillerpod_running.toInteger() == 1
70 }
71 }
72 timeout(1) {
73 waitUntil {
Luca Prete45401c82019-01-15 15:31:22 -080074 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 }
Matteo Scandolo08aea472019-01-23 11:45:37 -080082
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -080083
84
Wei-Yu Chen992665b2019-01-17 10:21:32 -080085 stage("Install M-CORD Control Plane Services") {
86 sh returnStdout: true, script: """
87 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -080088 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 -080089 """
Wei-Yu Chen037762d2019-01-24 11:12:39 -080090
Wei-Yu Chen037762d2019-01-24 11:12:39 -080091 timeout(20) {
92 control_plane = sh returnStdout: true, script: """
93 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -080094 kubectl -n epc get pods | grep -i running | grep 1/1 | wc -l
Wei-Yu Chen037762d2019-01-24 11:12:39 -080095 """
96 // We have 4 pods: cassandra, hss, mme and ngic-cp
97 return control_plane.toInteger() == 4
98 }
Luca Prete45401c82019-01-15 15:31:22 -080099 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -0800100
Wei-Yu Chen1a5f9ff2019-02-07 10:18:55 -0800101 // TODO: Use --namespace wowz to create the namespace
102 stage("Install CDN Remote Services") {
103 sh returnStdout: true, script: """
104 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
105 helm install -n cdn-remote cord/mcord-cdn-remote
106 """
107
108 timeout(3) {
109 waitUntil {
110 mcord_remote_cdn_working = sh returnStdout: true, script: """
111 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
112 kubectl -n wowz get pods -o wide | grep -i running | grep 1/1 | wc -l
113 """
114 return mcord_remote_cdn_working.toInteger() == 1
115 }
116 }
117 }
118
Luca Prete45401c82019-01-15 15:31:22 -0800119 currentBuild.result = 'SUCCESS'
120 } catch (err) {
121 currentBuild.result = 'FAILURE'
122 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
123 }
124 echo "RESULT: ${currentBuild.result}"
125 }
126}