blob: 1d5112f3b75ae98c0931c15737f353a2fa71f345 [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
Zack Williamsa26fc9d2018-09-18 16:49:01 -070080 stage('cord-kafka') {
81 steps {
82 sh '''
83 #!/usr/bin/env bash
84 set -eu -o pipefail
85
86 pushd cord/helm-charts
87 helm install -f examples/kafka-single.yaml --version 0.8.8 -n cord-kafka incubator/kafka
Zack Williams91cecd22018-09-26 10:59:44 -070088 ./scripts/wait_for_pods.sh
Zack Williamsa26fc9d2018-09-18 16:49:01 -070089
90 popd
91 '''
92 }
93 }
94
Zack Williams91cecd22018-09-26 10:59:44 -070095 stage('install/test att-workflow') {
Zack Williams2e515f32018-09-27 23:03:07 -070096 when {
97 expression {
98 params.manifestBranch ==~ 'master'
99 }
100 }
Zack Williams91cecd22018-09-26 10:59:44 -0700101 steps {
102 sh """
103 #!/usr/bin/env bash
104 set -eu -o pipefail
105
106 helm_install_args='-f examples/api-test-values.yaml'
107
108 pushd cord/helm-charts
109
110 helm dep up xos-core
111 helm install \${helm_install_args} xos-core -n xos-core
112
113 helm dep update xos-profiles/att-workflow
114 helm install \${helm_install_args} xos-profiles/att-workflow -n att-workflow
115
116 # wait for services to load
117 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
118
119 echo "# Checking helm deployments"
120 kubectl get pods
121
122 for hchart in \$(helm list -q);
123 do
124 echo "## 'helm status' for chart: \${hchart} ##"
125 helm status "\${hchart}"
126 done
127
Zack Williams2e515f32018-09-27 23:03:07 -0700128 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
129 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams91cecd22018-09-26 10:59:44 -0700130
131 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
132 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
133 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
134 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
135
136 export testname=_service_api.robot
137 export library=_library.robot
138
139 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
140 echo \$SERVICES
141
142 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
143
144 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
145
Zack Williams91cecd22018-09-26 10:59:44 -0700146 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
147 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
148
149 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
150 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
151 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
152 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
153 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
154 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
155
156 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
157 ## Run CORE API Tests
158 pybot -d Log -T XOSCoreAPITests.robot || true
159 ## Run services API Tests
160 for i in \$SERVICES; do bash -c "pybot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
161
162 popd
163
164 helm delete --purge att-workflow
165 helm delete --purge xos-core
166 """
167 }
168 }
169
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700170 stage('install/test rcord-lite') {
Zack Williams9d68aa32018-07-12 11:50:37 -0700171 steps {
172 sh """
173 #!/usr/bin/env bash
174 set -eu -o pipefail
175
176 helm_install_args='-f examples/api-test-values.yaml'
Zack Williams9d68aa32018-07-12 11:50:37 -0700177
178 pushd cord/helm-charts
179
180 helm dep up xos-core
181 helm install \${helm_install_args} xos-core -n xos-core
182
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700183 helm dep update xos-profiles/rcord-lite
184 helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
Zack Williams9d68aa32018-07-12 11:50:37 -0700185
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700186 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700187 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
Zack Williams9d68aa32018-07-12 11:50:37 -0700188
189 echo "# Checking helm deployments"
190 kubectl get pods
Zack Williams9d68aa32018-07-12 11:50:37 -0700191
192 for hchart in \$(helm list -q);
193 do
194 echo "## 'helm status' for chart: \${hchart} ##"
195 helm status "\${hchart}"
196 done
197
Zack Williams2e515f32018-09-27 23:03:07 -0700198 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
199 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams9d68aa32018-07-12 11:50:37 -0700200
Zack Williamsfd87d652018-07-12 14:21:12 -0700201 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
202 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
203 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
204 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 -0700205
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700206 export testname=_service_api.robot
207 export library=_library.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700208
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700209 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
210 echo \$SERVICES
Zack Williams9d68aa32018-07-12 11:50:37 -0700211
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700212 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 -0700213
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700214 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 -0700215
Zack Williamsfd87d652018-07-12 14:21:12 -0700216 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
217 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 -0700218
Zack Williamsfd87d652018-07-12 14:21:12 -0700219 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
220 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
221 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
222 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
223 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
224 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Zack Williams9d68aa32018-07-12 11:50:37 -0700225
Zack Williamsfd87d652018-07-12 14:21:12 -0700226 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700227 ## Run CORE API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700228 pybot -d Log -T XOSCoreAPITests.robot || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700229 ## Run Rcord-lite services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700230 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 -0700231
232 popd
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700233
234 helm delete --purge rcord-lite
235 helm delete --purge xos-core
Zack Williamsfd87d652018-07-12 14:21:12 -0700236 """
237 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700238 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700239
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700240 stage('install/test mcord') {
Zack Williamsfd87d652018-07-12 14:21:12 -0700241 steps {
242 sh """
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700243 #!/usr/bin/env bash
244 set -eu -o pipefail
Zack Williamsfd87d652018-07-12 14:21:12 -0700245
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700246 helm_install_args='-f examples/api-test-values.yaml'
247
248 pushd cord/helm-charts
249
250 helm dep up xos-core
251 helm install \${helm_install_args} xos-core -n xos-core
252
253 helm dep update xos-profiles/base-openstack
254 helm dep update xos-profiles/mcord
255 helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
256 helm install \${helm_install_args} xos-profiles/mcord -n mcord
257
258 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700259 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700260
261 echo "# Checking helm deployments"
262 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700263
264 for hchart in \$(helm list -q);
265 do
266 echo "## 'helm status' for chart: \${hchart} ##"
267 helm status "\${hchart}"
268 done
269
Zack Williams2e515f32018-09-27 23:03:07 -0700270 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
271 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700272
273 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
274 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
275 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
276 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
277
278 export testname=_service_api.robot
279 export library=_library.robot
280
281 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
282 echo \$SERVICES
283
284 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
285
286 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
287
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700288 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
289 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
290
291 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
292 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
293
294 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
295 ## Run mcord services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700296 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 -0700297
298 popd
299
300 helm delete --purge base-openstack
301 helm delete --purge mcord
302 helm delete --purge xos-core
303 """
Zack Williamsfd87d652018-07-12 14:21:12 -0700304 }
305 }
306
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700307 stage('install/test simpleexampleservice') {
308 steps {
309 sh """
310 #!/usr/bin/env bash
311 set -eu -o pipefail
312
313 helm_install_args='-f examples/api-test-values.yaml'
314
315 pushd cord/helm-charts
316
317 helm dep up xos-core
318 helm install \${helm_install_args} xos-core -n xos-core
319
320 helm dep update xos-profiles/base-kubernetes
321 helm dep update xos-profiles/demo-simpleexampleservice
322 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
323 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
324
325 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700326 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700327
328 echo "# Checking helm deployments"
329 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700330
331 for hchart in \$(helm list -q);
332 do
333 echo "## 'helm status' for chart: \${hchart} ##"
334 helm status "\${hchart}"
335 done
336
Zack Williams2e515f32018-09-27 23:03:07 -0700337 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
338 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700339
340 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
341 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
342 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
343 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
344
Kailash Khalasi09215942018-10-16 09:13:27 -0700345 # run e2e synchronizer test
346 helm test demo-simpleexampleservice
347
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700348 export testname=_service_api.robot
349 export library=_library.robot
350
351 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
352 echo \$SERVICES
353
354 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
355
356 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
357
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700358 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
359 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
360
361 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
362 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
363
364 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
365 ## Run kubernetes-base services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700366 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 -0700367
368 popd
369
370 helm delete --purge base-kubernetes
371 helm delete --purge demo-simpleexampleservice
372 helm delete --purge xos-core
373 """
374 }
375 }
376
377 stage('install/test hippie-oss') {
378 steps {
379 sh """
380 #!/usr/bin/env bash
381 set -eu -o pipefail
382
383 helm_install_args='-f examples/api-test-values.yaml'
384
385 pushd cord/helm-charts
386
387 helm dep up xos-core
388 helm install \${helm_install_args} xos-core -n xos-core
389
390 helm dep update xos-services/hippie-oss
391 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
392
393 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700394 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
395
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700396 echo "# Checking helm deployments"
397 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700398
399 for hchart in \$(helm list -q);
400 do
401 echo "## 'helm status' for chart: \${hchart} ##"
402 helm status "\${hchart}"
403 done
404
Zack Williams2e515f32018-09-27 23:03:07 -0700405 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
406 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700407
408 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
409 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
410 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
411 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
412
413 export testname=_service_api.robot
414 export library=_library.robot
415
416 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
417 echo \$SERVICES
418
419 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
420 ## Run hippie-oss services API Tests
Kailash Khalasi07c97a42018-08-06 12:15:43 -0700421 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 -0700422
423 popd
424
425 helm delete --purge hippie-oss
426 helm delete --purge xos-core
427 """
428 }
429 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700430 }
431 post {
432 always {
433 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700434 # copy robot logs
435 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
436 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700437
Kailash Khalasi09215942018-10-16 09:13:27 -0700438 #copy helm test robot logs
439 cp -r /tmp/*ml ./RobotLogs
440
Zack Williamsfd87d652018-07-12 14:21:12 -0700441 kubectl get pods --all-namespaces
442
443 echo "# removing helm deployments"
Zack Williamsfd87d652018-07-12 14:21:12 -0700444 for hchart in \$(helm list -q);
445 do
446 echo "## Purging chart: \${hchart} ##"
447 helm delete --purge "\${hchart}"
448 done
449
Zack Williamsf8b356c2018-07-17 17:01:27 -0700450 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700451 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700452 step([$class: 'RobotPublisher',
453 disableArchiveOutput: false,
454 logFileName: 'RobotLogs/log*.html',
455 otherFiles: '',
456 outputFileName: 'RobotLogs/output*.xml',
457 outputPath: '.',
458 passThreshold: 100,
459 reportFileName: 'RobotLogs/report*.html',
460 unstableThreshold: 0]);
461 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700462 }
463 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700464}