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 |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 88 | ./scripts/wait_for_pods.sh |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 89 | |
| 90 | popd |
| 91 | ''' |
| 92 | } |
| 93 | } |
| 94 | |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 95 | stage('install/test att-workflow') { |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 96 | when { |
| 97 | expression { |
| 98 | params.manifestBranch ==~ 'master' |
| 99 | } |
| 100 | } |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 101 | 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 Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 128 | 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 130 | |
| 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 Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 146 | 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 | |
| 156 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 157 | ## Run CORE API Tests |
| 158 | pybot -d Log -T XOSCoreAPITests.robot || true |
| 159 | ## Run services API Tests |
| 160 | for i in \$SERVICES; do bash -c "pybot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
| 161 | |
| 162 | popd |
| 163 | |
| 164 | helm delete --purge att-workflow |
| 165 | helm delete --purge xos-core |
| 166 | """ |
| 167 | } |
| 168 | } |
| 169 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 170 | stage('install/test rcord-lite') { |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 171 | steps { |
| 172 | sh """ |
| 173 | #!/usr/bin/env bash |
| 174 | set -eu -o pipefail |
| 175 | |
| 176 | helm_install_args='-f examples/api-test-values.yaml' |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 177 | |
| 178 | pushd cord/helm-charts |
| 179 | |
| 180 | helm dep up xos-core |
| 181 | helm install \${helm_install_args} xos-core -n xos-core |
| 182 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 183 | helm dep update xos-profiles/rcord-lite |
| 184 | helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 185 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 186 | # wait for services to load |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 187 | PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 188 | |
| 189 | echo "# Checking helm deployments" |
| 190 | kubectl get pods |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 191 | |
| 192 | for hchart in \$(helm list -q); |
| 193 | do |
| 194 | echo "## 'helm status' for chart: \${hchart} ##" |
| 195 | helm status "\${hchart}" |
| 196 | done |
| 197 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 198 | CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}') |
| 199 | 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] | 200 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 201 | 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 |
| 202 | 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 |
| 203 | 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 |
| 204 | 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] | 205 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 206 | export testname=_service_api.robot |
| 207 | export library=_library.robot |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 208 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 209 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 210 | echo \$SERVICES |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 211 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 212 | 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] | 213 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 214 | 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] | 215 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 216 | CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}') |
| 217 | 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] | 218 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 219 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 220 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py |
| 221 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py |
| 222 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 223 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 224 | sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
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/Tests |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 227 | ## Run CORE API Tests |
Kailash Khalasi | 07c97a4 | 2018-08-06 12:15:43 -0700 | [diff] [blame] | 228 | pybot -d Log -T XOSCoreAPITests.robot || true |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 229 | ## Run Rcord-lite services API Tests |
Kailash Khalasi | 07c97a4 | 2018-08-06 12:15:43 -0700 | [diff] [blame] | 230 | for i in \$SERVICES; do bash -c "pybot -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] | 231 | |
| 232 | popd |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 233 | |
| 234 | helm delete --purge rcord-lite |
| 235 | helm delete --purge xos-core |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 236 | """ |
| 237 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 238 | } |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 239 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 240 | stage('install/test mcord') { |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 241 | steps { |
| 242 | sh """ |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 243 | #!/usr/bin/env bash |
| 244 | set -eu -o pipefail |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 245 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 246 | helm_install_args='-f examples/api-test-values.yaml' |
| 247 | |
| 248 | pushd cord/helm-charts |
| 249 | |
| 250 | helm dep up xos-core |
| 251 | helm install \${helm_install_args} xos-core -n xos-core |
| 252 | |
| 253 | helm dep update xos-profiles/base-openstack |
| 254 | helm dep update xos-profiles/mcord |
| 255 | helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack |
| 256 | helm install \${helm_install_args} xos-profiles/mcord -n mcord |
| 257 | |
| 258 | # wait for services to load |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 259 | PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 260 | |
| 261 | echo "# Checking helm deployments" |
| 262 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 263 | |
| 264 | for hchart in \$(helm list -q); |
| 265 | do |
| 266 | echo "## 'helm status' for chart: \${hchart} ##" |
| 267 | helm status "\${hchart}" |
| 268 | done |
| 269 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 270 | CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}') |
| 271 | 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] | 272 | |
| 273 | 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 |
| 274 | 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 |
| 275 | 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 |
| 276 | 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 |
| 277 | |
| 278 | export testname=_service_api.robot |
| 279 | export library=_library.robot |
| 280 | |
| 281 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 282 | echo \$SERVICES |
| 283 | |
| 284 | 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 |
| 285 | |
| 286 | 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 |
| 287 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 288 | CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}') |
| 289 | XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172) |
| 290 | |
| 291 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 292 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py |
| 293 | |
| 294 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 295 | ## Run mcord services API Tests |
Kailash Khalasi | 07c97a4 | 2018-08-06 12:15:43 -0700 | [diff] [blame] | 296 | for i in \$SERVICES; do bash -c "pybot -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] | 297 | |
| 298 | popd |
| 299 | |
| 300 | helm delete --purge base-openstack |
| 301 | helm delete --purge mcord |
| 302 | helm delete --purge xos-core |
| 303 | """ |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 304 | } |
| 305 | } |
| 306 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 307 | stage('install/test simpleexampleservice') { |
| 308 | steps { |
| 309 | sh """ |
| 310 | #!/usr/bin/env bash |
| 311 | set -eu -o pipefail |
| 312 | |
| 313 | helm_install_args='-f examples/api-test-values.yaml' |
| 314 | |
| 315 | pushd cord/helm-charts |
| 316 | |
| 317 | helm dep up xos-core |
| 318 | helm install \${helm_install_args} xos-core -n xos-core |
| 319 | |
| 320 | helm dep update xos-profiles/base-kubernetes |
| 321 | helm dep update xos-profiles/demo-simpleexampleservice |
| 322 | helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes |
| 323 | helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice |
| 324 | |
| 325 | # wait for services to load |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 326 | PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 327 | |
| 328 | echo "# Checking helm deployments" |
| 329 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 330 | |
| 331 | for hchart in \$(helm list -q); |
| 332 | do |
| 333 | echo "## 'helm status' for chart: \${hchart} ##" |
| 334 | helm status "\${hchart}" |
| 335 | done |
| 336 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 337 | CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}') |
| 338 | 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] | 339 | |
| 340 | 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 |
| 341 | 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 |
| 342 | 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 |
| 343 | 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 |
| 344 | |
Kailash Khalasi | 0921594 | 2018-10-16 09:13:27 -0700 | [diff] [blame] | 345 | # run e2e synchronizer test |
| 346 | helm test demo-simpleexampleservice |
| 347 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 348 | export testname=_service_api.robot |
| 349 | export library=_library.robot |
| 350 | |
| 351 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 352 | echo \$SERVICES |
| 353 | |
| 354 | 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 |
| 355 | |
| 356 | 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 |
| 357 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 358 | CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}') |
| 359 | XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172) |
| 360 | |
| 361 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 362 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py |
| 363 | |
| 364 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 365 | ## Run kubernetes-base services API Tests |
Kailash Khalasi | 07c97a4 | 2018-08-06 12:15:43 -0700 | [diff] [blame] | 366 | for i in \$SERVICES; do bash -c "pybot -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] | 367 | |
| 368 | popd |
| 369 | |
| 370 | helm delete --purge base-kubernetes |
| 371 | helm delete --purge demo-simpleexampleservice |
| 372 | helm delete --purge xos-core |
| 373 | """ |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | stage('install/test hippie-oss') { |
| 378 | steps { |
| 379 | sh """ |
| 380 | #!/usr/bin/env bash |
| 381 | set -eu -o pipefail |
| 382 | |
| 383 | helm_install_args='-f examples/api-test-values.yaml' |
| 384 | |
| 385 | pushd cord/helm-charts |
| 386 | |
| 387 | helm dep up xos-core |
| 388 | helm install \${helm_install_args} xos-core -n xos-core |
| 389 | |
| 390 | helm dep update xos-services/hippie-oss |
| 391 | helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss |
| 392 | |
| 393 | # wait for services to load |
Zack Williams | 91cecd2 | 2018-09-26 10:59:44 -0700 | [diff] [blame] | 394 | PODS_TIMEOUT=900 ./scripts/wait_for_pods.sh |
| 395 | |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 396 | echo "# Checking helm deployments" |
| 397 | kubectl get pods |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 398 | |
| 399 | for hchart in \$(helm list -q); |
| 400 | do |
| 401 | echo "## 'helm status' for chart: \${hchart} ##" |
| 402 | helm status "\${hchart}" |
| 403 | done |
| 404 | |
Zack Williams | 2e515f3 | 2018-09-27 23:03:07 -0700 | [diff] [blame] | 405 | CORE_POD=\$(kubectl get pods | grep "xos-core.*Running" | awk '{print \$1}') |
| 406 | 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] | 407 | |
| 408 | 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 |
| 409 | 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 |
| 410 | 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 |
| 411 | 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 |
| 412 | |
| 413 | export testname=_service_api.robot |
| 414 | export library=_library.robot |
| 415 | |
| 416 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 417 | echo \$SERVICES |
| 418 | |
| 419 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
| 420 | ## Run hippie-oss services API Tests |
Kailash Khalasi | 07c97a4 | 2018-08-06 12:15:43 -0700 | [diff] [blame] | 421 | for i in \$SERVICES; do bash -c "pybot -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] | 422 | |
| 423 | popd |
| 424 | |
| 425 | helm delete --purge hippie-oss |
| 426 | helm delete --purge xos-core |
| 427 | """ |
| 428 | } |
| 429 | } |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 430 | } |
| 431 | post { |
| 432 | always { |
| 433 | sh ''' |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 434 | # copy robot logs |
| 435 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 436 | 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] | 437 | |
Kailash Khalasi | 0921594 | 2018-10-16 09:13:27 -0700 | [diff] [blame] | 438 | #copy helm test robot logs |
| 439 | cp -r /tmp/*ml ./RobotLogs |
| 440 | |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 441 | kubectl get pods --all-namespaces |
| 442 | |
| 443 | echo "# removing helm deployments" |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 444 | for hchart in \$(helm list -q); |
| 445 | do |
| 446 | echo "## Purging chart: \${hchart} ##" |
| 447 | helm delete --purge "\${hchart}" |
| 448 | done |
| 449 | |
Zack Williams | f8b356c | 2018-07-17 17:01:27 -0700 | [diff] [blame] | 450 | sudo minikube delete |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 451 | ''' |
Kailash Khalasi | 1c773ed | 2018-08-01 10:47:59 -0700 | [diff] [blame] | 452 | step([$class: 'RobotPublisher', |
| 453 | disableArchiveOutput: false, |
| 454 | logFileName: 'RobotLogs/log*.html', |
| 455 | otherFiles: '', |
| 456 | outputFileName: 'RobotLogs/output*.xml', |
| 457 | outputPath: '.', |
| 458 | passThreshold: 100, |
| 459 | reportFileName: 'RobotLogs/report*.html', |
| 460 | unstableThreshold: 0]); |
| 461 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false]) |
Zack Williams | fd87d65 | 2018-07-12 14:21:12 -0700 | [diff] [blame] | 462 | } |
| 463 | } |
Zack Williams | 9d68aa3 | 2018-07-12 11:50:37 -0700 | [diff] [blame] | 464 | } |