Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [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.manifestBranch}", \ |
| 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 | helm repo add cord https://charts.opencord.org |
| 77 | helm repo update |
| 78 | ''' |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | stage('Build BBSIM') { |
| 83 | steps { |
| 84 | sh ''' |
| 85 | git clone https://github.com/opencord/voltha-bbsim |
| 86 | cd voltha-bbsim/ |
| 87 | make docker |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 88 | docker images | grep bbsim |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 89 | ''' |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | stage('Install BBSIM w/SEBA') { |
| 94 | steps { |
| 95 | sh """ |
| 96 | #!/usr/bin/env bash |
| 97 | set -eu -o pipefail |
| 98 | |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 99 | git clone https://gerrit.opencord.org/pod-configs |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 100 | pushd cord/helm-charts |
| 101 | |
| 102 | helm install -f examples/kafka-single.yaml --version 0.13.3 -n cord-kafka incubator/kafka |
| 103 | |
| 104 | git clone https://gerrit.opencord.org/helm-repo-tools |
| 105 | helm-repo-tools/wait_for_pods.sh |
| 106 | |
| 107 | helm upgrade --install etcd-operator --version 0.8.3 stable/etcd-operator |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 108 | sleep 120 |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 109 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
| 110 | |
| 111 | helm dep up voltha |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 112 | helm install -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig} voltha -n voltha |
| 113 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh voltha |
| 114 | |
| 115 | helm dep up onos |
| 116 | helm install onos -n onos -f $WORKSPACE/pod-configs/kubernetes-configs/${params.deploymentConfig} |
| 117 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 118 | |
| 119 | helm dep up xos-core |
Kailash | 0db702b | 2019-01-29 13:54:19 -0800 | [diff] [blame] | 120 | helm install xos-core -n xos-core |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 121 | |
| 122 | helm dep update xos-profiles/seba-services |
Kailash | 0db702b | 2019-01-29 13:54:19 -0800 | [diff] [blame] | 123 | helm install xos-profiles/seba-services -n seba-services |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 124 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_pods.sh |
| 125 | |
Kailash | 0db702b | 2019-01-29 13:54:19 -0800 | [diff] [blame] | 126 | helm dep update xos-profiles/base-kubernetes |
| 127 | helm install xos-profiles/base-kubernetes -n base-kubernetes |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 128 | |
| 129 | helm dep update workflows/att-workflow |
Kailash | 0db702b | 2019-01-29 13:54:19 -0800 | [diff] [blame] | 130 | helm install workflows/att-workflow -n att-workflow --set att-workflow-driver.kafkaService=cord-kafka |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 131 | |
| 132 | # wait for services to load |
| 133 | JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 134 | |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 135 | echo "# Checking helm deployments" |
| 136 | kubectl get pods |
| 137 | helm list |
| 138 | |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 139 | helm install --set images.bbsim.tag=latest --set images.bbsim.pullPolicy=IfNotPresent bbsim -n bbsim |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 140 | for hchart in \$(helm list -q); |
| 141 | do |
| 142 | echo "## 'helm status' for chart: \${hchart} ##" |
| 143 | helm status "\${hchart}" |
| 144 | done |
Kailash | ff5c540 | 2019-01-28 15:47:54 -0800 | [diff] [blame] | 145 | kubectl get pods -n voltha -o json |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 146 | popd |
| 147 | """ |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | stage('Load BBSIM Tosca') { |
| 152 | steps { |
| 153 | sh ''' |
| 154 | #!/usr/bin/env bash |
| 155 | set -eu -o pipefail |
| 156 | |
| 157 | pushd cord/helm-charts |
| 158 | |
| 159 | curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @examples/bbsim-dhcp.yaml http://127.0.0.1:30007/run |
| 160 | curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @examples/bbsim-16.yaml http://127.0.0.1:30007/run |
| 161 | |
| 162 | popd |
| 163 | ''' |
| 164 | } |
| 165 | } |
| 166 | stage('Test BBSIM') { |
| 167 | steps { |
| 168 | sh ''' |
| 169 | #!/usr/bin/env bash |
| 170 | set -eu -o pipefail |
| 171 | |
| 172 | helm test --timeout 1000 bbsim || true |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 173 | ''' |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | post { |
| 178 | always { |
| 179 | sh ''' |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 180 | kubectl logs bbsim-api-test --namespace default |
| 181 | kubectl get pods --all-namespaces |
Kailash | c06c9b6 | 2019-02-25 10:01:24 -0800 | [diff] [blame] | 182 | ## get default pod logs |
Kailash | 2c1900c | 2019-02-11 12:18:27 -0800 | [diff] [blame] | 183 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 184 | do |
| 185 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 186 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 187 | else |
| 188 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 189 | fi |
| 190 | done |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 191 | |
Kailash | c06c9b6 | 2019-02-25 10:01:24 -0800 | [diff] [blame] | 192 | ## get voltha pod logs |
| 193 | for pod in \$(kubectl get pods -n voltha --no-headers | awk '{print \$1}'); |
| 194 | do |
| 195 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 196 | kubectl logs -n voltha \$pod onos> $WORKSPACE/\$pod.log; |
| 197 | else |
| 198 | kubectl logs -n voltha \$pod> $WORKSPACE/\$pod.log; |
| 199 | fi |
| 200 | done |
| 201 | |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 202 | # copy robot logs |
| 203 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 204 | cp -r /tmp/helm_test_bbsim_logs_*/*ml ./RobotLogs |
| 205 | |
| 206 | echo "# removing helm deployments" |
| 207 | kubectl get pods |
| 208 | helm list |
| 209 | |
| 210 | for hchart in \$(helm list -q); |
| 211 | do |
| 212 | echo "## Purging chart: \${hchart} ##" |
| 213 | helm delete --purge "\${hchart}" |
| 214 | done |
| 215 | |
| 216 | sudo minikube delete |
| 217 | ''' |
| 218 | step([$class: 'RobotPublisher', |
| 219 | disableArchiveOutput: false, |
| 220 | logFileName: 'RobotLogs/log*.html', |
| 221 | otherFiles: '', |
| 222 | outputFileName: 'RobotLogs/output*.xml', |
| 223 | outputPath: '.', |
| 224 | passThreshold: 100, |
| 225 | reportFileName: 'RobotLogs/report*.html', |
| 226 | unstableThreshold: 0]); |
Kailash | 2c1900c | 2019-02-11 12:18:27 -0800 | [diff] [blame] | 227 | archiveArtifacts artifacts: '*.log' |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 228 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false]) |
| 229 | |
| 230 | } |
| 231 | } |
| 232 | } |