Joey Armstrong | 518f357 | 2024-02-11 07:56:25 -0500 | [diff] [blame] | 1 | // Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 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 | |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 15 | // Run XOS api tests after changing the containers to use the current XOS |
| 16 | // container versions as parent, which may include synchronizer framework |
| 17 | // changes |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 18 | |
| 19 | CORE_CONTAINER="null" |
| 20 | |
| 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}" |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -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 | |
| 48 | stage('patch') { |
| 49 | steps { |
| 50 | sh """ |
| 51 | #!/usr/bin/env bash |
| 52 | set -eu -o pipefail |
| 53 | |
| 54 | VERSIONFILE="" # file path to file containing version number |
| 55 | NEW_VERSION="" # version number found in VERSIONFILE |
| 56 | releaseversion=0 |
| 57 | |
| 58 | function read_version { |
| 59 | if [ -f "VERSION" ] |
| 60 | then |
| 61 | NEW_VERSION=\$(head -n1 "VERSION") |
| 62 | VERSIONFILE="VERSION" |
| 63 | elif [ -f "package.json" ] |
| 64 | then |
| 65 | NEW_VERSION=\$(python -c 'import json,sys;obj=json.load(sys.stdin); print obj["version"]' < package.json) |
| 66 | VERSIONFILE="package.json" |
| 67 | else |
| 68 | echo "ERROR: No versioning file found!" |
| 69 | exit 1 |
| 70 | fi |
| 71 | } |
| 72 | |
| 73 | # check if the version is a released version |
| 74 | function check_if_releaseversion { |
| 75 | if [[ "\$NEW_VERSION" =~ ^([0-9]+)\\.([0-9]+)\\.([0-9]+)\$ ]] |
| 76 | then |
| 77 | echo "Version string '\$NEW_VERSION' in '\$VERSIONFILE' is a SemVer released version!" |
| 78 | releaseversion=1 |
| 79 | else |
| 80 | echo "Version string '\$NEW_VERSION' in '\$VERSIONFILE' is not a SemVer released version, skipping." |
| 81 | fi |
| 82 | } |
| 83 | |
| 84 | pushd cord |
Zack Williams | de1c621 | 2020-02-24 17:00:17 -0700 | [diff] [blame] | 85 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifests/default.xml) |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 86 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 87 | |
| 88 | pushd \$PROJECT_PATH |
| 89 | echo "Existing git tags:" |
| 90 | git tag -n |
| 91 | |
| 92 | read_version |
| 93 | check_if_releaseversion |
| 94 | |
| 95 | # perform checks if a released version |
| 96 | if [ "\$releaseversion" -eq "1" ] |
| 97 | then |
| 98 | git config --global user.email "apitest@opencord.org" |
| 99 | git config --global user.name "API Test" |
| 100 | |
| 101 | git tag -a "\$NEW_VERSION" -m "Tagged for api test on Gerrit patchset: ${gerritChangeNumber}" |
| 102 | |
| 103 | echo "Tags including new tag:" |
| 104 | git tag -n |
| 105 | |
| 106 | fi |
| 107 | popd |
| 108 | popd |
| 109 | """ |
| 110 | } |
| 111 | } |
Zack Williams | 1f67293 | 2018-07-24 11:24:10 -0700 | [diff] [blame] | 112 | |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 113 | stage('tag update') { |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 114 | steps { |
| 115 | sh """ |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 116 | #!/usr/bin/env bash |
| 117 | set -eu -o pipefail |
| 118 | |
Scott Baker | c71f9ca | 2019-03-04 09:38:13 -0800 | [diff] [blame] | 119 | ALLOWED_SERVICES="att-workflow-driver fabric fabric-crossconnect kubernetes-service olt-service onos-service rcord simpleexampleservice" |
| 120 | |
Kailash Khalasi | f57dcdd | 2018-09-16 09:22:27 -0700 | [diff] [blame] | 121 | echo "" > $WORKSPACE/xos_tags.yaml |
| 122 | echo "" > $WORKSPACE/updated_dockerfiles |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 123 | XOS_MAJOR=\$(cut -b 1 cord/orchestration/xos/VERSION) |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 124 | XOS_VERSION=\$(cat cord/orchestration/xos/VERSION) |
Zack Williams | 1f67293 | 2018-07-24 11:24:10 -0700 | [diff] [blame] | 125 | |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 126 | # update services |
Matteo Scandolo | d0b1670 | 2019-03-11 10:12:52 -0700 | [diff] [blame] | 127 | for df in cord/orchestration/xos-services/*/Dockerfile.synchronizer |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 128 | do |
Scott Baker | c71f9ca | 2019-03-04 09:38:13 -0800 | [diff] [blame] | 129 | service_dirname=\$(basename \$(dirname "\$df")) |
| 130 | if [[ "\$ALLOWED_SERVICES" =~ "\$service_dirname" ]] |
Zack Williams | 42acdd1 | 2018-08-17 13:58:07 -0700 | [diff] [blame] | 131 | then |
Scott Baker | c71f9ca | 2019-03-04 09:38:13 -0800 | [diff] [blame] | 132 | df_contents=\$(cat "\$df") |
| 133 | if [[ "\$df_contents" =~ "FROM xosproject/xos-synchronizer-base:\$XOS_MAJOR" || |
| 134 | "\$df_contents" =~ "FROM xosproject/xos-synchronizer-base:master" ]] |
| 135 | then |
| 136 | sed -i "s/^FROM\\(.*\\):.*\$/FROM\\1:\$XOS_VERSION/" "\$df" |
| 137 | echo "$WORKSPACE/\$df" >> $WORKSPACE/updated_dockerfiles |
| 138 | fi |
| 139 | else |
| 140 | echo "\$service_dirname not in ALLOWED_SERVICES. Not Testing." |
Zack Williams | 42acdd1 | 2018-08-17 13:58:07 -0700 | [diff] [blame] | 141 | fi |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 142 | done |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 143 | |
| 144 | # create values file with core version tags |
Zack Williams | 9b6b5eb | 2018-09-14 13:45:18 -0700 | [diff] [blame] | 145 | # not indented because heredoc requires it |
Kailash Khalasi | f57dcdd | 2018-09-16 09:22:27 -0700 | [diff] [blame] | 146 | cat << EOF > $WORKSPACE/xos_tags.yaml |
Zack Williams | 9b6b5eb | 2018-09-14 13:45:18 -0700 | [diff] [blame] | 147 | --- |
Zack Williams | effda9e | 2018-10-10 10:49:49 -0700 | [diff] [blame] | 148 | images: |
| 149 | xos_core: |
| 150 | tag: '\$XOS_VERSION' |
| 151 | xos_chameleon: |
| 152 | tag: '\$XOS_VERSION' |
Zack Williams | 9b6b5eb | 2018-09-14 13:45:18 -0700 | [diff] [blame] | 153 | EOF |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 154 | """ |
| 155 | } |
| 156 | } |
| 157 | |
Zack Williams | 1f67293 | 2018-07-24 11:24:10 -0700 | [diff] [blame] | 158 | stage('unittest') { |
| 159 | steps { |
| 160 | sh """ |
| 161 | #!/usr/bin/env bash |
| 162 | set -e -o pipefail |
| 163 | |
| 164 | cd "\${WORKSPACE}" |
| 165 | |
| 166 | export XOS_DIR=\${WORKSPACE}/cord/orchestration/xos |
| 167 | \$XOS_DIR/scripts/setup_venv.sh |
| 168 | source "\${WORKSPACE}/venv-xos/bin/activate" |
| 169 | |
| 170 | for df in \$(cat "\${WORKSPACE}/updated_dockerfiles") |
| 171 | do |
| 172 | projectdir=\$(dirname "\${df}") |
| 173 | if [ -e "\${projectdir}/xos/unittest.cfg" ] |
| 174 | then |
| 175 | pushd \${projectdir}/xos |
| 176 | echo "Performing nose2 tests" |
| 177 | nose2 --verbose --coverage-report xml --coverage-report term --junit-xml |
| 178 | popd |
| 179 | else |
| 180 | echo "No unit tests found for project \$(basename \${projectdir})" |
| 181 | fi |
| 182 | done |
| 183 | """ |
Zack Williams | 96a7369 | 2019-02-27 17:04:00 -0700 | [diff] [blame] | 184 | junit testResults: '**/nose2-junit.xml', allowEmptyResults: true |
| 185 | cobertura coberturaReportFile: '**/coverage.xml', fileCoverageTargets: '80, 0, 0', methodCoverageTargets: '50, 0, 0', failNoReports: false |
Zack Williams | 1f67293 | 2018-07-24 11:24:10 -0700 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 189 | stage('prep') { |
| 190 | parallel { |
| 191 | |
| 192 | stage('images') { |
| 193 | steps { |
| 194 | sh ''' |
| 195 | pushd cord/automation-tools/developer |
| 196 | mkdir ib_logs |
| 197 | ./imagebuilder.py -l ib_logs -a ib_actions.yml -g ib_graph.dot -f ../../helm-charts/examples/filter-images.yaml |
| 198 | popd |
| 199 | ''' |
| 200 | archiveArtifacts artifacts: 'cord/automation-tools/developer/ib_actions.yml, cord/automation-tools/developer/ib_graph.dot, cord/automation-tools/developer/ib_logs/*', fingerprint: true |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | stage('minikube') { |
| 205 | steps { |
| 206 | /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */ |
| 207 | sh ''' |
| 208 | export MINIKUBE_WANTUPDATENOTIFICATION=false |
| 209 | export MINIKUBE_WANTREPORTERRORPROMPT=false |
| 210 | export CHANGE_MINIKUBE_NONE_USER=true |
| 211 | export MINIKUBE_HOME=$HOME |
| 212 | mkdir -p $HOME/.kube || true |
| 213 | touch $HOME/.kube/config |
| 214 | export KUBECONFIG=$HOME/.kube/config |
| 215 | sudo -E /usr/bin/minikube start --vm-driver=none |
| 216 | ''' |
| 217 | script { |
| 218 | timeout(3) { |
| 219 | waitUntil { |
| 220 | sleep 5 |
| 221 | def kc_ret = sh script: "kubectl get po", returnStatus: true |
| 222 | return (kc_ret == 0); |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | stage('helm') { |
| 232 | steps { |
| 233 | sh ''' |
| 234 | helm init |
| 235 | sleep 60 |
| 236 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 237 | ''' |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | stage('build') { |
| 242 | steps { |
| 243 | sh """ |
| 244 | #!/usr/bin/env bash |
| 245 | set -eu -o pipefail |
| 246 | |
Zack Williams | 6650000 | 2018-09-06 15:29:05 -0700 | [diff] [blame] | 247 | helm_install_args='-f examples/image-tag-candidate.yaml -f examples/imagePullPolicy-IfNotPresent.yaml -f examples/api-test-values.yaml -f $WORKSPACE/xos_tags.yaml' |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 248 | |
| 249 | pushd cord/helm-charts |
| 250 | |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 251 | 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] | 252 | |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 253 | helm-repo-tools/wait_for_pods.sh |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 254 | |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 255 | helm dep up xos-core |
| 256 | helm install \${helm_install_args} xos-core -n xos-core |
| 257 | |
| 258 | # Pick which chart(s) to load depending on the project being tested |
| 259 | # In regex, please list repos in same order as requirements.yaml in the chart(s) loaded! |
| 260 | |
| 261 | if [[ "$GERRIT_PROJECT" =~ ^(rcord|onos-service|fabric|olt-service|vsg-hw|vrouter)\$ ]]; then |
| 262 | helm dep update xos-profiles/rcord-lite |
| 263 | helm install \${helm_install_args} xos-profiles/rcord-lite -n rcord-lite |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 264 | |
| 265 | elif [[ "$GERRIT_PROJECT" =~ ^(vMME|vspgwc|vspgwu|vHSS|hss_db|internetemulator|sdn-controller|epc-service|mcord|progran)\$ ]]; then |
| 266 | helm dep update xos-profiles/base-openstack |
| 267 | helm dep update xos-profiles/mcord |
| 268 | helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack |
| 269 | helm install \${helm_install_args} xos-profiles/mcord -n mcord |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 270 | |
| 271 | elif [[ "$GERRIT_PROJECT" =~ ^(openstack|vtn-service|exampleservice|addressmanager)\$ ]]; then |
| 272 | # NOTE: onos-service is included in base-openstack, but tested w/rcord-lite chart |
| 273 | |
| 274 | helm dep update xos-profiles/base-openstack |
| 275 | helm dep update xos-profiles/demo-exampleservice |
| 276 | helm install \${helm_install_args} xos-profiles/base-openstack -n base-openstack |
| 277 | helm install \${helm_install_args} xos-profiles/demo-exampleservice -n demo-exampleservice |
| 278 | |
| 279 | elif [[ "$GERRIT_PROJECT" =~ ^(kubernetes-service|simpleexampleservice)\$ ]]; then |
| 280 | helm dep update xos-profiles/base-kubernetes |
| 281 | helm dep update xos-profiles/demo-simpleexampleservice |
| 282 | helm install \${helm_install_args} xos-profiles/base-kubernetes -n base-kubernetes |
| 283 | helm install \${helm_install_args} xos-profiles/demo-simpleexampleservice -n demo-simpleexampleservice |
| 284 | |
| 285 | elif [[ "$GERRIT_PROJECT" =~ ^(hippie-oss)\$ ]]; then |
| 286 | helm dep update xos-services/hippie-oss |
| 287 | helm install \${helm_install_args} xos-services/hippie-oss -n hippie-oss |
| 288 | |
| 289 | elif [[ "$GERRIT_PROJECT" =~ ^(xos|xos-tosca|cord-tester|helm-charts)\$ ]]; then |
| 290 | echo "No additional charts to install for testing $GERRIT_PROJECT" |
| 291 | |
| 292 | else |
| 293 | echo "Couldn't find a chart to test project: $GERRIT_PROJECT!" |
| 294 | exit 1 |
| 295 | fi |
| 296 | |
Kailash Khalasi | 2bc499b | 2018-07-25 16:10:11 -0700 | [diff] [blame] | 297 | # wait for services to load |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 298 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
Kailash Khalasi | 512a7e5 | 2018-07-30 09:12:16 -0700 | [diff] [blame] | 299 | |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 300 | echo "# Checking helm deployments" |
| 301 | kubectl get pods |
| 302 | helm list |
| 303 | |
| 304 | for hchart in \$(helm list -q); |
| 305 | do |
| 306 | echo "## 'helm status' for chart: \${hchart} ##" |
| 307 | helm status "\${hchart}" |
| 308 | done |
| 309 | |
| 310 | popd |
| 311 | """ |
| 312 | } |
| 313 | } |
| 314 | |
Kailash Khalasi | 512a7e5 | 2018-07-30 09:12:16 -0700 | [diff] [blame] | 315 | stage('wait for core') { |
| 316 | steps { |
| 317 | timeout(time:5) { |
| 318 | waitUntil { |
| 319 | script { |
| 320 | try { |
| 321 | sh """ |
| 322 | CORE_POD=\$(kubectl get pods | grep xos-core | awk '{print \$1}') |
| 323 | CHAM_POD=\$(kubectl get pods | grep chameleon | awk '{print \$1}') |
| 324 | CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}') |
| 325 | XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172) |
| 326 | kubectl logs \$CORE_POD | grep "XOS core entering wait loop" |
Kailash Khalasi | 512a7e5 | 2018-07-30 09:12:16 -0700 | [diff] [blame] | 327 | curl -I -u admin@opencord.org:letmein http://\$XOS_CHAMELEON:9101/xosapi/v1/core/users | grep "200 OK" |
Kailash Khalasi | 309872a | 2018-07-31 12:39:02 -0700 | [diff] [blame] | 328 | sleep 30 |
Kailash Khalasi | 25ee072 | 2018-07-30 14:26:41 -0700 | [diff] [blame] | 329 | curl -I -u admin@opencord.org:letmein http://\$XOS_CHAMELEON:9101/xosapi/v1/core/sites | grep "200 OK" |
| 330 | """ |
Kailash Khalasi | 512a7e5 | 2018-07-30 09:12:16 -0700 | [diff] [blame] | 331 | return true |
| 332 | } catch (exception) { |
| 333 | return false |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 341 | stage('setup') { |
| 342 | steps { |
| 343 | sh """ |
| 344 | CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}') |
| 345 | |
| 346 | 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 |
| 347 | 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 |
| 348 | 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 |
| 349 | 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 |
| 350 | |
| 351 | # create additional testing files if services are loaded |
| 352 | if ! [[ "$GERRIT_PROJECT" =~ ^(xos|xos-tosca|cord-tester|helm-charts)\$ ]]; then |
| 353 | export testname=_service_api.robot |
| 354 | export library=_library.robot |
| 355 | |
| 356 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 357 | echo \$SERVICES |
| 358 | |
| 359 | 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 |
| 360 | |
| 361 | 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 |
| 362 | fi |
| 363 | """ |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | stage('test') { |
| 368 | steps { |
| 369 | sh """ |
| 370 | pushd cord/test/cord-tester/src/test/cord-api/Tests |
| 371 | |
| 372 | CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}') |
| 373 | CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}') |
| 374 | XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172) |
| 375 | |
| 376 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/ |
| 377 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py |
| 378 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py |
| 379 | sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py |
| 380 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 381 | sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py |
| 382 | |
| 383 | cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 384 | robot -d Log -T XOSCoreAPITests.robot || true |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 385 | |
| 386 | # do additional tests if services are loaded |
| 387 | if ! [[ "$GERRIT_PROJECT" =~ ^(xos|xos-tosca|cord-tester|helm-charts)\$ ]]; then |
| 388 | export testname=_service_api.robot |
| 389 | export library=_library.robot |
| 390 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 391 | echo \$SERVICES |
| 392 | |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 393 | for i in \$SERVICES; do bash -c "robot -d Log -T -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 394 | fi |
| 395 | |
| 396 | popd |
| 397 | """ |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | stage('Publish') { |
| 402 | steps { |
| 403 | sh """ |
| 404 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 405 | cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs |
| 406 | """ |
| 407 | |
| 408 | step([$class: 'RobotPublisher', |
| 409 | disableArchiveOutput: false, |
| 410 | logFileName: 'RobotLogs/log*.html', |
| 411 | otherFiles: '', |
| 412 | outputFileName: 'RobotLogs/output*.xml', |
| 413 | outputPath: '.', |
Kailash Khalasi | ad6cfda | 2018-07-25 11:31:35 -0700 | [diff] [blame] | 414 | passThreshold: 100, |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 415 | reportFileName: 'RobotLogs/report*.html', |
| 416 | unstableThreshold: 0]); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | } |
| 421 | |
| 422 | post { |
| 423 | always { |
| 424 | sh ''' |
Kailash Khalasi | ecb4eb6 | 2018-07-31 15:20:19 -0700 | [diff] [blame] | 425 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 426 | do |
| 427 | kubectl logs \$pod > $WORKSPACE/\$pod.log; |
| 428 | done |
| 429 | |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 430 | kubectl get pods --all-namespaces |
| 431 | |
| 432 | echo "# removing helm deployments" |
| 433 | kubectl get pods |
| 434 | helm list |
| 435 | |
| 436 | for hchart in \$(helm list -q); |
| 437 | do |
| 438 | echo "## Purging chart: \${hchart} ##" |
| 439 | helm delete --purge "\${hchart}" |
| 440 | done |
| 441 | |
| 442 | sudo minikube delete |
| 443 | ''' |
Kailash Khalasi | ecb4eb6 | 2018-07-31 15:20:19 -0700 | [diff] [blame] | 444 | archiveArtifacts artifacts: '*.log' |
Zack Williams | 15bc4a5 | 2018-07-23 15:31:58 -0700 | [diff] [blame] | 445 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "suchitra@opennetworking.org, you@opennetworking.org, kailash@opennetworking.org", sendToIndividuals: false]) |
| 446 | } |
| 447 | } |
| 448 | } |