blob: abb5e68e5217f2c7831e88576a357ada33b46225 [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 {
Zack Williamsb3292082019-10-11 17:15:18 -070022 label "${params.buildNode}"
Zack Williamsfd87d652018-07-12 14:21:12 -070023 }
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
Luca Prete2ae90132018-12-13 17:14:01 -080088
Luca Prete2ae90132018-12-13 17:14:01 -080089 ./helm-repo-tools/wait_for_pods.sh
Zack Williamsa26fc9d2018-09-18 16:49:01 -070090
91 popd
92 '''
93 }
94 }
95
Zack Williams91cecd22018-09-26 10:59:44 -070096 stage('install/test att-workflow') {
Zack Williams2e515f32018-09-27 23:03:07 -070097 when {
98 expression {
99 params.manifestBranch ==~ 'master'
100 }
101 }
Zack Williams91cecd22018-09-26 10:59:44 -0700102 steps {
103 sh """
104 #!/usr/bin/env bash
105 set -eu -o pipefail
106
107 helm_install_args='-f examples/api-test-values.yaml'
108
109 pushd cord/helm-charts
110
111 helm dep up xos-core
112 helm install \${helm_install_args} xos-core -n xos-core
113
Kailashdddff082018-12-14 11:05:47 -0800114 helm dep update xos-profiles/seba-services
Kailash831b7ce2018-12-14 15:47:22 -0800115 helm install \${helm_install_args} xos-profiles/seba-services -n seba-services
Kailashdddff082018-12-14 11:05:47 -0800116 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
Kailash Khalasi28323552018-12-13 15:03:22 -0800117 helm dep update workflows/att-workflow
118 helm install \${helm_install_args} workflows/att-workflow -n att-workflow
Zack Williams91cecd22018-09-26 10:59:44 -0700119
120 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800121 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams91cecd22018-09-26 10:59:44 -0700122
123 echo "# Checking helm deployments"
124 kubectl get pods
125
126 for hchart in \$(helm list -q);
127 do
128 echo "## 'helm status' for chart: \${hchart} ##"
129 helm status "\${hchart}"
130 done
131
Zack Williams2e515f32018-09-27 23:03:07 -0700132 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
133 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams91cecd22018-09-26 10:59:44 -0700134
135 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
136 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
137 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
138 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
139
140 export testname=_service_api.robot
141 export library=_library.robot
142
143 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
144 echo \$SERVICES
145
146 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
147
148 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
149
Zack Williams91cecd22018-09-26 10:59:44 -0700150 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
151 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
152
153 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
154 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
155 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
156 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
157 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
158 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
159
Kailashf7106c32018-12-12 10:08:20 -0800160 timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://'\$XOS_CHAMELEON\':9101/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
161
Zack Williams91cecd22018-09-26 10:59:44 -0700162 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
163 ## Run CORE API Tests
Kailashf14606e2018-12-06 14:11:11 -0800164 robot -d Log -T XOSCoreAPITests.robot || true
Zack Williams91cecd22018-09-26 10:59:44 -0700165 ## Run services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800166 for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Zack Williams91cecd22018-09-26 10:59:44 -0700167
168 popd
169
170 helm delete --purge att-workflow
171 helm delete --purge xos-core
Kailash831b7ce2018-12-14 15:47:22 -0800172 helm delete --purge seba-services
Zack Williams91cecd22018-09-26 10:59:44 -0700173 """
174 }
175 }
176
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700177 stage('install/test rcord-lite') {
Zack Williams9d68aa32018-07-12 11:50:37 -0700178 steps {
179 sh """
180 #!/usr/bin/env bash
181 set -eu -o pipefail
182
183 helm_install_args='-f examples/api-test-values.yaml'
Zack Williams9d68aa32018-07-12 11:50:37 -0700184
185 pushd cord/helm-charts
186
187 helm dep up xos-core
188 helm install \${helm_install_args} xos-core -n xos-core
189
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700190 helm dep update xos-profiles/rcord-lite
191 helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
Zack Williams9d68aa32018-07-12 11:50:37 -0700192
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700193 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800194 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams9d68aa32018-07-12 11:50:37 -0700195
196 echo "# Checking helm deployments"
197 kubectl get pods
Zack Williams9d68aa32018-07-12 11:50:37 -0700198
199 for hchart in \$(helm list -q);
200 do
201 echo "## 'helm status' for chart: \${hchart} ##"
202 helm status "\${hchart}"
203 done
204
Zack Williams2e515f32018-09-27 23:03:07 -0700205 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
206 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams9d68aa32018-07-12 11:50:37 -0700207
Zack Williamsfd87d652018-07-12 14:21:12 -0700208 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
209 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
210 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
211 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 -0700212
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700213 export testname=_service_api.robot
214 export library=_library.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700215
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700216 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
217 echo \$SERVICES
Zack Williams9d68aa32018-07-12 11:50:37 -0700218
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700219 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 -0700220
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700221 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 -0700222
Zack Williamsfd87d652018-07-12 14:21:12 -0700223 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
224 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 -0700225
Zack Williamsfd87d652018-07-12 14:21:12 -0700226 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
227 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
228 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
229 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
230 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
231 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800232 timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://'\$XOS_CHAMELEON\':9101/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
Zack Williams9d68aa32018-07-12 11:50:37 -0700233
Zack Williamsfd87d652018-07-12 14:21:12 -0700234 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700235 ## Run CORE API Tests
Kailashf14606e2018-12-06 14:11:11 -0800236 robot -d Log -T XOSCoreAPITests.robot || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700237 ## Run Rcord-lite services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800238 for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Zack Williamsfd87d652018-07-12 14:21:12 -0700239
240 popd
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700241
242 helm delete --purge rcord-lite
243 helm delete --purge xos-core
Zack Williamsfd87d652018-07-12 14:21:12 -0700244 """
245 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700246 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700247
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700248 stage('install/test simpleexampleservice') {
249 steps {
250 sh """
251 #!/usr/bin/env bash
252 set -eu -o pipefail
253
254 helm_install_args='-f examples/api-test-values.yaml'
255
256 pushd cord/helm-charts
257
258 helm dep up xos-core
259 helm install \${helm_install_args} xos-core -n xos-core
260
261 helm dep update xos-profiles/base-kubernetes
262 helm dep update xos-profiles/demo-simpleexampleservice
263 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
264 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
265
266 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800267 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700268
269 echo "# Checking helm deployments"
270 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700271
272 for hchart in \$(helm list -q);
273 do
274 echo "## 'helm status' for chart: \${hchart} ##"
275 helm status "\${hchart}"
276 done
277
Zack Williams2e515f32018-09-27 23:03:07 -0700278 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
279 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700280
281 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
282 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
283 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
284 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
285
286 export testname=_service_api.robot
287 export library=_library.robot
288
289 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
290 echo \$SERVICES
291
292 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
293
294 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
295
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700296 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
297 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
298
299 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
300 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800301 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
302 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
303 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
304 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
305 timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://'\$XOS_CHAMELEON\':9101/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700306
Kailashe2a3bfb2018-12-12 14:12:15 -0800307
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700308 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
309 ## Run kubernetes-base services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800310 for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700311
312 popd
313
314 helm delete --purge base-kubernetes
315 helm delete --purge demo-simpleexampleservice
316 helm delete --purge xos-core
317 """
318 }
319 }
320
321 stage('install/test hippie-oss') {
322 steps {
323 sh """
324 #!/usr/bin/env bash
325 set -eu -o pipefail
326
327 helm_install_args='-f examples/api-test-values.yaml'
328
329 pushd cord/helm-charts
330
331 helm dep up xos-core
332 helm install \${helm_install_args} xos-core -n xos-core
333
334 helm dep update xos-services/hippie-oss
335 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
Kailash Khalasi4859b3d2018-12-15 20:09:16 -0800336 sleep 300
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700337
338 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800339 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams91cecd22018-09-26 10:59:44 -0700340
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700341 echo "# Checking helm deployments"
342 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700343
344 for hchart in \$(helm list -q);
345 do
346 echo "## 'helm status' for chart: \${hchart} ##"
347 helm status "\${hchart}"
348 done
349
Zack Williams2e515f32018-09-27 23:03:07 -0700350 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
351 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700352
353 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
354 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
355 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
356 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
357
358 export testname=_service_api.robot
359 export library=_library.robot
360
361 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
362 echo \$SERVICES
363
Kailashe2a3bfb2018-12-12 14:12:15 -0800364 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
365
366 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
367
368 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
369 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
370
Kailashf7106c32018-12-12 10:08:20 -0800371 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
372 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
373 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
374 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
375 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
376 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
377 timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://'\$XOS_CHAMELEON\':9101/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
378
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700379 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
380 ## Run hippie-oss services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800381 for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700382
383 popd
384
385 helm delete --purge hippie-oss
386 helm delete --purge xos-core
387 """
388 }
389 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700390 }
391 post {
392 always {
393 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700394 # copy robot logs
395 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
396 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700397
Zack Williamsfd87d652018-07-12 14:21:12 -0700398 kubectl get pods --all-namespaces
399
400 echo "# removing helm deployments"
Zack Williamsfd87d652018-07-12 14:21:12 -0700401 for hchart in \$(helm list -q);
402 do
403 echo "## Purging chart: \${hchart} ##"
404 helm delete --purge "\${hchart}"
405 done
406
Zack Williamsf8b356c2018-07-17 17:01:27 -0700407 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700408 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700409 step([$class: 'RobotPublisher',
410 disableArchiveOutput: false,
411 logFileName: 'RobotLogs/log*.html',
412 otherFiles: '',
413 outputFileName: 'RobotLogs/output*.xml',
414 outputPath: '.',
415 passThreshold: 100,
416 reportFileName: 'RobotLogs/report*.html',
417 unstableThreshold: 0]);
418 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700419 }
420 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700421}