blob: 34f8dd223c7320161c4e871504aa4b8e5072b6ce [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
45 stage('patch') {
46 steps {
47 sh """
48 pushd cord
49 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
50 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
51 popd
52 """
53 }
54 }
55
56
57 stage('minikube') {
58 steps {
59 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
60 sh '''
61 export MINIKUBE_WANTUPDATENOTIFICATION=false
62 export MINIKUBE_WANTREPORTERRORPROMPT=false
63 export CHANGE_MINIKUBE_NONE_USER=true
64 export MINIKUBE_HOME=$HOME
65 mkdir -p $HOME/.kube || true
66 touch $HOME/.kube/config
67 export KUBECONFIG=$HOME/.kube/config
68 sudo -E /usr/bin/minikube start --vm-driver=none
69 '''
70 script {
71 timeout(3) {
72 waitUntil {
73 sleep 5
74 def kc_ret = sh script: "kubectl get po", returnStatus: true
75 return (kc_ret == 0);
76 }
77 }
78 }
79 }
80 }
81
82 stage('helm') {
83 steps {
84 sh '''
85 helm init
86 sleep 60
87 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
88 '''
89 }
90 }
91
Kailash Khalasi1c773ed2018-08-01 10:47:59 -070092 stage('install/test rcord-lite') {
Zack Williams9d68aa32018-07-12 11:50:37 -070093 steps {
94 sh """
95 #!/usr/bin/env bash
96 set -eu -o pipefail
97
98 helm_install_args='-f examples/api-test-values.yaml'
Zack Williams9d68aa32018-07-12 11:50:37 -070099
100 pushd cord/helm-charts
101
102 helm dep up xos-core
103 helm install \${helm_install_args} xos-core -n xos-core
104
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700105 helm dep update xos-profiles/rcord-lite
106 helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
Zack Williams9d68aa32018-07-12 11:50:37 -0700107
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700108 # wait for services to load
Kailash Khalasiedb48b12018-07-31 13:01:01 -0700109 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
Zack Williams9d68aa32018-07-12 11:50:37 -0700110
111 echo "# Checking helm deployments"
112 kubectl get pods
113 helm list
114
115 for hchart in \$(helm list -q);
116 do
117 echo "## 'helm status' for chart: \${hchart} ##"
118 helm status "\${hchart}"
119 done
120
Zack Williamsfd87d652018-07-12 14:21:12 -0700121 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
Zack Williams9d68aa32018-07-12 11:50:37 -0700122
Zack Williamsfd87d652018-07-12 14:21:12 -0700123 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
124 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
125 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
126 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 -0700127
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700128 export testname=_service_api.robot
129 export library=_library.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700130
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700131 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
132 echo \$SERVICES
Zack Williams9d68aa32018-07-12 11:50:37 -0700133
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700134 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 -0700135
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700136 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 -0700137
Zack Williamsfd87d652018-07-12 14:21:12 -0700138 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
139 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
140 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 -0700141
Zack Williamsfd87d652018-07-12 14:21:12 -0700142 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
143 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
144 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
145 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
146 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
147 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Zack Williams9d68aa32018-07-12 11:50:37 -0700148
Zack Williamsfd87d652018-07-12 14:21:12 -0700149 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700150 ## Run CORE API Tests
Zack Williamsfd87d652018-07-12 14:21:12 -0700151 pybot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice -e ControllerUser XOSCoreAPITests.robot || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700152 ## Run Rcord-lite services API Tests
Kailash Khalasi29573cd2018-08-03 10:51:23 -0700153 for i in \$SERVICES; do bash -c "pybot -d Log -T -e ProgranServiceInstance -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Zack Williamsfd87d652018-07-12 14:21:12 -0700154
155 popd
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700156
157 helm delete --purge rcord-lite
158 helm delete --purge xos-core
Zack Williamsfd87d652018-07-12 14:21:12 -0700159 """
160 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700161 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700162
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700163 stage('install/test mcord') {
Zack Williamsfd87d652018-07-12 14:21:12 -0700164 steps {
165 sh """
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700166 #!/usr/bin/env bash
167 set -eu -o pipefail
Zack Williamsfd87d652018-07-12 14:21:12 -0700168
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700169 helm_install_args='-f examples/api-test-values.yaml'
170
171 pushd cord/helm-charts
172
173 helm dep up xos-core
174 helm install \${helm_install_args} xos-core -n xos-core
175
176 helm dep update xos-profiles/base-openstack
177 helm dep update xos-profiles/mcord
178 helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
179 helm install \${helm_install_args} xos-profiles/mcord -n mcord
180
181 # wait for services to load
182 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
183
184 echo "# Checking helm deployments"
185 kubectl get pods
186 helm list
187
188 for hchart in \$(helm list -q);
189 do
190 echo "## 'helm status' for chart: \${hchart} ##"
191 helm status "\${hchart}"
192 done
193
194 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
195
196 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
197 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
198 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
199 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
200
201 export testname=_service_api.robot
202 export library=_library.robot
203
204 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
205 echo \$SERVICES
206
207 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
208
209 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
210
211 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
212 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
213 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
214
215 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
216 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
217
218 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
219 ## Run mcord services API Tests
220 for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
221
222 popd
223
224 helm delete --purge base-openstack
225 helm delete --purge mcord
226 helm delete --purge xos-core
227 """
Zack Williamsfd87d652018-07-12 14:21:12 -0700228 }
229 }
230
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700231 stage('install/test simpleexampleservice') {
232 steps {
233 sh """
234 #!/usr/bin/env bash
235 set -eu -o pipefail
236
237 helm_install_args='-f examples/api-test-values.yaml'
238
239 pushd cord/helm-charts
240
241 helm dep up xos-core
242 helm install \${helm_install_args} xos-core -n xos-core
243
244 helm dep update xos-profiles/base-kubernetes
245 helm dep update xos-profiles/demo-simpleexampleservice
246 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
247 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
248
249 # wait for services to load
250 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
251
252 echo "# Checking helm deployments"
253 kubectl get pods
254 helm list
255
256 for hchart in \$(helm list -q);
257 do
258 echo "## 'helm status' for chart: \${hchart} ##"
259 helm status "\${hchart}"
260 done
261
262 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
263
264 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
265 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
266 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
267 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
268
269 export testname=_service_api.robot
270 export library=_library.robot
271
272 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
273 echo \$SERVICES
274
275 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
276
277 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
278
279 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
280 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
281 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
282
283 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
284 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
285
286 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
287 ## Run kubernetes-base services API Tests
288 for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
289
290 popd
291
292 helm delete --purge base-kubernetes
293 helm delete --purge demo-simpleexampleservice
294 helm delete --purge xos-core
295 """
296 }
297 }
298
299 stage('install/test hippie-oss') {
300 steps {
301 sh """
302 #!/usr/bin/env bash
303 set -eu -o pipefail
304
305 helm_install_args='-f examples/api-test-values.yaml'
306
307 pushd cord/helm-charts
308
309 helm dep up xos-core
310 helm install \${helm_install_args} xos-core -n xos-core
311
312 helm dep update xos-services/hippie-oss
313 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
314
315 # wait for services to load
316 JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh
317 ## sleeping as hippie-oss doesnt have a tosca-loader
318 sleep 300
319 echo "# Checking helm deployments"
320 kubectl get pods
321 helm list
322
323 for hchart in \$(helm list -q);
324 do
325 echo "## 'helm status' for chart: \${hchart} ##"
326 helm status "\${hchart}"
327 done
328
329 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
330
331 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
332 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
333 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
334 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
335
336 export testname=_service_api.robot
337 export library=_library.robot
338
339 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
340 echo \$SERVICES
341
342 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
343 ## Run hippie-oss services API Tests
344 for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
345
346 popd
347
348 helm delete --purge hippie-oss
349 helm delete --purge xos-core
350 """
351 }
352 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700353 }
354 post {
355 always {
356 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700357 # copy robot logs
358 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
359 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700360
Zack Williamsfd87d652018-07-12 14:21:12 -0700361 kubectl get pods --all-namespaces
362
363 echo "# removing helm deployments"
364 kubectl get pods
365 helm list
366
367 for hchart in \$(helm list -q);
368 do
369 echo "## Purging chart: \${hchart} ##"
370 helm delete --purge "\${hchart}"
371 done
372
Zack Williamsf8b356c2018-07-17 17:01:27 -0700373 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700374 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700375 step([$class: 'RobotPublisher',
376 disableArchiveOutput: false,
377 logFileName: 'RobotLogs/log*.html',
378 otherFiles: '',
379 outputFileName: 'RobotLogs/output*.xml',
380 outputPath: '.',
381 passThreshold: 100,
382 reportFileName: 'RobotLogs/report*.html',
383 unstableThreshold: 0]);
384 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700385 }
386 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700387}