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" |
| 31 | PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 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}", \ |
| 52 | manifestBranch: "${params.manifestBranch}", \ |
| 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 """ |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 80 | git clone https://github.com/ciena/kind-voltha.git |
| 81 | cd kind-voltha/ |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 82 | JUST_K8S=y ./voltha up |
| 83 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 84 | """ |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | stage('Build Images') { |
| 89 | steps { |
| 90 | sh """ |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 91 | make-local () { |
| 92 | make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 93 | } |
Andy Bavier | 0ed7706 | 2020-02-18 10:09:19 -0700 | [diff] [blame] | 94 | if [ "${gerritProject}" = "pyvoltha" ]; then |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 95 | make -C $WORKSPACE/voltha/pyvoltha/ dist |
Andy Bavier | 0ed7706 | 2020-02-18 10:09:19 -0700 | [diff] [blame] | 96 | export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/ |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 97 | make-local voltha-openonu-adapter |
| 98 | elif [ "${gerritProject}" = "voltha-lib-go" ]; then |
| 99 | make -C $WORKSPACE/voltha/voltha-lib-go/ build |
| 100 | export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/ |
| 101 | make-local voltha-go |
| 102 | make-local voltha-openolt-adapter |
| 103 | elif [ "${gerritProject}" = "voltha-protos" ]; then |
| 104 | make -C $WORKSPACE/voltha/voltha-protos/ build |
| 105 | export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/ |
| 106 | make-local voltha-go |
| 107 | make-local voltha-openolt-adapter |
| 108 | make-local voltha-openonu-adapter |
| 109 | make-local ofagent-py |
Andy Bavier | 0ed7706 | 2020-02-18 10:09:19 -0700 | [diff] [blame] | 110 | elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 111 | make-local ${gerritProject} |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 112 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 113 | """ |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | stage('Push Images') { |
| 118 | steps { |
| 119 | sh ''' |
Andy Bavier | 0ed7706 | 2020-02-18 10:09:19 -0700 | [diff] [blame] | 120 | if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 121 | export GOROOT=/usr/local/go |
| 122 | export GOPATH=\$(pwd) |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 123 | docker images | grep citest |
| 124 | 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 |
| 125 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 126 | ''' |
| 127 | } |
| 128 | } |
| 129 | stage('Deploy Voltha') { |
| 130 | steps { |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 131 | sh ''' |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 132 | export EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${extraHelmFlags} " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 133 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 134 | IMAGES="" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 135 | if [ "${gerritProject}" = "voltha-go" ]; then |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 136 | IMAGES="rw_core ro_core " |
| 137 | elif [ "${gerritProject}" = "ofagent-py" ]; then |
| 138 | IMAGES="ofagent " |
| 139 | elif [ "${gerritProject}" = "voltha-onos" ]; then |
| 140 | IMAGES="onos " |
| 141 | elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
| 142 | IMAGES="adapter_open_olt " |
| 143 | elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
| 144 | IMAGES="adapter_open_onu " |
| 145 | elif [ "${gerritProject}" = "voltha-api-server" ]; then |
| 146 | IMAGES="afrouter afrouterd " |
| 147 | elif [ "${gerritProject}" = "bbsim" ]; then |
| 148 | IMAGES="bbsim " |
Andy Bavier | ec0c10d | 2020-02-14 13:06:27 -0700 | [diff] [blame] | 149 | elif [ "${gerritProject}" = "pyvoltha" ]; then |
| 150 | IMAGES="adapter_open_onu " |
Andy Bavier | b99c3d3 | 2020-02-18 11:14:17 -0700 | [diff] [blame] | 151 | elif [ "${gerritProject}" = "voltha-lib-go" ]; then |
| 152 | IMAGES="rw_core ro_core adapter_open_olt " |
| 153 | elif [ "${gerritProject}" = "voltha-protos" ]; then |
| 154 | IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent " |
Zack Williams | 0499750 | 2019-10-04 14:32:20 -0700 | [diff] [blame] | 155 | else |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 156 | echo "No images to push" |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 157 | fi |
| 158 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 159 | for I in \$IMAGES |
| 160 | do |
| 161 | EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never " |
| 162 | done |
| 163 | |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 164 | if [ "${gerritProject}" = "voltha-helm-charts" ]; then |
Andy Bavier | 4540634 | 2019-10-02 16:45:40 -0700 | [diff] [blame] | 165 | export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts |
| 166 | export VOLTHA_CHART=\$CHART_PATH/voltha |
| 167 | export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt |
| 168 | export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 169 | helm dep update \$VOLTHA_CHART |
| 170 | helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART |
| 171 | helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART |
| 172 | fi |
| 173 | |
| 174 | cd $WORKSPACE/kind-voltha/ |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 175 | echo \$EXTRA_HELM_FLAGS |
| 176 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 177 | ./voltha up |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 178 | ''' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
| 182 | stage('Run E2E Tests') { |
| 183 | steps { |
| 184 | sh ''' |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 185 | mkdir -p $WORKSPACE/RobotLogs |
Andy Bavier | db00308 | 2020-02-04 11:57:36 -0700 | [diff] [blame] | 186 | |
| 187 | # By default, all tests tagged 'sanity' are run. This covers basic functionality |
| 188 | # like running through the ATT workflow for a single subscriber. |
| 189 | export TEST_TAGS=sanity |
| 190 | |
| 191 | # If the Gerrit comment contains a line with "functional tests" then run the full |
| 192 | # functional test suite. This covers tests tagged either 'sanity' or 'functional'. |
| 193 | # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line |
| 194 | REGEX="functional tests" |
| 195 | if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then |
| 196 | TEST_TAGS=sanityORfunctional |
| 197 | fi |
| 198 | |
| 199 | make -C $WORKSPACE/voltha/voltha-system-tests single-kind || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 200 | ''' |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | post { |
| 206 | always { |
| 207 | sh ''' |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 208 | set +e |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 209 | cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/ |
Andy Bavier | aec6038 | 2019-10-29 15:09:04 -0700 | [diff] [blame] | 210 | 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] | 211 | kubectl get nodes -o wide |
| 212 | kubectl get pods -o wide |
| 213 | kubectl get pods -n voltha -o wide |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 214 | |
| 215 | sync |
| 216 | pkill kail || true |
| 217 | |
| 218 | ## Pull out errors from log files |
| 219 | extract_errors_go() { |
| 220 | echo |
| 221 | echo "Error summary for $1:" |
| 222 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 223 | echo |
| 224 | } |
| 225 | |
| 226 | extract_errors_python() { |
| 227 | echo |
| 228 | echo "Error summary for $1:" |
| 229 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 230 | echo |
| 231 | } |
| 232 | |
| 233 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 234 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 235 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 236 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 237 | |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 238 | gzip $WORKSPACE/onos-voltha-combined.log |
| 239 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 240 | ## shut down kind-voltha |
| 241 | cd $WORKSPACE/kind-voltha |
| 242 | WAIT_ON_DOWN=y ./voltha down |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 243 | ''' |
| 244 | step([$class: 'RobotPublisher', |
| 245 | disableArchiveOutput: false, |
| 246 | logFileName: 'RobotLogs/log*.html', |
| 247 | otherFiles: '', |
| 248 | outputFileName: 'RobotLogs/output*.xml', |
| 249 | outputPath: '.', |
| 250 | passThreshold: 80, |
| 251 | reportFileName: 'RobotLogs/report*.html', |
| 252 | unstableThreshold: 0]); |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 253 | archiveArtifacts artifacts: '*.log,*.gz' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | } |