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 { |
Zack Williams | b329208 | 2019-10-11 17:15:18 -0700 | [diff] [blame] | 23 | label "${params.buildNode}" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 24 | } |
| 25 | options { |
Andy Bavier | 5f4b2fa | 2019-10-03 07:48:49 -0700 | [diff] [blame] | 26 | timeout(time: 90, 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 """ |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 61 | git clone https://github.com/ciena/kind-voltha.git |
| 62 | cd kind-voltha/ |
Kailash | 9eac273 | 2019-09-03 18:05:48 -0700 | [diff] [blame] | 63 | DEPLOY_K8S=y JUST_K8S=y FANCY=0 ./voltha up |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 64 | """ |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | stage('Build Images') { |
| 69 | steps { |
| 70 | sh """ |
hwchiu | 9140fd2 | 2019-10-10 15:48:30 -0700 | [diff] [blame] | 71 | if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 72 | cd $WORKSPACE/voltha/${gerritProject}/ |
| 73 | make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 74 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 75 | """ |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | stage('Push Images') { |
| 80 | steps { |
| 81 | sh ''' |
hwchiu | 9140fd2 | 2019-10-10 15:48:30 -0700 | [diff] [blame] | 82 | if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 83 | export GOROOT=/usr/local/go |
| 84 | export GOPATH=\$(pwd) |
| 85 | export TYPE=minimal |
| 86 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 87 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Andy Bavier | e6f4190 | 2019-11-21 17:26:56 -0700 | [diff] [blame] | 88 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 89 | docker images | grep citest |
| 90 | 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 |
| 91 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 92 | ''' |
| 93 | } |
| 94 | } |
| 95 | stage('Deploy Voltha') { |
| 96 | steps { |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 97 | sh ''' |
Andy Bavier | 90f7470 | 2019-10-16 20:21:51 -0700 | [diff] [blame] | 98 | HELM_FLAG="${extraHelmFlags} " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 99 | |
| 100 | if [ "${gerritProject}" = "voltha-go" ]; then |
Zack Williams | e65b1ee | 2019-12-09 15:57:16 -0700 | [diff] [blame] | 101 | HELM_FLAG+="--set images.rw_core.tag=citest,images.rw_core.pullPolicy=Never,images.ro_core.tag=citest,images.ro_core.pullPolicy=Never " |
| 102 | fi |
| 103 | |
| 104 | if [ "${gerritProject}" = "ofagent-py" ]; then |
| 105 | HELM_FLAG+="--set images.ofagent.tag=citest,images.ofagent.pullPolicy=Never " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 106 | fi |
| 107 | |
| 108 | if [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 109 | HELM_FLAG+="--set images.adapter_open_olt.tag=citest,images.adapter_open_olt.pullPolicy=Never " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 110 | fi |
| 111 | |
| 112 | if [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 113 | HELM_FLAG+="--set images.adapter_open_onu.tag=citest,images.adapter_open_onu.pullPolicy=Never " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 114 | fi |
| 115 | |
Andy Bavier | a6f8e48 | 2019-10-24 08:22:30 -0700 | [diff] [blame] | 116 | if [ "${gerritProject}" = "bbsim" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 117 | HELM_FLAG+="--set images.bbsim.tag=citest,images.bbsim.pullPolicy=Never " |
Andy Bavier | c4183ba | 2019-09-30 15:40:18 -0700 | [diff] [blame] | 118 | fi |
| 119 | |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 120 | if [ "${gerritProject}" = "voltha-api-server" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 121 | HELM_FLAG+="--set images.afrouter.tag=citest,images.afrouter.pullPolicy=Never,images.afrouterd.tag=citest,images.afrouterd.pullPolicy=Never " |
Zack Williams | 0499750 | 2019-10-04 14:32:20 -0700 | [diff] [blame] | 122 | else |
Andy Bavier | bedd039 | 2019-10-16 13:58:18 -0700 | [diff] [blame] | 123 | # afrouter only has master branch at present |
Zack Williams | 0499750 | 2019-10-04 14:32:20 -0700 | [diff] [blame] | 124 | HELM_FLAG+="--set images.afrouter.tag=master,images.afrouterd.tag=master " |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 125 | fi |
| 126 | |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 127 | if [ "${gerritProject}" = "voltha-helm-charts" ]; then |
Andy Bavier | 4540634 | 2019-10-02 16:45:40 -0700 | [diff] [blame] | 128 | export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts |
| 129 | export VOLTHA_CHART=\$CHART_PATH/voltha |
| 130 | export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt |
| 131 | export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 132 | helm dep update \$VOLTHA_CHART |
| 133 | helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART |
| 134 | helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART |
| 135 | fi |
| 136 | |
| 137 | cd $WORKSPACE/kind-voltha/ |
Kailash | da9b656 | 2019-09-03 12:48:31 -0700 | [diff] [blame] | 138 | echo \$HELM_FLAG |
Andy Bavier | 3d8d528 | 2019-10-04 16:03:49 -0700 | [diff] [blame] | 139 | 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 WITH_SIM_ADAPTERS=n ./voltha up |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 140 | ''' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
| 144 | stage('Run E2E Tests') { |
| 145 | steps { |
| 146 | sh ''' |
| 147 | cd kind-voltha/ |
| 148 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 149 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Andy Bavier | e6f4190 | 2019-11-21 17:26:56 -0700 | [diff] [blame] | 150 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
Andy Bavier | 3708d07 | 2019-12-10 15:22:18 -0700 | [diff] [blame^] | 151 | export ROBOT_MISC_ARGS="-v teardown_device:False" |
Andy Bavier | aca510e | 2019-10-15 08:00:25 -0700 | [diff] [blame] | 152 | make -C $WORKSPACE/voltha/voltha-system-tests sanity-kind || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 153 | ''' |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | post { |
| 159 | always { |
| 160 | sh ''' |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 161 | set +e |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 162 | # copy robot logs |
| 163 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
Andy Bavier | 70f4b8f | 2019-10-15 08:34:49 -0700 | [diff] [blame] | 164 | cp -r $WORKSPACE/voltha/voltha-system-tests/tests/*/*.html ./RobotLogs || true |
| 165 | cp -r $WORKSPACE/voltha/voltha-system-tests/tests/*/*.xml ./RobotLogs || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 166 | cd kind-voltha/ |
| 167 | cp install-minimal.log $WORKSPACE/ |
| 168 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 169 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Andy Bavier | e6f4190 | 2019-11-21 17:26:56 -0700 | [diff] [blame] | 170 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
Andy Bavier | aec6038 | 2019-10-29 15:09:04 -0700 | [diff] [blame] | 171 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 172 | kubectl get nodes -o wide |
| 173 | kubectl get pods -o wide |
| 174 | kubectl get pods -n voltha -o wide |
| 175 | ## get default pod logs |
| 176 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 177 | do |
| 178 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 179 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 180 | else |
| 181 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 182 | fi |
| 183 | done |
| 184 | ## get voltha pod logs |
| 185 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 186 | do |
| 187 | if [[ \$pod == *"-api-"* ]]; then |
| 188 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 189 | else |
| 190 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 191 | fi |
| 192 | done |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 193 | ## clean up node |
Andy Bavier | 3d8d528 | 2019-10-04 16:03:49 -0700 | [diff] [blame] | 194 | FANCY=0 WAIT_ON_DOWN=y ./voltha down |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 195 | cd $WORKSPACE/ |
Andy Bavier | 70f4b8f | 2019-10-15 08:34:49 -0700 | [diff] [blame] | 196 | rm -rf kind-voltha/ voltha/ || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 197 | ''' |
| 198 | step([$class: 'RobotPublisher', |
| 199 | disableArchiveOutput: false, |
| 200 | logFileName: 'RobotLogs/log*.html', |
| 201 | otherFiles: '', |
| 202 | outputFileName: 'RobotLogs/output*.xml', |
| 203 | outputPath: '.', |
| 204 | passThreshold: 80, |
| 205 | reportFileName: 'RobotLogs/report*.html', |
| 206 | unstableThreshold: 0]); |
| 207 | archiveArtifacts artifacts: '*.log' |
| 208 | |
| 209 | } |
| 210 | } |
| 211 | } |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 212 | |