Kailash | aad7101 | 2019-08-27 10:36:53 -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 | // voltha-2.x e2e tests |
| 16 | // uses kind-voltha to deploy voltha-2.X |
| 17 | // uses bbsim to simulate OLT/ONUs |
| 18 | |
| 19 | pipeline { |
| 20 | |
| 21 | /* no label, executor is determined by JJB */ |
| 22 | agent { |
| 23 | label "${params.executorNode}" |
| 24 | } |
| 25 | options { |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 26 | timeout(time: 120, unit: 'MINUTES') |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | stages { |
| 30 | |
| 31 | stage('Repo') { |
| 32 | steps { |
| 33 | checkout(changelog: false, \ |
| 34 | poll: false, |
| 35 | scm: [$class: 'RepoScm', \ |
| 36 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 37 | manifestBranch: "${params.manifestBranch}", \ |
| 38 | currentBranch: true, \ |
| 39 | destinationDir: 'voltha', \ |
| 40 | forceSync: true, |
| 41 | resetFirst: true, \ |
| 42 | quiet: true, \ |
| 43 | jobs: 4, \ |
| 44 | showAllChanges: true] \ |
| 45 | ) |
| 46 | } |
| 47 | } |
| 48 | stage('Patch') { |
| 49 | steps { |
| 50 | sh """ |
| 51 | pushd voltha |
| 52 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 53 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 54 | popd |
| 55 | """ |
| 56 | } |
| 57 | } |
| 58 | stage('Create K8s Cluster') { |
| 59 | steps { |
| 60 | sh """ |
| 61 | git clone https://gerrit.opencord.org/voltha-system-tests |
| 62 | git clone https://github.com/ciena/kind-voltha.git |
| 63 | cd kind-voltha/ |
Kailash | 9eac273 | 2019-09-03 18:05:48 -0700 | [diff] [blame] | 64 | DEPLOY_K8S=y JUST_K8S=y FANCY=0 ./voltha up |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 65 | """ |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | stage('Build Images') { |
| 70 | steps { |
| 71 | sh """ |
| 72 | cd $WORKSPACE/voltha/${gerritProject}/ |
Kailash | 9eac273 | 2019-09-03 18:05:48 -0700 | [diff] [blame] | 73 | make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 74 | """ |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | stage('Push Images') { |
| 79 | steps { |
| 80 | sh ''' |
| 81 | export GOROOT=/usr/local/go |
| 82 | export GOPATH=\$(pwd) |
| 83 | export TYPE=minimal |
| 84 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 85 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Kailash | eadb2e2 | 2019-09-05 10:30:06 -0700 | [diff] [blame] | 86 | export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 87 | docker images | grep citest |
| 88 | for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; done |
| 89 | ''' |
| 90 | } |
| 91 | } |
| 92 | stage('Deploy Voltha') { |
| 93 | steps { |
| 94 | sh """ |
Kailash | 25f7a70 | 2019-09-05 11:43:11 -0700 | [diff] [blame] | 95 | HELM_FLAG="--set defaults.image_tag=voltha-2.1 " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 96 | |
| 97 | if [ "${gerritProject}" = "voltha-go" ]; then |
| 98 | HELM_FLAG+="-f $WORKSPACE/voltha-system-tests/tests/data/ci-test.yaml" |
| 99 | fi |
| 100 | |
| 101 | if [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
| 102 | HELM_FLAG+="--set images.adapter_open_olt.tag=citest,images.adapter_open_olt.pullPolicy=Never" |
| 103 | fi |
| 104 | |
| 105 | if [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
| 106 | HELM_FLAG+="--set images.adapter_open_onu.tag=citest,images.adapter_open_onu.pullPolicy=Never" |
| 107 | fi |
| 108 | |
| 109 | cd kind-voltha/ |
Kailash | da9b656 | 2019-09-03 12:48:31 -0700 | [diff] [blame] | 110 | echo \$HELM_FLAG |
| 111 | EXTRA_HELM_FLAGS=\$HELM_FLAG VOLTHA_LOG_LEVEL=DEBUG TYPE=minimal WITH_RADIUS=y WITH_BBSIM=y INSTALL_ONOS_APPS=y CONFIG_SADIS=y FANCY=0 ./voltha up |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 112 | """ |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | stage('Run E2E Tests') { |
| 117 | steps { |
| 118 | sh ''' |
| 119 | cd kind-voltha/ |
| 120 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 121 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Kailash | eadb2e2 | 2019-09-05 10:30:06 -0700 | [diff] [blame] | 122 | export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 123 | cd $WORKSPACE/voltha-system-tests/tests/sanity |
Kailash | 184cbea | 2019-09-11 13:54:47 -0700 | [diff] [blame] | 124 | robot -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101 -e notready --critical sanity --noncritical VOL-1705 -v num_onus:1 sanity.robot || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 125 | ''' |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | post { |
| 131 | always { |
| 132 | sh ''' |
| 133 | # copy robot logs |
| 134 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 135 | cp -r $WORKSPACE/voltha-system-tests/tests/sanity/*ml ./RobotLogs || true |
| 136 | cd kind-voltha/ |
| 137 | cp install-minimal.log $WORKSPACE/ |
| 138 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 139 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Kailash | eadb2e2 | 2019-09-05 10:30:06 -0700 | [diff] [blame] | 140 | export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 141 | kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s "[[:space:]]" "\n" | sort | uniq -c |
| 142 | kubectl get nodes -o wide |
| 143 | kubectl get pods -o wide |
| 144 | kubectl get pods -n voltha -o wide |
| 145 | ## get default pod logs |
| 146 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 147 | do |
| 148 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 149 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 150 | else |
| 151 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 152 | fi |
| 153 | done |
| 154 | ## get voltha pod logs |
| 155 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 156 | do |
| 157 | if [[ \$pod == *"-api-"* ]]; then |
| 158 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 159 | else |
| 160 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 161 | fi |
| 162 | done |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 163 | ## clean up node |
Andy Bavier | 3a58ba3 | 2019-09-20 16:31:40 -0700 | [diff] [blame] | 164 | WAIT_ON_DOWN=y ./voltha down |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 165 | cd $WORKSPACE/ |
| 166 | rm -rf kind-voltha/ voltha-system-tests/ || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 167 | ''' |
| 168 | step([$class: 'RobotPublisher', |
| 169 | disableArchiveOutput: false, |
| 170 | logFileName: 'RobotLogs/log*.html', |
| 171 | otherFiles: '', |
| 172 | outputFileName: 'RobotLogs/output*.xml', |
| 173 | outputPath: '.', |
| 174 | passThreshold: 80, |
| 175 | reportFileName: 'RobotLogs/report*.html', |
| 176 | unstableThreshold: 0]); |
| 177 | archiveArtifacts artifacts: '*.log' |
| 178 | |
| 179 | } |
| 180 | } |
| 181 | } |