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}", \ |
| 33 | manifestBranch: "${params.branch}", \ |
| 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 | |
| 80 | |
| 81 | stage('install/test att-workflow') { |
| 82 | steps { |
| 83 | sh """ |
| 84 | #!/usr/bin/env bash |
| 85 | set -eu -o pipefail |
| 86 | |
| 87 | |
| 88 | pushd cord/helm-charts |
| 89 | |
| 90 | helm dep up xos-core |
| 91 | helm install xos-core -n xos-core |
| 92 | |
| 93 | helm dep update xos-profiles/att-workflow |
| 94 | helm install xos-profiles/att-workflow -n att-workflow |
| 95 | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator |
| 96 | helm install --name cord-kafka incubator/kafka -f examples/kafka-single.yaml |
| 97 | |
| 98 | # wait for services to load |
| 99 | JOBS_TIMEOUT=900 ./scripts/wait_for_jobs.sh |
| 100 | sleep 300 |
| 101 | echo "# Checking helm deployments" |
| 102 | kubectl get pods |
| 103 | helm list |
| 104 | |
| 105 | for hchart in \$(helm list -q); |
| 106 | do |
| 107 | echo "## 'helm status' for chart: \${hchart} ##" |
| 108 | helm status "\${hchart}" |
| 109 | done |
| 110 | helm test att-workflow |
| 111 | popd |
| 112 | |
| 113 | """ |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | post { |
| 118 | always { |
| 119 | sh ''' |
| 120 | |
| 121 | kubectl logs att-workflow-api-test --namespace default |
| 122 | kubectl get pods --all-namespaces |
| 123 | |
| 124 | # copy robot logs |
| 125 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 126 | cp -r /tmp/helm_test_attworkflow_logs_*/*ml ./RobotLogs |
| 127 | |
| 128 | echo "# removing helm deployments" |
| 129 | kubectl get pods |
| 130 | helm list |
| 131 | |
| 132 | for hchart in \$(helm list -q); |
| 133 | do |
| 134 | echo "## Purging chart: \${hchart} ##" |
| 135 | helm delete --purge "\${hchart}" |
| 136 | done |
| 137 | |
| 138 | sudo minikube delete |
| 139 | ''' |
| 140 | step([$class: 'RobotPublisher', |
| 141 | disableArchiveOutput: false, |
| 142 | logFileName: 'RobotLogs/log*.html', |
| 143 | otherFiles: '', |
| 144 | outputFileName: 'RobotLogs/output*.xml', |
| 145 | outputPath: '.', |
| 146 | passThreshold: 100, |
| 147 | reportFileName: 'RobotLogs/report*.html', |
| 148 | unstableThreshold: 0]); |
| 149 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, teo@opennetworking.org", sendToIndividuals: false]) |
| 150 | |
| 151 | } |
| 152 | } |
| 153 | } |