Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 1 | // 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 18 | pipeline { |
| 19 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 20 | /* no label, executor is determined by JJB */ |
| 21 | agent { |
Zack Williams | b329208 | 2019-10-11 17:15:18 -0700 | [diff] [blame] | 22 | label "${params.buildNode}" |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 23 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 24 | |
| 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 45 | 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 Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 80 | 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 Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 88 | |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 89 | ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 90 | |
| 91 | popd |
| 92 | ''' |
| 93 | } |
| 94 | } |
| 95 | |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 96 | stage('install/test att-workflow') { |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 97 | when { |
| 98 | expression { |
| 99 | params.manifestBranch ==~ 'master' |
| 100 | } |
| 101 | } |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 102 | 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 | |
Kailash | dddff08 | 2018-12-14 11:05:47 -0800 | [diff] [blame] | 114 | helm dep update xos-profiles/seba-services |
Kailash | 831b7ce | 2018-12-14 15:47:22 -0800 | [diff] [blame] | 115 | helm install \${helm_install_args} xos-profiles/seba-services -n seba-services |
Kailash | dddff08 | 2018-12-14 11:05:47 -0800 | [diff] [blame] | 116 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
Kailash Khalasi | 2832355 | 2018-12-13 15:03:22 -0800 | [diff] [blame] | 117 | helm dep update workflows/att-workflow |
| 118 | helm install \${helm_install_args} workflows/att-workflow -n att-workflow |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 119 | |
| 120 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 121 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 122 | |
| 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 Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 132 | 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 134 | |
| 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 150 | 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 | |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 160 | 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 162 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 163 | ## Run CORE API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 164 | robot -d Log -T XOSCoreAPITests.robot || true |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 165 | ## Run services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 166 | for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 167 | |
| 168 | popd |
| 169 | |
| 170 | helm delete --purge att-workflow |
| 171 | helm delete --purge xos-core |
Kailash | 831b7ce | 2018-12-14 15:47:22 -0800 | [diff] [blame] | 172 | helm delete --purge seba-services |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 173 | """ |
| 174 | } |
| 175 | } |
| 176 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 177 | stage('install/test rcord-lite') { |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 178 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 184 | |
| 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 190 | helm dep update xos-profiles/rcord-lite |
| 191 | helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 192 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 193 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 194 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 195 | |
| 196 | echo "# Checking helm deployments" |
| 197 | kubectl get pods |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 198 | |
| 199 | for hchart in \$(helm list -q); |
| 200 | do |
| 201 | echo "## 'helm status' for chart: \${hchart} ##" |
| 202 | helm status "\${hchart}" |
| 203 | done |
| 204 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 205 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 207 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 208 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 212 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 213 | export testname=_service_api.robot |
| 214 | export library=_library.robot |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 215 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 216 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 218 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 219 | 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 Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 220 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 221 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 222 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 223 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 225 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 226 | 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 |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 232 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 233 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 234 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 235 | ## Run CORE API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 236 | robot -d Log -T XOSCoreAPITests.robot || true |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 237 | ## Run Rcord-lite services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 238 | for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 239 | |
| 240 | popd |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 241 | |
| 242 | helm delete --purge rcord-lite |
| 243 | helm delete --purge xos-core |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 244 | """ |
| 245 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 246 | } |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 247 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 248 | 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 Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 267 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 268 | |
| 269 | echo "# Checking helm deployments" |
| 270 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 271 | |
| 272 | for hchart in \$(helm list -q); |
| 273 | do |
| 274 | echo "## 'helm status' for chart: \${hchart} ##" |
| 275 | helm status "\${hchart}" |
| 276 | done |
| 277 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 278 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 280 | |
| 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 296 | 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 |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 301 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 306 | |
Kailash | e2a3bfb | 2018-12-12 14:12:15 -0800 | [diff] [blame] | 307 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 308 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 309 | ## Run kubernetes-base services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 310 | for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 311 | |
| 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 Khalasi | 4859b3d | 2018-12-15 20:09:16 -0800 | [diff] [blame] | 336 | sleep 300 |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 337 | |
| 338 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 339 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 340 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 341 | echo "# Checking helm deployments" |
| 342 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 343 | |
| 344 | for hchart in \$(helm list -q); |
| 345 | do |
| 346 | echo "## 'helm status' for chart: \${hchart} ##" |
| 347 | helm status "\${hchart}" |
| 348 | done |
| 349 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 350 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 352 | |
| 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 | |
Kailash | e2a3bfb | 2018-12-12 14:12:15 -0800 | [diff] [blame] | 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/./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 | |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 371 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 379 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 380 | ## Run hippie-oss services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 381 | for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 382 | |
| 383 | popd |
| 384 | |
| 385 | helm delete --purge hippie-oss |
| 386 | helm delete --purge xos-core |
| 387 | """ |
| 388 | } |
| 389 | } |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 390 | } |
| 391 | post { |
| 392 | always { |
| 393 | sh ''' |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 394 | # 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 Khalasi | ecb4eb6 | 2018-07-31 15:20:19 -0700 | [diff] [blame] | 397 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 398 | kubectl get pods --all-namespaces |
| 399 | |
| 400 | echo "# removing helm deployments" |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 401 | for hchart in \$(helm list -q); |
| 402 | do |
| 403 | echo "## Purging chart: \${hchart} ##" |
| 404 | helm delete --purge "\${hchart}" |
| 405 | done |
| 406 | |
Zack Williams | f8b356c | 2018-07-17 17:01:27 -0700 | [diff] [blame] | 407 | sudo minikube delete |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 408 | ''' |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 409 | 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 Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 419 | } |
| 420 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 421 | } |