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 | f2688e0 | 2019-03-18 21:11:13 -0700 | [diff] [blame] | 139 | helm install --set images.bbsim.tag=latest --set images.bbsim.pullPolicy=IfNotPresent --set onus_per_pon_port=${params.OnuCount} 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 |
| 145 | popd |
| 146 | """ |
| 147 | } |
| 148 | } |
Kailash | d029488 | 2019-03-19 13:23:32 -0700 | [diff] [blame] | 149 | stage('Load BBSIM-DHCP Tosca') { |
| 150 | steps { |
| 151 | sh ''' |
| 152 | #!/usr/bin/env bash |
| 153 | set -eu -o pipefail |
| 154 | pushd cord/helm-charts |
| 155 | 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 |
| 156 | popd |
| 157 | ''' |
| 158 | } |
| 159 | } |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 160 | stage('Test BBSIM') { |
| 161 | steps { |
Kailash | ef0be3d | 2019-03-19 09:21:22 -0700 | [diff] [blame] | 162 | sh """ |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 163 | #!/usr/bin/env bash |
| 164 | set -eu -o pipefail |
Kailash | f2688e0 | 2019-03-18 21:11:13 -0700 | [diff] [blame] | 165 | pushd cord/test/cord-tester/src/test/cord-api/Tests/BBSim/ |
| 166 | robot -e notready -v number_of_onus:${params.OnuCount} BBSIMScale.robot || true |
Kailash | ef0be3d | 2019-03-19 09:21:22 -0700 | [diff] [blame] | 167 | """ |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | } |
Kailash | d029488 | 2019-03-19 13:23:32 -0700 | [diff] [blame] | 171 | |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 172 | post { |
| 173 | always { |
| 174 | sh ''' |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 175 | kubectl get pods --all-namespaces |
Kailash | c06c9b6 | 2019-02-25 10:01:24 -0800 | [diff] [blame] | 176 | ## get default pod logs |
Kailash | 2c1900c | 2019-02-11 12:18:27 -0800 | [diff] [blame] | 177 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 178 | do |
| 179 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 180 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 181 | else |
| 182 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 183 | fi |
| 184 | done |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 185 | |
Kailash | c06c9b6 | 2019-02-25 10:01:24 -0800 | [diff] [blame] | 186 | ## get voltha pod logs |
| 187 | for pod in \$(kubectl get pods -n voltha --no-headers | awk '{print \$1}'); |
| 188 | do |
| 189 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 190 | kubectl logs -n voltha \$pod onos> $WORKSPACE/\$pod.log; |
| 191 | else |
| 192 | kubectl logs -n voltha \$pod> $WORKSPACE/\$pod.log; |
| 193 | fi |
| 194 | done |
| 195 | |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 196 | # copy robot logs |
| 197 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
Kailash | f2688e0 | 2019-03-18 21:11:13 -0700 | [diff] [blame] | 198 | cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/BBSim/*ml ./RobotLogs |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 199 | |
| 200 | echo "# removing helm deployments" |
| 201 | kubectl get pods |
| 202 | helm list |
| 203 | |
| 204 | for hchart in \$(helm list -q); |
| 205 | do |
| 206 | echo "## Purging chart: \${hchart} ##" |
| 207 | helm delete --purge "\${hchart}" |
| 208 | done |
| 209 | |
| 210 | sudo minikube delete |
| 211 | ''' |
| 212 | step([$class: 'RobotPublisher', |
| 213 | disableArchiveOutput: false, |
| 214 | logFileName: 'RobotLogs/log*.html', |
| 215 | otherFiles: '', |
| 216 | outputFileName: 'RobotLogs/output*.xml', |
| 217 | outputPath: '.', |
| 218 | passThreshold: 100, |
| 219 | reportFileName: 'RobotLogs/report*.html', |
| 220 | unstableThreshold: 0]); |
Kailash | 2c1900c | 2019-02-11 12:18:27 -0800 | [diff] [blame] | 221 | archiveArtifacts artifacts: '*.log' |
Kailash | 46a2a9a | 2019-01-23 12:39:04 -0800 | [diff] [blame] | 222 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false]) |
| 223 | |
| 224 | } |
| 225 | } |
| 226 | } |