blob: 14392c99d9c9d35c95e45bb479d5607e2edf7a5c [file] [log] [blame]
Kailash46a2a9a2019-01-23 12:39:04 -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
15// chart-api-test-helm.groovy
16// Checks functionality of the helm-chart, without overriding the version/tag used
17
18pipeline {
19
20 /* no label, executor is determined by JJB */
21 agent {
22 label "${params.executorNode}"
23 }
24
25 stages {
26
27 stage('repo') {
28 steps {
29 checkout(changelog: false, \
30 poll: false,
31 scm: [$class: 'RepoScm', \
32 manifestRepositoryUrl: "${params.manifestUrl}", \
33 manifestBranch: "${params.manifestBranch}", \
34 currentBranch: true, \
35 destinationDir: 'cord', \
36 forceSync: true,
37 resetFirst: true, \
38 quiet: true, \
39 jobs: 4, \
40 showAllChanges: true] \
41 )
42 }
43 }
44
45 stage('minikube') {
46 steps {
47 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
48 sh '''
49 export MINIKUBE_WANTUPDATENOTIFICATION=false
50 export MINIKUBE_WANTREPORTERRORPROMPT=false
51 export CHANGE_MINIKUBE_NONE_USER=true
52 export MINIKUBE_HOME=$HOME
53 mkdir -p $HOME/.kube || true
54 touch $HOME/.kube/config
55 export KUBECONFIG=$HOME/.kube/config
56 sudo -E /usr/bin/minikube start --vm-driver=none
57 '''
58 script {
59 timeout(3) {
60 waitUntil {
61 sleep 5
62 def kc_ret = sh script: "kubectl get po", returnStatus: true
63 return (kc_ret == 0);
64 }
65 }
66 }
67 }
68 }
69
70 stage('helm') {
71 steps {
72 sh '''
73 helm init
74 sleep 60
75 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
76 helm repo add cord https://charts.opencord.org
77 helm repo update
78 '''
79 }
80 }
81
82 stage('Build BBSIM') {
83 steps {
84 sh '''
85 git clone https://github.com/opencord/voltha-bbsim
86 cd voltha-bbsim/
87 make docker
Kailashff5c5402019-01-28 15:47:54 -080088 docker images | grep bbsim
Kailash46a2a9a2019-01-23 12:39:04 -080089 '''
90 }
91 }
92
93 stage('Install BBSIM w/SEBA') {
94 steps {
95 sh """
96 #!/usr/bin/env bash
97 set -eu -o pipefail
98
Kailashff5c5402019-01-28 15:47:54 -080099 git clone https://gerrit.opencord.org/pod-configs
Kailash46a2a9a2019-01-23 12:39:04 -0800100 pushd cord/helm-charts
101
102 helm install -f examples/kafka-single.yaml --version 0.13.3 -n cord-kafka incubator/kafka
103
104 git clone https://gerrit.opencord.org/helm-repo-tools
105 helm-repo-tools/wait_for_pods.sh
106
107 helm upgrade --install etcd-operator --version 0.8.3 stable/etcd-operator
Kailashff5c5402019-01-28 15:47:54 -0800108 sleep 120
Kailash46a2a9a2019-01-23 12:39:04 -0800109 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
110
111 helm dep up voltha
Kailashff5c5402019-01-28 15:47:54 -0800112 helm install -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig} voltha -n voltha
113 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh voltha
114
115 helm dep up onos
116 helm install onos -n onos -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig}
117 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Kailash46a2a9a2019-01-23 12:39:04 -0800118
119 helm dep up xos-core
Kailashff5c5402019-01-28 15:47:54 -0800120 helm install xos-core -n xos-core -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig}
Kailash46a2a9a2019-01-23 12:39:04 -0800121
122 helm dep update xos-profiles/seba-services
Kailashff5c5402019-01-28 15:47:54 -0800123 helm install xos-profiles/seba-services -n seba-services -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig}
124 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
125
126 helm dep update xos-profiles/base-kubernetes
127 helm install xos-profiles/base-kubernetes -n base-kubernetes -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig}
Kailash46a2a9a2019-01-23 12:39:04 -0800128
129 helm dep update workflows/att-workflow
Kailashff5c5402019-01-28 15:47:54 -0800130 helm install workflows/att-workflow -n att-workflow -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig}
Kailash46a2a9a2019-01-23 12:39:04 -0800131
132 # wait for services to load
133 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
Kailashff5c5402019-01-28 15:47:54 -0800134
Kailash46a2a9a2019-01-23 12:39:04 -0800135 echo "# Checking helm deployments"
136 kubectl get pods
137 helm list
138
Kailashff5c5402019-01-28 15:47:54 -0800139 helm install --set images.bbsim.tag=latest --set images.bbsim.pullPolicy=IfNotPresent bbsim -n bbsim
Kailash46a2a9a2019-01-23 12:39:04 -0800140 for hchart in \$(helm list -q);
141 do
142 echo "## 'helm status' for chart: \${hchart} ##"
143 helm status "\${hchart}"
144 done
Kailashff5c5402019-01-28 15:47:54 -0800145 kubectl get pods -n voltha -o json
Kailash46a2a9a2019-01-23 12:39:04 -0800146 popd
147 """
148 }
149 }
150
151 stage('Load BBSIM Tosca') {
152 steps {
153 sh '''
154 #!/usr/bin/env bash
155 set -eu -o pipefail
156
157 pushd cord/helm-charts
158
159 curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @examples/bbsim-dhcp.yaml http://127.0.0.1:30007/run
160 curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @examples/bbsim-16.yaml http://127.0.0.1:30007/run
161
162 popd
163 '''
164 }
165 }
166 stage('Test BBSIM') {
167 steps {
168 sh '''
169 #!/usr/bin/env bash
170 set -eu -o pipefail
171
172 helm test --timeout 1000 bbsim || true
Kailash46a2a9a2019-01-23 12:39:04 -0800173 '''
174 }
175 }
176 }
177 post {
178 always {
179 sh '''
180
181 kubectl logs bbsim-api-test --namespace default
182 kubectl get pods --all-namespaces
183
Kailashff5c5402019-01-28 15:47:54 -0800184 curl http://127.0.0.1:30125/api/v1/devices || true
185
Kailash46a2a9a2019-01-23 12:39:04 -0800186 # copy robot logs
187 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
188 cp -r /tmp/helm_test_bbsim_logs_*/*ml ./RobotLogs
189
190 echo "# removing helm deployments"
191 kubectl get pods
192 helm list
193
194 for hchart in \$(helm list -q);
195 do
196 echo "## Purging chart: \${hchart} ##"
197 helm delete --purge "\${hchart}"
198 done
199
200 sudo minikube delete
201 '''
202 step([$class: 'RobotPublisher',
203 disableArchiveOutput: false,
204 logFileName: 'RobotLogs/log*.html',
205 otherFiles: '',
206 outputFileName: 'RobotLogs/output*.xml',
207 outputPath: '.',
208 passThreshold: 100,
209 reportFileName: 'RobotLogs/report*.html',
210 unstableThreshold: 0]);
211 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
212
213 }
214 }
215}