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 | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 26 | timeout(time: 90, unit: 'MINUTES') |
| 27 | } |
| 28 | environment { |
| 29 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 30 | VOLTCONFIG="$HOME/.volt/config-minimal" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 31 | PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 32 | TYPE="minimal" |
| 33 | FANCY=0 |
| 34 | WITH_SIM_ADAPTERS="n" |
| 35 | WITH_RADIUS="y" |
| 36 | WITH_BBSIM="y" |
| 37 | DEPLOY_K8S="y" |
| 38 | VOLTHA_LOG_LEVEL="DEBUG" |
| 39 | CONFIG_SADIS="n" |
Andy Bavier | e234fa5 | 2020-02-24 11:32:03 -0700 | [diff] [blame] | 40 | ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | stages { |
| 44 | |
| 45 | stage('Repo') { |
| 46 | steps { |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 47 | step([$class: 'WsCleanup']) |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 48 | checkout(changelog: false, \ |
| 49 | poll: false, |
| 50 | scm: [$class: 'RepoScm', \ |
| 51 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 52 | manifestBranch: "${params.branch}", \ |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 53 | currentBranch: true, \ |
| 54 | destinationDir: 'voltha', \ |
| 55 | forceSync: true, |
| 56 | resetFirst: true, \ |
| 57 | quiet: true, \ |
| 58 | jobs: 4, \ |
| 59 | showAllChanges: true] \ |
| 60 | ) |
| 61 | } |
| 62 | } |
| 63 | stage('Patch') { |
| 64 | steps { |
| 65 | sh """ |
| 66 | pushd voltha |
Andy Bavier | b35171c | 2020-03-06 15:47:29 -0700 | [diff] [blame] | 67 | if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ] |
| 68 | then |
| 69 | repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 70 | else |
| 71 | echo "No patchset to download!" |
| 72 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 73 | popd |
| 74 | """ |
| 75 | } |
| 76 | } |
| 77 | stage('Create K8s Cluster') { |
| 78 | steps { |
| 79 | sh """ |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 80 | if [ "${branch}" != "master" ]; then |
| 81 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 82 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 83 | else |
| 84 | echo "on master, using default settings for kind-voltha" |
| 85 | fi |
| 86 | |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 87 | cd $WORKSPACE/voltha/kind-voltha/ |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 88 | JUST_K8S=y ./voltha up |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 89 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 90 | """ |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | stage('Build Images') { |
| 95 | steps { |
| 96 | sh """ |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 97 | make-local () { |
| 98 | make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 99 | } |
Andy Bavier | 0ed7706 | 2020-02-18 10:09:19 -0700 | [diff] [blame] | 100 | if [ "${gerritProject}" = "pyvoltha" ]; then |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 101 | make -C $WORKSPACE/voltha/pyvoltha/ dist |
Andy Bavier | 0ed7706 | 2020-02-18 10:09:19 -0700 | [diff] [blame] | 102 | export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/ |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 103 | make-local voltha-openonu-adapter |
| 104 | elif [ "${gerritProject}" = "voltha-lib-go" ]; then |
| 105 | make -C $WORKSPACE/voltha/voltha-lib-go/ build |
| 106 | export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/ |
| 107 | make-local voltha-go |
| 108 | make-local voltha-openolt-adapter |
| 109 | elif [ "${gerritProject}" = "voltha-protos" ]; then |
| 110 | make -C $WORKSPACE/voltha/voltha-protos/ build |
| 111 | export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/ |
| 112 | make-local voltha-go |
| 113 | make-local voltha-openolt-adapter |
| 114 | make-local voltha-openonu-adapter |
| 115 | make-local ofagent-py |
Andy Bavier | 178c47b | 2020-04-01 13:05:43 -0700 | [diff] [blame] | 116 | elif [ "${gerritProject}" = "voltctl" ]; then |
Andy Bavier | decde3f | 2020-04-01 15:29:43 -0700 | [diff] [blame] | 117 | # Set and handle GOPATH and PATH |
| 118 | export GOPATH=\${GOPATH:-$WORKSPACE/go} |
| 119 | export PATH=\$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:\$GOPATH/bin |
Andy Bavier | 178c47b | 2020-04-01 13:05:43 -0700 | [diff] [blame] | 120 | make -C $WORKSPACE/voltha/voltctl/ build |
Andy Bavier | 4318f8d | 2020-04-09 13:50:53 -0700 | [diff] [blame] | 121 | elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|kind-voltha)\$ ]]; then |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 122 | make-local ${gerritProject} |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 123 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 124 | """ |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | stage('Push Images') { |
| 129 | steps { |
| 130 | sh ''' |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 131 | if [ "${branch}" != "master" ]; then |
| 132 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 133 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 134 | else |
| 135 | echo "on master, using default settings for kind-voltha" |
| 136 | fi |
| 137 | |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 138 | if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|voltctl|kind-voltha)\$ ]]; then |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 139 | export GOROOT=/usr/local/go |
| 140 | export GOPATH=\$(pwd) |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 141 | docker images | grep citest |
| 142 | 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 |
| 143 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 144 | ''' |
| 145 | } |
| 146 | } |
| 147 | stage('Deploy Voltha') { |
| 148 | steps { |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 149 | sh ''' |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 150 | if [ "${branch}" != "master" ]; then |
| 151 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 152 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 153 | else |
| 154 | echo "on master, using default settings for kind-voltha" |
| 155 | fi |
| 156 | |
| 157 | export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 158 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 159 | IMAGES="" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 160 | if [ "${gerritProject}" = "voltha-go" ]; then |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 161 | IMAGES="rw_core ro_core " |
| 162 | elif [ "${gerritProject}" = "ofagent-py" ]; then |
Andy Bavier | 8d81642 | 2020-03-23 15:34:26 -0700 | [diff] [blame] | 163 | IMAGES="ofagent_py " |
| 164 | EXTRA_HELM_FLAGS+="--set use_ofagent_go=false " |
Andy Bavier | 9c412a8 | 2020-03-23 12:00:28 -0700 | [diff] [blame] | 165 | elif [ "${gerritProject}" = "ofagent-go" ]; then |
Andy Bavier | 8d81642 | 2020-03-23 15:34:26 -0700 | [diff] [blame] | 166 | IMAGES="ofagent_go " |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 167 | elif [ "${gerritProject}" = "voltha-onos" ]; then |
| 168 | IMAGES="onos " |
| 169 | elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
| 170 | IMAGES="adapter_open_olt " |
| 171 | elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
| 172 | IMAGES="adapter_open_onu " |
| 173 | elif [ "${gerritProject}" = "voltha-api-server" ]; then |
| 174 | IMAGES="afrouter afrouterd " |
| 175 | elif [ "${gerritProject}" = "bbsim" ]; then |
| 176 | IMAGES="bbsim " |
Andy Bavier | ec0c10d | 2020-02-14 13:06:27 -0700 | [diff] [blame] | 177 | elif [ "${gerritProject}" = "pyvoltha" ]; then |
| 178 | IMAGES="adapter_open_onu " |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 179 | elif [ "${gerritProject}" = "voltha-lib-go" ]; then |
| 180 | IMAGES="rw_core ro_core adapter_open_olt " |
| 181 | elif [ "${gerritProject}" = "voltha-protos" ]; then |
| 182 | IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent " |
Zack Williams | 0499750 | 2019-10-04 14:32:20 -0700 | [diff] [blame] | 183 | else |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 184 | echo "No images to push" |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 185 | fi |
| 186 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 187 | for I in \$IMAGES |
| 188 | do |
| 189 | EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never " |
| 190 | done |
| 191 | |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 192 | if [ "${gerritProject}" = "voltha-helm-charts" ]; then |
Andy Bavier | 4540634 | 2019-10-02 16:45:40 -0700 | [diff] [blame] | 193 | export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts |
| 194 | export VOLTHA_CHART=\$CHART_PATH/voltha |
| 195 | export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt |
| 196 | export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 197 | helm dep update \$VOLTHA_CHART |
| 198 | helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART |
| 199 | helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART |
| 200 | fi |
| 201 | |
Andy Bavier | 178c47b | 2020-04-01 13:05:43 -0700 | [diff] [blame] | 202 | if [ "${gerritProject}" = "voltctl" ]; then |
| 203 | export VOLTCTL_VERSION=$(cat $WORKSPACE/voltha/voltctl/VERSION) |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 204 | cp $WORKSPACE/voltha/voltctl/voltctl $WORKSPACE/voltha/kind-voltha/bin/voltctl |
| 205 | md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl |
Andy Bavier | 178c47b | 2020-04-01 13:05:43 -0700 | [diff] [blame] | 206 | fi |
| 207 | |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 208 | cd $WORKSPACE/voltha/kind-voltha/ |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 209 | echo \$EXTRA_HELM_FLAGS |
| 210 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 211 | ./voltha up |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 212 | ''' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
| 216 | stage('Run E2E Tests') { |
| 217 | steps { |
| 218 | sh ''' |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 219 | mkdir -p $WORKSPACE/RobotLogs |
Andy Bavier | db00308 | 2020-02-04 11:57:36 -0700 | [diff] [blame] | 220 | |
| 221 | # By default, all tests tagged 'sanity' are run. This covers basic functionality |
| 222 | # like running through the ATT workflow for a single subscriber. |
| 223 | export TEST_TAGS=sanity |
| 224 | |
| 225 | # If the Gerrit comment contains a line with "functional tests" then run the full |
| 226 | # functional test suite. This covers tests tagged either 'sanity' or 'functional'. |
| 227 | # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line |
| 228 | REGEX="functional tests" |
| 229 | if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then |
| 230 | TEST_TAGS=sanityORfunctional |
| 231 | fi |
| 232 | |
| 233 | make -C $WORKSPACE/voltha/voltha-system-tests single-kind || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 234 | ''' |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | post { |
| 240 | always { |
| 241 | sh ''' |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 242 | set +e |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 243 | cp $WORKSPACE/voltha/kind-voltha/install-minimal.log $WORKSPACE/ |
Andy Bavier | aec6038 | 2019-10-29 15:09:04 -0700 | [diff] [blame] | 244 | 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] | 245 | kubectl get nodes -o wide |
| 246 | kubectl get pods -o wide |
| 247 | kubectl get pods -n voltha -o wide |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 248 | |
| 249 | sync |
| 250 | pkill kail || true |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 251 | md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 252 | |
| 253 | ## Pull out errors from log files |
| 254 | extract_errors_go() { |
| 255 | echo |
| 256 | echo "Error summary for $1:" |
| 257 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 258 | echo |
| 259 | } |
| 260 | |
| 261 | extract_errors_python() { |
| 262 | echo |
| 263 | echo "Error summary for $1:" |
| 264 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 265 | echo |
| 266 | } |
| 267 | |
| 268 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 269 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 270 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 271 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 272 | |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 273 | gzip $WORKSPACE/onos-voltha-combined.log |
| 274 | |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 275 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 276 | ## shut down kind-voltha |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 277 | if [ "${branch}" != "master" ]; then |
| 278 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 279 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 280 | else |
| 281 | echo "on master, using default settings for kind-voltha" |
| 282 | fi |
| 283 | |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 284 | cd $WORKSPACE/voltha/kind-voltha |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 285 | WAIT_ON_DOWN=y ./voltha down |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 286 | ''' |
| 287 | step([$class: 'RobotPublisher', |
| 288 | disableArchiveOutput: false, |
| 289 | logFileName: 'RobotLogs/log*.html', |
| 290 | otherFiles: '', |
| 291 | outputFileName: 'RobotLogs/output*.xml', |
| 292 | outputPath: '.', |
| 293 | passThreshold: 80, |
| 294 | reportFileName: 'RobotLogs/report*.html', |
| 295 | unstableThreshold: 0]); |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 296 | archiveArtifacts artifacts: '*.log,*.gz' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | } |