Kailash | c8170bb | 2019-03-26 10:06:55 -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.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 | |
Kailash | d130320 | 2019-03-28 11:48:25 -0700 | [diff] [blame^] | 45 | stage('patch') { |
| 46 | steps { |
| 47 | sh ''' |
| 48 | pushd cord |
| 49 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 50 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 51 | popd |
| 52 | ''' |
| 53 | } |
| 54 | } |
| 55 | |
Kailash | c8170bb | 2019-03-26 10:06:55 -0700 | [diff] [blame] | 56 | stage('minikube') { |
| 57 | steps { |
| 58 | /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */ |
| 59 | sh ''' |
| 60 | export MINIKUBE_WANTUPDATENOTIFICATION=false |
| 61 | export MINIKUBE_WANTREPORTERRORPROMPT=false |
| 62 | export CHANGE_MINIKUBE_NONE_USER=true |
| 63 | export MINIKUBE_HOME=$HOME |
| 64 | mkdir -p $HOME/.kube || true |
| 65 | touch $HOME/.kube/config |
| 66 | export KUBECONFIG=$HOME/.kube/config |
| 67 | sudo -E /usr/bin/minikube start --vm-driver=none |
| 68 | ''' |
| 69 | script { |
| 70 | timeout(3) { |
| 71 | waitUntil { |
| 72 | sleep 5 |
| 73 | def kc_ret = sh script: "kubectl get po", returnStatus: true |
| 74 | return (kc_ret == 0); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | stage('helm') { |
| 82 | steps { |
| 83 | sh ''' |
| 84 | helm init |
| 85 | sleep 60 |
| 86 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 87 | ''' |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | stage ('Build XOS Core and TestService') { |
| 92 | steps { |
| 93 | sh """ |
| 94 | #!/usr/bin/env bash |
| 95 | set -eu -o pipefail |
| 96 | |
Kailash | c8170bb | 2019-03-26 10:06:55 -0700 | [diff] [blame] | 97 | cd $WORKSPACE/cord/orchestration/xos/containers/xos |
| 98 | make build |
| 99 | cd $WORKSPACE/cord/orchestration/xos/testservice |
Scott Baker | a07d5a3 | 2019-03-28 10:48:17 -0700 | [diff] [blame] | 100 | make DOCKER_TAG=candidate DOCKER_BUILD_ARGS=--no-cache DOCKER_REPOSITORY=xosproject/ docker-build |
Kailash | c8170bb | 2019-03-26 10:06:55 -0700 | [diff] [blame] | 101 | """ |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | stage('Install XOS w/TestService') { |
| 106 | steps { |
| 107 | sh """ |
| 108 | #!/usr/bin/env bash |
| 109 | set -eu -o pipefail |
| 110 | |
| 111 | pushd cord/helm-charts |
| 112 | helm dep update xos-core |
| 113 | helm install --set images.xos_core.tag=candidate,images.xos_core.pullPolicy=Never xos-core -n xos-core |
| 114 | |
| 115 | git clone https://gerrit.opencord.org/helm-repo-tools |
| 116 | helm-repo-tools/wait_for_pods.sh |
| 117 | |
| 118 | #install testservice |
Kailash | fe84038 | 2019-03-26 21:11:09 -0700 | [diff] [blame] | 119 | cd $WORKSPACE/cord/orchestration/xos/testservice/helm-charts |
Kailash | c8170bb | 2019-03-26 10:06:55 -0700 | [diff] [blame] | 120 | helm install -f testservice-devel.yaml testservice -n testservice |
| 121 | popd |
| 122 | """ |
| 123 | } |
| 124 | } |
| 125 | stage('Wait for Core') { |
| 126 | steps { |
| 127 | sh """ |
Kailash | fe84038 | 2019-03-26 21:11:09 -0700 | [diff] [blame] | 128 | #!/usr/bin/env bash |
| 129 | set -ex -o pipefail |
| 130 | |
Kailash | c8170bb | 2019-03-26 10:06:55 -0700 | [diff] [blame] | 131 | #wait for xos-core and models to be loaded |
| 132 | timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done" |
| 133 | """ |
| 134 | } |
| 135 | } |
| 136 | stage('Test Core') { |
| 137 | steps { |
| 138 | sh """ |
| 139 | #!/usr/bin/env bash |
| 140 | set -eu -o pipefail |
| 141 | pushd cord/test/cord-tester/src/test/cord-api/ |
| 142 | source setup_venv.sh |
| 143 | cd Tests/xos-test-service |
| 144 | robot -e notready test-service.robot || true |
| 145 | popd |
| 146 | """ |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | post { |
| 151 | always { |
| 152 | sh """ |
| 153 | kubectl get pods --all-namespaces |
| 154 | |
| 155 | # copy robot logs |
| 156 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
Kailash | fe84038 | 2019-03-26 21:11:09 -0700 | [diff] [blame] | 157 | cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/xos-test-service/*ml ./RobotLogs |
Kailash | c8170bb | 2019-03-26 10:06:55 -0700 | [diff] [blame] | 158 | echo "# removing helm deployments" |
| 159 | kubectl get pods |
| 160 | helm list |
| 161 | |
| 162 | for hchart in \$(helm list -q); |
| 163 | do |
| 164 | echo "## Purging chart: \${hchart} ##" |
| 165 | helm delete --purge "\${hchart}" |
| 166 | done |
| 167 | |
| 168 | sudo minikube delete |
| 169 | """ |
| 170 | step([$class: 'RobotPublisher', |
| 171 | disableArchiveOutput: false, |
| 172 | logFileName: 'RobotLogs/log*.html', |
| 173 | otherFiles: '', |
| 174 | outputFileName: 'RobotLogs/output*.xml', |
| 175 | outputPath: '.', |
| 176 | passThreshold: 100, |
| 177 | reportFileName: 'RobotLogs/report*.html', |
| 178 | unstableThreshold: 0]); |
| 179 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, teo@opennetworking.org", sendToIndividuals: false]) |
| 180 | |
| 181 | } |
| 182 | } |
| 183 | } |