Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -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 | |
| 18 | pipeline { |
| 19 | |
| 20 | /* no label, executor is determined by JJB */ |
| 21 | agent { |
| 22 | label "${params.executorNode}" |
| 23 | } |
| 24 | |
| 25 | stages { |
| 26 | |
| 27 | stage('repo') { |
| 28 | steps { |
| 29 | checkout(changelog: false, \ |
| 30 | poll: false, |
| 31 | scm: [$class: 'RepoScm', \ |
| 32 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
Kailash Khalasi | f55eba8 | 2018-08-21 13:02:38 -0700 | [diff] [blame] | 33 | manifestBranch: "${params.manifestBranch}", \ |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 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 | |
| 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 | |
Kailash | 2caf2b0 | 2019-05-01 14:50:47 -0700 | [diff] [blame] | 80 | stage('install xos') { |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 81 | steps { |
| 82 | sh """ |
| 83 | #!/usr/bin/env bash |
| 84 | set -eu -o pipefail |
| 85 | |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 86 | pushd cord/helm-charts |
| 87 | |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 88 | 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] | 89 | |
Luca Prete | 2ae9013 | 2018-12-13 17:14:01 -0800 | [diff] [blame] | 90 | helm-repo-tools/wait_for_pods.sh |
Zack Williams | a26fc9d | 2018-09-18 16:49:01 -0700 | [diff] [blame] | 91 | |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 92 | helm dep up xos-core |
Kailash | c3042c5 | 2019-09-13 10:15:08 -0700 | [diff] [blame^] | 93 | |
| 94 | if [[ ${gerritProject} == "xos"]]; then |
| 95 | helm install --set images.xos_core.tag=master xos-core -n xos-core; |
| 96 | else |
| 97 | helm install xos-core -n xos-core; |
| 98 | fi |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 99 | |
Kailash | f05f3a1 | 2018-12-17 09:06:28 -0800 | [diff] [blame] | 100 | helm dep update xos-profiles/seba-services |
Kailash | be13fe7 | 2019-02-04 10:50:48 -0800 | [diff] [blame] | 101 | helm install xos-profiles/seba-services |
Kailash | f05f3a1 | 2018-12-17 09:06:28 -0800 | [diff] [blame] | 102 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
Kailash | f05f3a1 | 2018-12-17 09:06:28 -0800 | [diff] [blame] | 103 | |
Kailash | b06829d | 2019-05-02 14:44:57 -0700 | [diff] [blame] | 104 | sleep 60 |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 105 | echo "# Checking helm deployments" |
| 106 | kubectl get pods |
| 107 | helm list |
| 108 | |
| 109 | for hchart in \$(helm list -q); |
| 110 | do |
| 111 | echo "## 'helm status' for chart: \${hchart} ##" |
| 112 | helm status "\${hchart}" |
| 113 | done |
Kailash | be13fe7 | 2019-02-04 10:50:48 -0800 | [diff] [blame] | 114 | popd |
| 115 | |
| 116 | """ |
| 117 | } |
| 118 | } |
Kailash | 2caf2b0 | 2019-05-01 14:50:47 -0700 | [diff] [blame] | 119 | |
| 120 | stage('install profile') { |
| 121 | when { expression { return params.InstallService } } |
| 122 | steps { |
| 123 | sh """ |
| 124 | #!/usr/bin/env bash |
| 125 | set -eu -o pipefail |
| 126 | |
| 127 | pushd cord/helm-charts |
| 128 | |
| 129 | helm dep update ${params.helmChart} |
| 130 | helm install --set image.tag=master ${params.helmChart} --set att-workflow-driver.kafkaService=cord-kafka -n ${params.service} |
| 131 | |
| 132 | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator |
| 133 | |
| 134 | # wait for services to load |
| 135 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
Kailash | b06829d | 2019-05-02 14:44:57 -0700 | [diff] [blame] | 136 | sleep 120 |
Kailash | 2caf2b0 | 2019-05-01 14:50:47 -0700 | [diff] [blame] | 137 | echo "# Checking helm deployments" |
| 138 | kubectl get pods |
| 139 | helm list |
| 140 | |
| 141 | for hchart in \$(helm list -q); |
| 142 | do |
| 143 | echo "## 'helm status' for chart: \${hchart} ##" |
| 144 | helm status "\${hchart}" |
| 145 | done |
| 146 | popd |
| 147 | |
| 148 | """ |
| 149 | } |
| 150 | } |
| 151 | |
Kailash | 866e14f | 2019-02-22 10:43:23 -0800 | [diff] [blame] | 152 | stage('test') { |
Kailash | be13fe7 | 2019-02-04 10:50:48 -0800 | [diff] [blame] | 153 | steps { |
| 154 | sh """ |
| 155 | #!/usr/bin/env bash |
| 156 | set -eu -o pipefail |
Kailash | f73ff1c | 2019-03-06 14:00:51 -0800 | [diff] [blame] | 157 | export CORD_KAFKA_IP=\$(kubectl exec cord-kafka-0 -- ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172) |
Kailash | be13fe7 | 2019-02-04 10:50:48 -0800 | [diff] [blame] | 158 | pushd cord/test/cord-tester/src/test/cord-api/ |
| 159 | source setup_venv.sh |
Kailash | c47d9c5 | 2019-03-05 13:10:47 -0800 | [diff] [blame] | 160 | cd Tests/${params.TestDir} |
Kailash | 866e14f | 2019-02-22 10:43:23 -0800 | [diff] [blame] | 161 | ${params.TestCommand} || true |
Kailash | be13fe7 | 2019-02-04 10:50:48 -0800 | [diff] [blame] | 162 | popd |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 163 | """ |
| 164 | } |
| 165 | } |
| 166 | } |
Kailash | 2caf2b0 | 2019-05-01 14:50:47 -0700 | [diff] [blame] | 167 | |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 168 | post { |
| 169 | always { |
Kailash | f73ff1c | 2019-03-06 14:00:51 -0800 | [diff] [blame] | 170 | sh """ |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 171 | kubectl get pods --all-namespaces |
| 172 | |
Kailash | 2caf2b0 | 2019-05-01 14:50:47 -0700 | [diff] [blame] | 173 | ## get pod logs |
| 174 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 175 | do |
| 176 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 177 | done || true |
| 178 | |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 179 | # copy robot logs |
| 180 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
Kailash | c47d9c5 | 2019-03-05 13:10:47 -0800 | [diff] [blame] | 181 | cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/${params.TestDir}/Log/*ml ./RobotLogs |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 182 | echo "# removing helm deployments" |
| 183 | kubectl get pods |
| 184 | helm list |
| 185 | |
| 186 | for hchart in \$(helm list -q); |
| 187 | do |
| 188 | echo "## Purging chart: \${hchart} ##" |
| 189 | helm delete --purge "\${hchart}" |
| 190 | done |
| 191 | |
| 192 | sudo minikube delete |
Kailash | f73ff1c | 2019-03-06 14:00:51 -0800 | [diff] [blame] | 193 | """ |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 194 | step([$class: 'RobotPublisher', |
| 195 | disableArchiveOutput: false, |
| 196 | logFileName: 'RobotLogs/log*.html', |
| 197 | otherFiles: '', |
| 198 | outputFileName: 'RobotLogs/output*.xml', |
| 199 | outputPath: '.', |
| 200 | passThreshold: 100, |
| 201 | reportFileName: 'RobotLogs/report*.html', |
| 202 | unstableThreshold: 0]); |
Kailash | 2caf2b0 | 2019-05-01 14:50:47 -0700 | [diff] [blame] | 203 | archiveArtifacts artifacts: '*.log' |
| 204 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.notificationEmail}", sendToIndividuals: false]) |
Kailash Khalasi | c00ac4d | 2018-08-20 09:21:48 -0700 | [diff] [blame] | 205 | |
| 206 | } |
| 207 | } |
| 208 | } |