blob: c76dfec386cdeaa9ddd677476691c20f0cf2da4b [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
Kailashf7106c32018-12-12 10:08:20 -0800156 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"
157
Zack Williams91cecd22018-09-26 10:59:44 -0700158 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
159 ## Run CORE API Tests
Kailashf14606e2018-12-06 14:11:11 -0800160 robot -d Log -T XOSCoreAPITests.robot || true
Zack Williams91cecd22018-09-26 10:59:44 -0700161 ## Run services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800162 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 -0700163
164 popd
165
166 helm delete --purge att-workflow
167 helm delete --purge xos-core
168 """
169 }
170 }
171
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700172 stage('install/test rcord-lite') {
Zack Williams9d68aa32018-07-12 11:50:37 -0700173 steps {
174 sh """
175 #!/usr/bin/env bash
176 set -eu -o pipefail
177
178 helm_install_args='-f examples/api-test-values.yaml'
Zack Williams9d68aa32018-07-12 11:50:37 -0700179
180 pushd cord/helm-charts
181
182 helm dep up xos-core
183 helm install \${helm_install_args} xos-core -n xos-core
184
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700185 helm dep update xos-profiles/rcord-lite
186 helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite
Zack Williams9d68aa32018-07-12 11:50:37 -0700187
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700188 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700189 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
Zack Williams9d68aa32018-07-12 11:50:37 -0700190
191 echo "# Checking helm deployments"
192 kubectl get pods
Zack Williams9d68aa32018-07-12 11:50:37 -0700193
194 for hchart in \$(helm list -q);
195 do
196 echo "## 'helm status' for chart: \${hchart} ##"
197 helm status "\${hchart}"
198 done
199
Zack Williams2e515f32018-09-27 23:03:07 -0700200 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
201 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Zack Williams9d68aa32018-07-12 11:50:37 -0700202
Zack Williamsfd87d652018-07-12 14:21:12 -0700203 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
204 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
205 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
206 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 -0700207
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700208 export testname=_service_api.robot
209 export library=_library.robot
Zack Williams9d68aa32018-07-12 11:50:37 -0700210
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700211 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
212 echo \$SERVICES
Zack Williams9d68aa32018-07-12 11:50:37 -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/./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 -0700215
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700216 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 -0700217
Zack Williamsfd87d652018-07-12 14:21:12 -0700218 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
219 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 -0700220
Zack Williamsfd87d652018-07-12 14:21:12 -0700221 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
222 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
223 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
224 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
225 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
226 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800227 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 -0700228
Zack Williamsfd87d652018-07-12 14:21:12 -0700229 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700230 ## Run CORE API Tests
Kailashf14606e2018-12-06 14:11:11 -0800231 robot -d Log -T XOSCoreAPITests.robot || true
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700232 ## Run Rcord-lite services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800233 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 -0700234
235 popd
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700236
237 helm delete --purge rcord-lite
238 helm delete --purge xos-core
Zack Williamsfd87d652018-07-12 14:21:12 -0700239 """
240 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700241 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700242
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700243 stage('install/test mcord') {
Zack Williamsfd87d652018-07-12 14:21:12 -0700244 steps {
245 sh """
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700246 #!/usr/bin/env bash
247 set -eu -o pipefail
Zack Williamsfd87d652018-07-12 14:21:12 -0700248
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700249 helm_install_args='-f examples/api-test-values.yaml'
250
251 pushd cord/helm-charts
252
253 helm dep up xos-core
254 helm install \${helm_install_args} xos-core -n xos-core
255
256 helm dep update xos-profiles/base-openstack
257 helm dep update xos-profiles/mcord
258 helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack
259 helm install \${helm_install_args} xos-profiles/mcord -n mcord
260
261 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700262 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700263
264 echo "# Checking helm deployments"
265 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700266
267 for hchart in \$(helm list -q);
268 do
269 echo "## 'helm status' for chart: \${hchart} ##"
270 helm status "\${hchart}"
271 done
272
Zack Williams2e515f32018-09-27 23:03:07 -0700273 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
274 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700275
276 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
277 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
278 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
279 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
280
281 export testname=_service_api.robot
282 export library=_library.robot
283
284 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
285 echo \$SERVICES
286
287 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
288
289 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
290
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700291 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
292 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
293
294 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
295 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800296 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
297 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
298 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
299 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
300 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 -0700301
302 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
303 ## Run mcord services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800304 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 -0700305
306 popd
307
308 helm delete --purge base-openstack
309 helm delete --purge mcord
310 helm delete --purge xos-core
311 """
Zack Williamsfd87d652018-07-12 14:21:12 -0700312 }
313 }
314
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700315 stage('install/test simpleexampleservice') {
316 steps {
317 sh """
318 #!/usr/bin/env bash
319 set -eu -o pipefail
320
321 helm_install_args='-f examples/api-test-values.yaml'
322
323 pushd cord/helm-charts
324
325 helm dep up xos-core
326 helm install \${helm_install_args} xos-core -n xos-core
327
328 helm dep update xos-profiles/base-kubernetes
329 helm dep update xos-profiles/demo-simpleexampleservice
330 helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes
331 helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice
332
333 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700334 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700335
336 echo "# Checking helm deployments"
337 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700338
339 for hchart in \$(helm list -q);
340 do
341 echo "## 'helm status' for chart: \${hchart} ##"
342 helm status "\${hchart}"
343 done
344
Zack Williams2e515f32018-09-27 23:03:07 -0700345 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
346 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700347
348 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
349 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
350 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
351 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
352
Kailash Khalasi09215942018-10-16 09:13:27 -0700353 # run e2e synchronizer test
354 helm test demo-simpleexampleservice
355
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700356 export testname=_service_api.robot
357 export library=_library.robot
358
359 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
360 echo \$SERVICES
361
362 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
363
364 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
365
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700366 CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
367 XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
368
Kailashf7106c32018-12-12 10:08:20 -0800369
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700370 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
371 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
Kailashf7106c32018-12-12 10:08:20 -0800372 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
373 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
374 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
375 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
376 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 -0700377
378 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
379 ## Run kubernetes-base services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800380 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 -0700381
382 popd
383
384 helm delete --purge base-kubernetes
385 helm delete --purge demo-simpleexampleservice
386 helm delete --purge xos-core
387 """
388 }
389 }
390
391 stage('install/test hippie-oss') {
392 steps {
393 sh """
394 #!/usr/bin/env bash
395 set -eu -o pipefail
396
397 helm_install_args='-f examples/api-test-values.yaml'
398
399 pushd cord/helm-charts
400
401 helm dep up xos-core
402 helm install \${helm_install_args} xos-core -n xos-core
403
404 helm dep update xos-services/hippie-oss
405 helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss
406
407 # wait for services to load
Zack Williams91cecd22018-09-26 10:59:44 -0700408 PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh
409
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700410 echo "# Checking helm deployments"
411 kubectl get pods
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700412
413 for hchart in \$(helm list -q);
414 do
415 echo "## 'helm status' for chart: \${hchart} ##"
416 helm status "\${hchart}"
417 done
418
Zack Williams2e515f32018-09-27 23:03:07 -0700419 CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}')
420 CORE_CONTAINER=\$(docker ps | grep k8s_xos-core_\${CORE_POD} | awk '{print \$1}')
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700421
422 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
423 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
424 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
425 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
426
427 export testname=_service_api.robot
428 export library=_library.robot
429
430 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
431 echo \$SERVICES
432
Kailashf7106c32018-12-12 10:08:20 -0800433 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
434 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
435 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
436 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
437 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
438 sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
439 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"
440
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700441 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailashf7106c32018-12-12 10:08:20 -0800442
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700443 ## Run hippie-oss services API Tests
Kailashf14606e2018-12-06 14:11:11 -0800444 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 -0700445
446 popd
447
448 helm delete --purge hippie-oss
449 helm delete --purge xos-core
450 """
451 }
452 }
Zack Williamsfd87d652018-07-12 14:21:12 -0700453 }
454 post {
455 always {
456 sh '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700457 # copy robot logs
458 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
459 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasiecb4eb62018-07-31 15:20:19 -0700460
Zack Williamsfd87d652018-07-12 14:21:12 -0700461 kubectl get pods --all-namespaces
462
463 echo "# removing helm deployments"
Zack Williamsfd87d652018-07-12 14:21:12 -0700464 for hchart in \$(helm list -q);
465 do
466 echo "## Purging chart: \${hchart} ##"
467 helm delete --purge "\${hchart}"
468 done
469
Zack Williamsf8b356c2018-07-17 17:01:27 -0700470 sudo minikube delete
Zack Williamsfd87d652018-07-12 14:21:12 -0700471 '''
Kailash Khalasi1c773ed2018-08-01 10:47:59 -0700472 step([$class: 'RobotPublisher',
473 disableArchiveOutput: false,
474 logFileName: 'RobotLogs/log*.html',
475 otherFiles: '',
476 outputFileName: 'RobotLogs/output*.xml',
477 outputPath: '.',
478 passThreshold: 100,
479 reportFileName: 'RobotLogs/report*.html',
480 unstableThreshold: 0]);
481 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Zack Williamsfd87d652018-07-12 14:21:12 -0700482 }
483 }
Zack Williams9d68aa32018-07-12 11:50:37 -0700484}