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