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 { |
| 22 | label "${params.executorNode}" |
| 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 | |
| 89 | git clone https://gerrit.opencord.org/helm-repo-tools |
| 90 | ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 91 | |
| 92 | popd |
| 93 | ''' |
| 94 | } |
| 95 | } |
| 96 | |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 97 | stage('install/test att-workflow') { |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 98 | when { |
| 99 | expression { |
| 100 | params.manifestBranch ==~ 'master' |
| 101 | } |
| 102 | } |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 103 | 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 | |
Kailash | dddff08 | 2018-12-14 11:05:47 -0800 | [diff] [blame] | 115 | helm dep update xos-profiles/seba-services |
Kailash | 831b7ce | 2018-12-14 15:47:22 -0800 | [diff] [blame] | 116 | helm install \${helm_install_args} xos-profiles/seba-services -n seba-services |
Kailash | dddff08 | 2018-12-14 11:05:47 -0800 | [diff] [blame] | 117 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
Kailash Khalasi | 2832355 | 2018-12-13 15:03:22 -0800 | [diff] [blame] | 118 | helm dep update workflows/att-workflow |
| 119 | helm install \${helm_install_args} workflows/att-workflow -n att-workflow |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 120 | |
| 121 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 122 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 123 | |
| 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 Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 133 | 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 135 | |
| 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 151 | 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 | |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 161 | 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 163 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 164 | ## Run CORE API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 165 | robot -d Log -T XOSCoreAPITests.robot || true |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 166 | ## Run services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 167 | 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] | 168 | |
| 169 | popd |
| 170 | |
| 171 | helm delete --purge att-workflow |
| 172 | helm delete --purge xos-core |
Kailash | 831b7ce | 2018-12-14 15:47:22 -0800 | [diff] [blame] | 173 | helm delete --purge seba-services |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 174 | """ |
| 175 | } |
| 176 | } |
| 177 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 178 | stage('install/test rcord-lite') { |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 179 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 185 | |
| 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 191 | helm dep update xos-profiles/rcord-lite |
| 192 | helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 193 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 194 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 195 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 196 | |
| 197 | echo "# Checking helm deployments" |
| 198 | kubectl get pods |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 199 | |
| 200 | for hchart in \$(helm list -q); |
| 201 | do |
| 202 | echo "## 'helm status' for chart: \${hchart} ##" |
| 203 | helm status "\${hchart}" |
| 204 | done |
| 205 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 206 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 208 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 209 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 213 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 214 | export testname=_service_api.robot |
| 215 | export library=_library.robot |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 216 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 217 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 219 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 220 | 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] | 221 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 222 | 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] | 223 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 224 | 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 Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 226 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 227 | 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 |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 233 | 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] | 234 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 235 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 236 | ## Run CORE API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 237 | robot -d Log -T XOSCoreAPITests.robot || true |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 238 | ## Run Rcord-lite services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 239 | 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] | 240 | |
| 241 | popd |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 242 | |
| 243 | helm delete --purge rcord-lite |
| 244 | helm delete --purge xos-core |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 245 | """ |
| 246 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 247 | } |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 248 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 249 | stage('install/test mcord') { |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 250 | steps { |
| 251 | sh """ |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 252 | #!/usr/bin/env bash |
| 253 | set -eu -o pipefail |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 254 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 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-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 Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 268 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 269 | |
| 270 | echo "# Checking helm deployments" |
| 271 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 272 | |
| 273 | for hchart in \$(helm list -q); |
| 274 | do |
| 275 | echo "## 'helm status' for chart: \${hchart} ##" |
| 276 | helm status "\${hchart}" |
| 277 | done |
| 278 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 279 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 281 | |
| 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 297 | 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 |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 302 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 307 | |
| 308 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 309 | ## Run mcord 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 -e ProgranServiceInstance -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-openstack |
| 315 | helm delete --purge mcord |
| 316 | helm delete --purge xos-core |
| 317 | """ |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 321 | 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 Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 340 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 341 | |
| 342 | echo "# Checking helm deployments" |
| 343 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 344 | |
| 345 | for hchart in \$(helm list -q); |
| 346 | do |
| 347 | echo "## 'helm status' for chart: \${hchart} ##" |
| 348 | helm status "\${hchart}" |
| 349 | done |
| 350 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 351 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 353 | |
| 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 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 | |
| 372 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 373 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 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" |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 379 | |
Kailash | e2a3bfb | 2018-12-12 14:12:15 -0800 | [diff] [blame] | 380 | # run e2e synchronizer test |
| 381 | helm test demo-simpleexampleservice |
| 382 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 383 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 384 | ## Run kubernetes-base services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 385 | 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] | 386 | |
| 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 Khalasi | 4859b3d | 2018-12-15 20:09:16 -0800 | [diff] [blame] | 411 | sleep 300 |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 412 | |
| 413 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 414 | PODS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 415 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 416 | echo "# Checking helm deployments" |
| 417 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 418 | |
| 419 | for hchart in \$(helm list -q); |
| 420 | do |
| 421 | echo "## 'helm status' for chart: \${hchart} ##" |
| 422 | helm status "\${hchart}" |
| 423 | done |
| 424 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 425 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 427 | |
| 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 | |
Kailash | e2a3bfb | 2018-12-12 14:12:15 -0800 | [diff] [blame] | 439 | 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 | |
Kailash | f7106c3 | 2018-12-12 10:08:20 -0800 | [diff] [blame] | 446 | 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 Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 454 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 455 | ## Run hippie-oss services API Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 456 | 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] | 457 | |
| 458 | popd |
| 459 | |
| 460 | helm delete --purge hippie-oss |
| 461 | helm delete --purge xos-core |
| 462 | """ |
| 463 | } |
| 464 | } |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 465 | } |
| 466 | post { |
| 467 | always { |
| 468 | sh ''' |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 469 | # 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 Khalasi | 4859b3d | 2018-12-15 20:09:16 -0800 | [diff] [blame] | 472 | cp -r /tmp/helm_test_demo-simpleexampleservice*/*ml ./RobotLogs |
Kailash Khalasi | ecb4eb6 | 2018-07-31 15:20:19 -0700 | [diff] [blame] | 473 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 474 | kubectl get pods --all-namespaces |
| 475 | |
| 476 | echo "# removing helm deployments" |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 477 | for hchart in \$(helm list -q); |
| 478 | do |
| 479 | echo "## Purging chart: \${hchart} ##" |
| 480 | helm delete --purge "\${hchart}" |
| 481 | done |
| 482 | |
Zack Williams | f8b356c | 2018-07-17 17:01:27 -0700 | [diff] [blame] | 483 | sudo minikube delete |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 484 | ''' |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 485 | 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 Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 495 | } |
| 496 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 497 | } |