Kailash | 66c389c | 2019-04-24 14:56:11 -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 | |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 18 | def serviceName = "${gerritProject}" |
Carmelo Cascone | 43086e1 | 2020-03-23 19:29:04 -0700 | [diff] [blame] | 19 | def xosCoreVersionMismatch = false |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 20 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 21 | pipeline { |
| 22 | |
| 23 | /* no label, executor is determined by JJB */ |
| 24 | agent { |
Zack Williams | b329208 | 2019-10-11 17:15:18 -0700 | [diff] [blame] | 25 | label "${params.buildNode}" |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | stages { |
| 29 | |
| 30 | stage('repo') { |
| 31 | steps { |
| 32 | checkout(changelog: false, \ |
| 33 | poll: false, |
| 34 | scm: [$class: 'RepoScm', \ |
| 35 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 36 | manifestBranch: "${params.manifestBranch}", \ |
| 37 | currentBranch: true, \ |
| 38 | destinationDir: 'cord', \ |
| 39 | forceSync: true, |
| 40 | resetFirst: true, \ |
| 41 | quiet: true, \ |
| 42 | jobs: 4, \ |
| 43 | showAllChanges: true] \ |
| 44 | ) |
| 45 | } |
| 46 | } |
| 47 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 48 | stage('minikube') { |
| 49 | steps { |
| 50 | /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */ |
| 51 | sh ''' |
| 52 | export MINIKUBE_WANTUPDATENOTIFICATION=false |
| 53 | export MINIKUBE_WANTREPORTERRORPROMPT=false |
| 54 | export CHANGE_MINIKUBE_NONE_USER=true |
| 55 | export MINIKUBE_HOME=$HOME |
| 56 | mkdir -p $HOME/.kube || true |
| 57 | touch $HOME/.kube/config |
| 58 | export KUBECONFIG=$HOME/.kube/config |
| 59 | sudo -E /usr/bin/minikube start --vm-driver=none |
| 60 | ''' |
| 61 | script { |
| 62 | timeout(3) { |
| 63 | waitUntil { |
| 64 | sleep 5 |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 65 | def kc_ret = sh script: "kubectl get pods", returnStatus: true |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 66 | return (kc_ret == 0); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | stage('helm') { |
| 74 | steps { |
| 75 | sh ''' |
| 76 | helm init |
| 77 | sleep 60 |
| 78 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
Carmelo Cascone | 319b34c | 2020-01-14 16:48:07 -0800 | [diff] [blame] | 79 | helm repo add cord https://charts.opencord.org |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 80 | ''' |
| 81 | } |
| 82 | } |
| 83 | |
Carmelo Cascone | 43086e1 | 2020-03-23 19:29:04 -0700 | [diff] [blame] | 84 | stage('Verify xos-core version requirements') { |
| 85 | steps { |
| 86 | script { |
| 87 | if (serviceName == "olt-service") { |
| 88 | serviceName = "volt" |
| 89 | } |
| 90 | else if (serviceName == "onos-service") { |
| 91 | serviceName = "onos" |
| 92 | } |
| 93 | else if (serviceName == "kubernetes-service") { |
| 94 | serviceName = "kubernetes" |
| 95 | } |
| 96 | } |
| 97 | result = sh returnStdout: true, script: """ |
| 98 | #!/usr/bin/env bash |
| 99 | set -eu -o pipefail |
| 100 | |
| 101 | # Obtain git tag of the service corresponding to the the docker image |
| 102 | # used in the latest released version of the helm chart (i.e., HEAD |
| 103 | # of cord/helm-charts master branch, which should be already checked |
| 104 | # out by repo). |
| 105 | pushd cord/helm-charts |
| 106 | export RELEASED_GIT_TAG=\$(echo -e "import yaml\\nwith open('xos-services/${serviceName}/Chart.yaml', 'r') as f: print yaml.safe_load(f)['appVersion']" | python) |
| 107 | popd |
| 108 | |
| 109 | # Obtain the xos-core version requirement from the config.yaml of the |
| 110 | # released service. |
| 111 | pushd cord |
| 112 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 113 | pushd \${PROJECT_PATH} |
| 114 | git fetch --all --tags |
| 115 | git checkout tags/\${RELEASED_GIT_TAG} -b foobar |
| 116 | export RELEASED_CORE_VER_REQ=\$(echo -e "import yaml\\nwith open('xos/synchronizer/config.yaml', 'r') as f: yaml.safe_load(f)['core_version']" | python) |
| 117 | popd |
| 118 | popd |
| 119 | |
| 120 | # Do the same for the patchset we want to verify. |
| 121 | pushd cord |
| 122 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 123 | pushd \${PROJECT_PATH} |
| 124 | export PATCHSET_CORE_VER_REQ=\$(echo -e "import yaml\\nwith open('xos/synchronizer/config.yaml', 'r') as f: yaml.safe_load(f)['core_version']" | python) |
| 125 | popd |
| 126 | popd |
| 127 | |
| 128 | echo "RELEASED_CORE_VER_REQ: \${RELEASED_CORE_VER_REQ}" |
| 129 | echo "PATCHSET_CORE_VER_REQ: \${PATCHSET_CORE_VER_REQ}" |
| 130 | |
| 131 | if [ "\${PATCHSET_CORE_VER_REQ}" == "\${RELEASED_CORE_VER_REQ}" ]; then |
| 132 | echo 0 |
| 133 | else |
| 134 | # xosCoreVersionMismatch is true |
| 135 | echo 1 |
| 136 | fi |
| 137 | """ |
| 138 | xosCoreVersionMismatch = result.toBoolean() |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if( xosCoreVersionMismatch ) { |
| 143 | echo "Detected xos-core version requirements mismatch. Will skip the rest of the pipeline and return SUCCESS" |
| 144 | currentBuild.result = 'SUCCESS' |
| 145 | return |
| 146 | } |
| 147 | |
| 148 | // The patchset should be already checked out, but for consistency with |
| 149 | // other pipeline jobs, we re-do the same here. |
| 150 | stage('patch') { |
| 151 | steps { |
| 152 | sh ''' |
| 153 | pushd cord |
| 154 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 155 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 156 | popd |
| 157 | ''' |
| 158 | } |
| 159 | } |
| 160 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 161 | stage('Install XOS w/Service') { |
| 162 | steps { |
Carmelo Cascone | 43086e1 | 2020-03-23 19:29:04 -0700 | [diff] [blame] | 163 | script { |
Kailash | 5f300b9 | 2019-05-21 14:04:19 -0700 | [diff] [blame] | 164 | if (serviceName == "olt-service") { |
| 165 | serviceName = "volt" |
| 166 | } |
| 167 | else if (serviceName == "onos-service") { |
| 168 | serviceName = "onos" |
| 169 | } |
| 170 | else if (serviceName == "kubernetes-service") { |
| 171 | serviceName = "kubernetes" |
| 172 | } |
| 173 | } |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 174 | sh """ |
| 175 | #!/usr/bin/env bash |
| 176 | set -eu -o pipefail |
| 177 | |
| 178 | pushd cord/helm-charts |
| 179 | helm dep update xos-core |
| 180 | helm install xos-core -n xos-core |
| 181 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 182 | helm-repo-tools/wait_for_pods.sh |
| 183 | |
| 184 | #install service |
Kailash | 5f300b9 | 2019-05-21 14:04:19 -0700 | [diff] [blame] | 185 | helm dep update xos-services/${serviceName} |
| 186 | helm install xos-services/${serviceName} -n ${serviceName} |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 187 | popd |
| 188 | """ |
| 189 | } |
| 190 | } |
| 191 | stage('Verify') { |
| 192 | steps { |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 193 | echo "serviceName: ${serviceName}" |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 194 | sh """ |
| 195 | #!/usr/bin/env bash |
| 196 | set -ex -o pipefail |
| 197 | export DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos/VERSION) |
| 198 | |
| 199 | #wait for xos-core and models to be loaded |
| 200 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done" |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 201 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${serviceName}\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done" |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 202 | |
| 203 | ## get pod logs |
| 204 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 205 | do |
Daniele Moro | a5f0078 | 2020-02-24 11:23:46 -0800 | [diff] [blame] | 206 | kubectl logs \${pod} > $WORKSPACE/\${pod}_pre.log; |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 207 | done |
| 208 | """ |
| 209 | } |
| 210 | } |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 211 | stage('Generate Model API Tests') { |
| 212 | steps { |
| 213 | sh """ |
| 214 | CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}') |
| 215 | cd $WORKSPACE/cord/test/cord-tester |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 216 | docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceupgradetest.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceupgradetest.xtarget |
| 217 | docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosstaticlibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosstaticlibrary.xtarget |
| 218 | |
| 219 | export testname=_service_api.robot |
| 220 | export library=_library.robot |
| 221 | |
| 222 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 223 | echo \$SERVICES |
| 224 | |
| 225 | for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosserviceupgradetest.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 |
| 226 | |
| 227 | for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosstaticlibrary.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 |
| 228 | ls -al $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/ |
| 229 | """ |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | stage('Test Pre-Upgrade') { |
| 234 | steps { |
| 235 | sh """ |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 236 | #!/usr/bin/env bash |
| 237 | set -ex -o pipefail |
| 238 | |
| 239 | pushd cord/test/cord-tester |
| 240 | make venv_cord |
| 241 | source venv_cord/bin/activate |
| 242 | cd src/test/cord-api/Tests |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 243 | |
| 244 | CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}') |
| 245 | CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}') |
| 246 | XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172) |
| 247 | |
| 248 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 249 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py |
| 250 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py |
| 251 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 252 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 253 | sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 254 | |
| 255 | export testname=_service_api.robot |
| 256 | export library=_library.robot |
| 257 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 258 | echo \$SERVICES |
| 259 | |
| 260 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 261 | for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i create -d Log -T -v TESTLIBRARY:${serviceName}_library.robot \$i\$testname"; sleep 2; done || true |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 262 | |
| 263 | popd |
| 264 | """ |
| 265 | } |
| 266 | } |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 267 | |
| 268 | stage('Build/Install New Service') { |
| 269 | steps { |
| 270 | sh """ |
| 271 | #!/usr/bin/env bash |
| 272 | set -eu -o pipefail |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 273 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 274 | pushd $WORKSPACE/cord/orchestration/xos-services/${gerritProject} |
| 275 | export DOCKER_TAG=\$(cat VERSION)-test |
| 276 | export DOCKER_REPOSITORY=xosproject/ |
| 277 | export DOCKER_BUILD_ARGS=--no-cache |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 278 | echo "\$(cat VERSION)-test" > VERSION |
| 279 | make docker-build |
| 280 | |
| 281 | #install newservice |
| 282 | cd $WORKSPACE/cord/helm-charts |
| 283 | helm upgrade --set image.tag=\$DOCKER_TAG \ |
| 284 | --set image.pullPolicy=Never \ |
Kailash | 5f300b9 | 2019-05-21 14:04:19 -0700 | [diff] [blame] | 285 | --recreate-pods ${serviceName} xos-services/${serviceName} |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 286 | popd |
| 287 | """ |
| 288 | } |
| 289 | } |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 290 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 291 | stage('Verify Service Upgrade') { |
| 292 | steps { |
| 293 | sh """ |
| 294 | #!/usr/bin/env bash |
| 295 | set -ex -o pipefail |
| 296 | DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos-services/${gerritProject}/VERSION) |
| 297 | |
| 298 | #wait for xos-core and models to be loaded |
| 299 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done" |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 300 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${serviceName}\\").state'| grep -q present; do echo 'Waiting for New Service to be loaded'; sleep 5; done" |
| 301 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${serviceName}\\").version'| grep -q \$DOCKER_TAG; do echo 'Waiting for New Service Version Check'; sleep 5; done" |
Kailash | 4590ca1 | 2019-04-30 14:49:22 -0700 | [diff] [blame] | 302 | sleep 120 |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 303 | """ |
| 304 | } |
| 305 | } |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 306 | |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 307 | stage('Test Post-Upgrade') { |
| 308 | steps { |
| 309 | sh """ |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 310 | #!/usr/bin/env bash |
| 311 | set -ex -o pipefail |
| 312 | |
| 313 | cd cord/test/cord-tester |
| 314 | make venv_cord |
| 315 | source venv_cord/bin/activate |
| 316 | cd src/test/cord-api/Tests |
| 317 | |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 318 | CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}') |
| 319 | |
| 320 | export testname=_service_api.robot |
| 321 | export library=_library.robot |
| 322 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 323 | echo \$SERVICES |
Matteo Scandolo | 5c6a480 | 2019-05-14 10:44:21 -0700 | [diff] [blame] | 324 | for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i get -d Log -T -v TESTLIBRARY:${serviceName}_library.robot \$i\$testname"; sleep 2; done || true |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 325 | """ |
| 326 | } |
| 327 | } |
| 328 | |
Andy Bavier | e053ad3 | 2019-05-09 13:58:34 -0700 | [diff] [blame] | 329 | /* Disable the downgrade step because the core doesn't support reverse migrations |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 330 | stage('Downgrade Service') { |
| 331 | steps { |
| 332 | sh """ |
| 333 | #!/usr/bin/env bash |
| 334 | set -eu -o pipefail |
| 335 | |
| 336 | pushd cord/helm-charts |
| 337 | #delete service |
| 338 | helm delete --purge ${gerritProject} |
| 339 | |
| 340 | #re-install service with previous version |
| 341 | helm dep update xos-services/${gerritProject} |
| 342 | helm install xos-services/${gerritProject} -n ${gerritProject} |
| 343 | |
| 344 | #wait for xos-core and models to be loaded |
| 345 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done" |
| 346 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").state'| grep -q present; do echo 'Waiting for Service to be loaded'; sleep 5; done" |
Kailash | 4590ca1 | 2019-04-30 14:49:22 -0700 | [diff] [blame] | 347 | sleep 120 |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 348 | |
| 349 | cd $WORKSPACE/cord/test/cord-tester |
| 350 | make venv_cord |
| 351 | source venv_cord/bin/activate |
| 352 | cd src/test/cord-api/Tests |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 353 | |
| 354 | CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}') |
| 355 | |
| 356 | export testname=_service_api.robot |
| 357 | export library=_library.robot |
| 358 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 359 | |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 360 | echo \$SERVICES |
| 361 | for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i get -d Log -T -v TESTLIBRARY:${gerritProject}_library.robot \$i\$testname"; sleep 2; done || true |
| 362 | |
| 363 | ## get pod logs |
| 364 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 365 | do |
| 366 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 367 | done || true |
| 368 | |
| 369 | popd |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 370 | """ |
| 371 | } |
| 372 | } |
Andy Bavier | e053ad3 | 2019-05-09 13:58:34 -0700 | [diff] [blame] | 373 | */ |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 374 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 375 | } |
Kailash | 44fd62c | 2019-04-30 10:26:31 -0700 | [diff] [blame] | 376 | |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 377 | post { |
| 378 | always { |
| 379 | sh """ |
Daniele Moro | a5f0078 | 2020-02-24 11:23:46 -0800 | [diff] [blame] | 380 | ## get pod logs |
| 381 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 382 | do |
| 383 | kubectl logs \${pod} > $WORKSPACE/\${pod}_post.log; |
| 384 | done |
| 385 | |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 386 | # copy robot logs |
| 387 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 388 | cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 389 | kubectl get pods --all-namespaces |
| 390 | kubectl describe pods |
| 391 | http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status |
| 392 | echo "# removing helm deployments" |
| 393 | kubectl get pods |
| 394 | helm list |
| 395 | |
| 396 | for hchart in \$(helm list -q); |
| 397 | do |
| 398 | echo "## Purging chart: \${hchart} ##" |
| 399 | helm delete --purge "\${hchart}" |
| 400 | done |
| 401 | |
| 402 | sudo minikube delete |
| 403 | """ |
Kailash | f5c3f2b | 2019-04-30 08:58:49 -0700 | [diff] [blame] | 404 | step([$class: 'RobotPublisher', |
| 405 | disableArchiveOutput: false, |
| 406 | logFileName: 'RobotLogs/log*.html', |
| 407 | otherFiles: '', |
| 408 | outputFileName: 'RobotLogs/output*.xml', |
| 409 | outputPath: '.', |
| 410 | passThreshold: 100, |
| 411 | reportFileName: 'RobotLogs/report*.html', |
| 412 | unstableThreshold: 0]); |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 413 | archiveArtifacts artifacts: '*.log' |
Zack Williams | d7af207 | 2020-03-06 13:11:26 -0700 | [diff] [blame] | 414 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "scottb@opennetworking.org", sendToIndividuals: false]) |
Kailash | 66c389c | 2019-04-24 14:56:11 -0700 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | } |