blob: fea6a52fc5ddbd984cdf26d91c5cf437e3e8d640 [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 mcord') {
Zack Williamsfd87d652018-07-12 14:21:12 -0700250 steps {
251 sh """
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700252 #!/usr/bin/env bash
253 set -eu -o pipefail
Zack Williamsfd87d652018-07-12 14:21:12 -0700254
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700255 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-openstack
263 helm dep update xos-profiles/mcord
264 helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
265 helm install \${helm_install_args} xos-profiles/mcord -n mcord
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
308 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
309 ## Run mcord services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800310 for i in \$SERVICES; do bash -c "robot -d Log -T -e ProgranServiceInstance -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-openstack
315 helm delete --purge mcord
316 helm delete --purge xos-core
317 """
Zack Williamsfd87d652018-07-12 14:21:12 -0700318 }
319 }
320
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700321 stage('install/test simpleexampleservice') {
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-profiles/base-kubernetes
335 helm dep update xos-profiles/demo-simpleexampleservice
336 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
337 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
338
339 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800340 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700341
342 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
365 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
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700369 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
372 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
373 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800374 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"
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700379
Kailashe2a3bfb2018-12-12 14:12:15 -0800380 # run e2e synchronizer test
381 helm test demo-simpleexampleservice
382
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700383 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
384 ## Run kubernetes-base services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800385 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 -0700386
387 popd
388
389 helm delete --purge base-kubernetes
390 helm delete --purge demo-simpleexampleservice
391 helm delete --purge xos-core
392 """
393 }
394 }
395
396 stage('install/test hippie-oss') {
397 steps {
398 sh """
399 #!/usr/bin/env bash
400 set -eu -o pipefail
401
402 helm_install_args='-f examples/api-test-values.yaml'
403
404 pushd cord/helm-charts
405
406 helm dep up xos-core
407 helm install \${helm_install_args} xos-core -n xos-core
408
409 helm dep update xos-services/hippie-oss
410 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
Kailash Khalasi4859b3d2018-12-15 20:09:16 -0800411 sleep 300
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700412
413 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800414 PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh
Zack Williams91cecd22018-09-26 10:59:44 -0700415
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700416 echo "# Checking helm deployments"
417 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700418
419 for hchart in \$(helm list -q);
420 do
421 echo "## 'helm status' for chart: \${hchart} ##"
422 helm status "\${hchart}"
423 done
424
Zack Williams2e515f32018-09-27 23:03:07 -0700425 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
426 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700427
428 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
429 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
430 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
431 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
432
433 export testname=_service_api.robot
434 export library=_library.robot
435
436 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
437 echo \$SERVICES
438
Kailashe2a3bfb2018-12-12 14:12:15 -0800439 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
440
441 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
442
443 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
444 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
445
Kailashf7106c32018-12-12 10:08:20 -0800446 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
447 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
448 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
449 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
450 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
451 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
452 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"
453
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700454 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
455 ## Run hippie-oss services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800456 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 -0700457
458 popd
459
460 helm delete --purge hippie-oss
461 helm delete --purge xos-core
462 """
463 }
464 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700465 }
466 post {
467 always {
468 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700469 # copy robot logs
470 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
471 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasi4859b3d2018-12-15 20:09:16 -0800472 cp -r /tmp/helm_test_demo-simpleexampleservice*/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700473
Zack Williamsfd87d652018-07-12 14:21:12 -0700474 kubectl get pods --all-namespaces
475
476 echo "# removing helm deployments"
Zack Williamsfd87d652018-07-12 14:21:12 -0700477 for hchart in \$(helm list -q);
478 do
479 echo "## Purging chart: \${hchart} ##"
480 helm delete --purge "\${hchart}"
481 done
482
Zack Williamsf8b356c2018-07-17 17:01:27 -0700483 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700484 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700485 step([$class: 'RobotPublisher',
486 disableArchiveOutput: false,
487 logFileName: 'RobotLogs/log*.html',
488 otherFiles: '',
489 outputFileName: 'RobotLogs/output*.xml',
490 outputPath: '.',
491 passThreshold: 100,
492 reportFileName: 'RobotLogs/report*.html',
493 unstableThreshold: 0]);
494 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700495 }
496 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700497}