blob: 17f69150a5414511289a3ce8390055bcbca3905e [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
Luca Prete2ae90132018-12-13 17:14:01 -080088
89 git clone https://gerrit.opencord.org/helm-repo-tools
90 ./helm-repo-tools/wait_for_pods.sh
Zack Williamsa26fc9d2018-09-18 16:49:01 -070091
92 popd
93 '''
94 }
95 }
96
Zack Williams91cecd22018-09-26 10:59:44 -070097 stage('install/test att-workflow') {
Zack Williams2e515f32018-09-27 23:03:07 -070098 when {
99 expression {
100 params.manifestBranch ==~ 'master'
101 }
102 }
Zack Williams91cecd22018-09-26 10:59:44 -0700103 steps {
104 sh """
105 #!/usr/bin/env bash
106 set -eu -o pipefail
107
108 helm_install_args='-f examples/api-test-values.yaml'
109
110 pushd cord/helm-charts
111
112 helm dep up xos-core
113 helm install \${helm_install_args} xos-core -n xos-core
114
Kailashdddff082018-12-14 11:05:47 -0800115 helm dep update xos-profiles/seba-services
Kailash831b7ce2018-12-14 15:47:22 -0800116 helm install \${helm_install_args} xos-profiles/seba-services -n seba-services
Kailashdddff082018-12-14 11:05:47 -0800117 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
Kailash Khalasi28323552018-12-13 15:03:22 -0800118 helm dep update workflows/att-workflow
119 helm install \${helm_install_args} workflows/att-workflow -n att-workflow
Zack Williams91cecd22018-09-26 10:59:44 -0700120
121 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800122 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams91cecd22018-09-26 10:59:44 -0700123
124 echo "# Checking helm deployments"
125 kubectl get pods
126
127 for hchart in \$(helm list -q);
128 do
129 echo "## 'helm status' for chart: \${hchart} ##"
130 helm status "\${hchart}"
131 done
132
Zack Williams2e515f32018-09-27 23:03:07 -0700133 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
134 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams91cecd22018-09-26 10:59:44 -0700135
136 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
137 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
138 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
139 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
140
141 export testname=_service_api.robot
142 export library=_library.robot
143
144 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
145 echo \$SERVICES
146
147 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
148
149 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
150
Zack Williams91cecd22018-09-26 10:59:44 -0700151 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
152 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
153
154 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
155 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
156 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
157 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
158 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
159 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
160
Kailashf7106c32018-12-12 10:08:20 -0800161 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"
162
Zack Williams91cecd22018-09-26 10:59:44 -0700163 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
164 ## Run CORE API Tests
Kailashf14606e2018-12-06 14:11:11 -0800165 robot -d Log -T XOSCoreAPITests.robot || true
Zack Williams91cecd22018-09-26 10:59:44 -0700166 ## Run services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800167 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 -0700168
169 popd
170
171 helm delete --purge att-workflow
172 helm delete --purge xos-core
Kailash831b7ce2018-12-14 15:47:22 -0800173 helm delete --purge seba-services
Zack Williams91cecd22018-09-26 10:59:44 -0700174 """
175 }
176 }
177
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700178 stage('install/test rcord-lite') {
Zack Williams9d68aa32018-07-12 11:50:37 -0700179 steps {
180 sh """
181 #!/usr/bin/env bash
182 set -eu -o pipefail
183
184 helm_install_args='-f examples/api-test-values.yaml'
Zack Williams9d68aa32018-07-12 11:50:37 -0700185
186 pushd cord/helm-charts
187
188 helm dep up xos-core
189 helm install \${helm_install_args} xos-core -n xos-core
190
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700191 helm dep update xos-profiles/rcord-lite
192 helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
Zack Williams9d68aa32018-07-12 11:50:37 -0700193
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700194 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800195 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams9d68aa32018-07-12 11:50:37 -0700196
197 echo "# Checking helm deployments"
198 kubectl get pods
Zack Williams9d68aa32018-07-12 11:50:37 -0700199
200 for hchart in \$(helm list -q);
201 do
202 echo "## 'helm status' for chart: \${hchart} ##"
203 helm status "\${hchart}"
204 done
205
Zack Williams2e515f32018-09-27 23:03:07 -0700206 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
207 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams9d68aa32018-07-12 11:50:37 -0700208
Zack Williamsfd87d652018-07-12 14:21:12 -0700209 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
210 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
211 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
212 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 -0700213
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700214 export testname=_service_api.robot
215 export library=_library.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700216
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700217 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
218 echo \$SERVICES
Zack Williams9d68aa32018-07-12 11:50:37 -0700219
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700220 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 -0700221
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700222 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 -0700223
Zack Williamsfd87d652018-07-12 14:21:12 -0700224 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
225 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 -0700226
Zack Williamsfd87d652018-07-12 14:21:12 -0700227 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
228 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
229 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
230 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
231 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
232 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800233 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 -0700234
Zack Williamsfd87d652018-07-12 14:21:12 -0700235 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700236 ## Run CORE API Tests
Kailashf14606e2018-12-06 14:11:11 -0800237 robot -d Log -T XOSCoreAPITests.robot || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700238 ## Run Rcord-lite services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800239 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 -0700240
241 popd
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700242
243 helm delete --purge rcord-lite
244 helm delete --purge xos-core
Zack Williamsfd87d652018-07-12 14:21:12 -0700245 """
246 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700247 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700248
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700249 stage('install/test simpleexampleservice') {
250 steps {
251 sh """
252 #!/usr/bin/env bash
253 set -eu -o pipefail
254
255 helm_install_args='-f examples/api-test-values.yaml'
256
257 pushd cord/helm-charts
258
259 helm dep up xos-core
260 helm install \${helm_install_args} xos-core -n xos-core
261
262 helm dep update xos-profiles/base-kubernetes
263 helm dep update xos-profiles/demo-simpleexampleservice
264 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
265 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
266
267 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800268 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700269
270 echo "# Checking helm deployments"
271 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700272
273 for hchart in \$(helm list -q);
274 do
275 echo "## 'helm status' for chart: \${hchart} ##"
276 helm status "\${hchart}"
277 done
278
Zack Williams2e515f32018-09-27 23:03:07 -0700279 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
280 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700281
282 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
283 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
284 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
285 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
286
287 export testname=_service_api.robot
288 export library=_library.robot
289
290 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
291 echo \$SERVICES
292
293 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
294
295 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
296
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700297 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
298 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
299
300 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
301 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800302 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
303 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
304 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
305 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
306 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 -0700307
Kailashe2a3bfb2018-12-12 14:12:15 -0800308
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700309 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
310 ## Run kubernetes-base services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800311 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 -0700312
313 popd
314
315 helm delete --purge base-kubernetes
316 helm delete --purge demo-simpleexampleservice
317 helm delete --purge xos-core
318 """
319 }
320 }
321
322 stage('install/test hippie-oss') {
323 steps {
324 sh """
325 #!/usr/bin/env bash
326 set -eu -o pipefail
327
328 helm_install_args='-f examples/api-test-values.yaml'
329
330 pushd cord/helm-charts
331
332 helm dep up xos-core
333 helm install \${helm_install_args} xos-core -n xos-core
334
335 helm dep update xos-services/hippie-oss
336 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
Kailash Khalasi4859b3d2018-12-15 20:09:16 -0800337 sleep 300
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700338
339 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800340 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams91cecd22018-09-26 10:59:44 -0700341
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700342 echo "# Checking helm deployments"
343 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700344
345 for hchart in \$(helm list -q);
346 do
347 echo "## 'helm status' for chart: \${hchart} ##"
348 helm status "\${hchart}"
349 done
350
Zack Williams2e515f32018-09-27 23:03:07 -0700351 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
352 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700353
354 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
355 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
356 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
357 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
358
359 export testname=_service_api.robot
360 export library=_library.robot
361
362 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
363 echo \$SERVICES
364
Kailashe2a3bfb2018-12-12 14:12:15 -0800365 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
366
367 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
368
369 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
370 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
371
Kailashf7106c32018-12-12 10:08:20 -0800372 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
373 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
374 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
375 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
376 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
377 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
378 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"
379
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700380 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
381 ## Run hippie-oss services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800382 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 -0700383
384 popd
385
386 helm delete --purge hippie-oss
387 helm delete --purge xos-core
388 """
389 }
390 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700391 }
392 post {
393 always {
394 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700395 # copy robot logs
396 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
397 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700398
Zack Williamsfd87d652018-07-12 14:21:12 -0700399 kubectl get pods --all-namespaces
400
401 echo "# removing helm deployments"
Zack Williamsfd87d652018-07-12 14:21:12 -0700402 for hchart in \$(helm list -q);
403 do
404 echo "## Purging chart: \${hchart} ##"
405 helm delete --purge "\${hchart}"
406 done
407
Zack Williamsf8b356c2018-07-17 17:01:27 -0700408 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700409 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700410 step([$class: 'RobotPublisher',
411 disableArchiveOutput: false,
412 logFileName: 'RobotLogs/log*.html',
413 otherFiles: '',
414 outputFileName: 'RobotLogs/output*.xml',
415 outputPath: '.',
416 passThreshold: 100,
417 reportFileName: 'RobotLogs/report*.html',
418 unstableThreshold: 0]);
419 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700420 }
421 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700422}
Kailasheedd9ee2019-01-28 17:59:35 -0800423