blob: 9149221d6aa0f5dc6a9eca93b005342fa083af09 [file] [log] [blame]
Zack Williams9d68aa32018-07-12 11:50:37 -07001// 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
Zack Williams9d68aa32018-07-12 11:50:37 -070018pipeline {
19
Zack Williamsfd87d652018-07-12 14:21:12 -070020 /* no label, executor is determined by JJB */
21 agent {
22 label "${params.executorNode}"
23 }
Zack Williams9d68aa32018-07-12 11:50:37 -070024
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
Zack Williams9d68aa32018-07-12 11:50:37 -070045 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 '''
77 }
78 }
79
Kailash Khalasi1c773ed2018-08-01 10:47:59 -070080 stage('install/test rcord-lite') {
Zack Williams9d68aa32018-07-12 11:50:37 -070081 steps {
82 sh """
83 #!/usr/bin/env bash
84 set -eu -o pipefail
85
86 helm_install_args='-f examples/api-test-values.yaml'
Zack Williams9d68aa32018-07-12 11:50:37 -070087
88 pushd cord/helm-charts
89
90 helm dep up xos-core
91 helm install \${helm_install_args} xos-core -n xos-core
92
Kailash Khalasi1c773ed2018-08-01 10:47:59 -070093 helm dep update xos-profiles/rcord-lite
94 helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
Zack Williams9d68aa32018-07-12 11:50:37 -070095
Kailash Khalasi1c773ed2018-08-01 10:47:59 -070096 # wait for services to load
Kailash Khalasiedb48b12018-07-31 13:01:01 -070097 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
Kailash Khalasiba3e3d72018-08-03 13:53:45 -070098 # adding tmp sleep momentarily
99 sleep 120
Zack Williams9d68aa32018-07-12 11:50:37 -0700100
101 echo "# Checking helm deployments"
102 kubectl get pods
103 helm list
104
105 for hchart in \$(helm list -q);
106 do
107 echo "## 'helm status' for chart: \${hchart} ##"
108 helm status "\${hchart}"
109 done
110
Zack Williamsfd87d652018-07-12 14:21:12 -0700111 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
Zack Williams9d68aa32018-07-12 11:50:37 -0700112
Zack Williamsfd87d652018-07-12 14:21:12 -0700113 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosapitests.xtarget
114 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
115 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
116 docker exec -i \$CORE_CONTAINER /bin/bash -c "xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosapitests.xtarget /opt/xos/core/models/core.xproto" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700117
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700118 export testname=_service_api.robot
119 export library=_library.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700120
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700121 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
122 echo \$SERVICES
Zack Williams9d68aa32018-07-12 11:50:37 -0700123
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700124 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosserviceapitests.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done
Zack Williamsfd87d652018-07-12 14:21:12 -0700125
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700126 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xoslibrary.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$library; done
Zack Williams9d68aa32018-07-12 11:50:37 -0700127
Zack Williamsfd87d652018-07-12 14:21:12 -0700128 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
129 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
130 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
Zack Williams9d68aa32018-07-12 11:50:37 -0700131
Zack Williamsfd87d652018-07-12 14:21:12 -0700132 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
133 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
134 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
135 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
136 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
137 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Zack Williams9d68aa32018-07-12 11:50:37 -0700138
Zack Williamsfd87d652018-07-12 14:21:12 -0700139 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700140 ## Run CORE API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700141 pybot -d Log -T XOSCoreAPITests.robot || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700142 ## Run Rcord-lite services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700143 for i in \$SERVICES; do bash -c "pybot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Zack Williamsfd87d652018-07-12 14:21:12 -0700144
145 popd
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700146
147 helm delete --purge rcord-lite
148 helm delete --purge xos-core
Zack Williamsfd87d652018-07-12 14:21:12 -0700149 """
150 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700151 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700152
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700153 stage('install/test mcord') {
Zack Williamsfd87d652018-07-12 14:21:12 -0700154 steps {
155 sh """
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700156 #!/usr/bin/env bash
157 set -eu -o pipefail
Zack Williamsfd87d652018-07-12 14:21:12 -0700158
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700159 helm_install_args='-f examples/api-test-values.yaml'
160
161 pushd cord/helm-charts
162
163 helm dep up xos-core
164 helm install \${helm_install_args} xos-core -n xos-core
165
166 helm dep update xos-profiles/base-openstack
167 helm dep update xos-profiles/mcord
168 helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
169 helm install \${helm_install_args} xos-profiles/mcord -n mcord
170
171 # wait for services to load
172 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
173
174 echo "# Checking helm deployments"
175 kubectl get pods
176 helm list
177
178 for hchart in \$(helm list -q);
179 do
180 echo "## 'helm status' for chart: \${hchart} ##"
181 helm status "\${hchart}"
182 done
183
184 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
185
186 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosapitests.xtarget
187 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
188 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
189 docker exec -i \$CORE_CONTAINER /bin/bash -c "xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosapitests.xtarget /opt/xos/core/models/core.xproto" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
190
191 export testname=_service_api.robot
192 export library=_library.robot
193
194 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
195 echo \$SERVICES
196
197 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosserviceapitests.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done
198
199 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xoslibrary.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$library; done
200
201 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
202 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
203 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
204
205 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
206 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
207
208 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
209 ## Run mcord services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700210 for i in \$SERVICES; do bash -c "pybot -d Log -T -e ProgranServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700211
212 popd
213
214 helm delete --purge base-openstack
215 helm delete --purge mcord
216 helm delete --purge xos-core
217 """
Zack Williamsfd87d652018-07-12 14:21:12 -0700218 }
219 }
220
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700221 stage('install/test simpleexampleservice') {
222 steps {
223 sh """
224 #!/usr/bin/env bash
225 set -eu -o pipefail
226
227 helm_install_args='-f examples/api-test-values.yaml'
228
229 pushd cord/helm-charts
230
231 helm dep up xos-core
232 helm install \${helm_install_args} xos-core -n xos-core
233
234 helm dep update xos-profiles/base-kubernetes
235 helm dep update xos-profiles/demo-simpleexampleservice
236 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
237 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
238
239 # wait for services to load
240 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
241
242 echo "# Checking helm deployments"
243 kubectl get pods
244 helm list
245
246 for hchart in \$(helm list -q);
247 do
248 echo "## 'helm status' for chart: \${hchart} ##"
249 helm status "\${hchart}"
250 done
251
252 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
253
254 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosapitests.xtarget
255 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
256 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
257 docker exec -i \$CORE_CONTAINER /bin/bash -c "xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosapitests.xtarget /opt/xos/core/models/core.xproto" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
258
259 export testname=_service_api.robot
260 export library=_library.robot
261
262 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
263 echo \$SERVICES
264
265 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosserviceapitests.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done
266
267 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xoslibrary.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$library; done
268
269 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
270 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
271 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
272
273 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
274 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
275
276 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
277 ## Run kubernetes-base services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700278 for i in \$SERVICES; do bash -c "pybot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700279
280 popd
281
282 helm delete --purge base-kubernetes
283 helm delete --purge demo-simpleexampleservice
284 helm delete --purge xos-core
285 """
286 }
287 }
288
289 stage('install/test hippie-oss') {
290 steps {
291 sh """
292 #!/usr/bin/env bash
293 set -eu -o pipefail
294
295 helm_install_args='-f examples/api-test-values.yaml'
296
297 pushd cord/helm-charts
298
299 helm dep up xos-core
300 helm install \${helm_install_args} xos-core -n xos-core
301
302 helm dep update xos-services/hippie-oss
303 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
304
305 # wait for services to load
306 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
307 ## sleeping as hippie-oss doesnt have a tosca-loader
308 sleep 300
309 echo "# Checking helm deployments"
310 kubectl get pods
311 helm list
312
313 for hchart in \$(helm list -q);
314 do
315 echo "## 'helm status' for chart: \${hchart} ##"
316 helm status "\${hchart}"
317 done
318
319 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
320
321 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosapitests.xtarget
322 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
323 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
324 docker exec -i \$CORE_CONTAINER /bin/bash -c "xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosapitests.xtarget /opt/xos/core/models/core.xproto" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
325
326 export testname=_service_api.robot
327 export library=_library.robot
328
329 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
330 echo \$SERVICES
331
332 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
333 ## Run hippie-oss services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700334 for i in \$SERVICES; do bash -c "pybot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700335
336 popd
337
338 helm delete --purge hippie-oss
339 helm delete --purge xos-core
340 """
341 }
342 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700343 }
344 post {
345 always {
346 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700347 # copy robot logs
348 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
349 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700350
Zack Williamsfd87d652018-07-12 14:21:12 -0700351 kubectl get pods --all-namespaces
352
353 echo "# removing helm deployments"
354 kubectl get pods
355 helm list
356
357 for hchart in \$(helm list -q);
358 do
359 echo "## Purging chart: \${hchart} ##"
360 helm delete --purge "\${hchart}"
361 done
362
Zack Williamsf8b356c2018-07-17 17:01:27 -0700363 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700364 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700365 step([$class: 'RobotPublisher',
366 disableArchiveOutput: false,
367 logFileName: 'RobotLogs/log*.html',
368 otherFiles: '',
369 outputFileName: 'RobotLogs/output*.xml',
370 outputPath: '.',
371 passThreshold: 100,
372 reportFileName: 'RobotLogs/report*.html',
373 unstableThreshold: 0]);
374 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700375 }
376 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700377}