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" |
| 40 | ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs -v teardown_device:False" |
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 |
| 67 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 68 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 69 | popd |
| 70 | """ |
| 71 | } |
| 72 | } |
| 73 | stage('Create K8s Cluster') { |
| 74 | steps { |
| 75 | sh """ |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 76 | git clone https://github.com/ciena/kind-voltha.git |
| 77 | cd kind-voltha/ |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 78 | JUST_K8S=y ./voltha up |
| 79 | 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] | 80 | """ |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | stage('Build Images') { |
| 85 | steps { |
| 86 | sh """ |
hwchiu | 9140fd2 | 2019-10-10 15:48:30 -0700 | [diff] [blame] | 87 | if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 88 | cd $WORKSPACE/voltha/${gerritProject}/ |
| 89 | make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 90 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 91 | """ |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | stage('Push Images') { |
| 96 | steps { |
| 97 | sh ''' |
hwchiu | 9140fd2 | 2019-10-10 15:48:30 -0700 | [diff] [blame] | 98 | if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 99 | export GOROOT=/usr/local/go |
| 100 | export GOPATH=\$(pwd) |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 101 | docker images | grep citest |
| 102 | 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 |
| 103 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 104 | ''' |
| 105 | } |
| 106 | } |
| 107 | stage('Deploy Voltha') { |
| 108 | steps { |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 109 | sh ''' |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 110 | export EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${extraHelmFlags} " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 111 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 112 | IMAGES="" |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 113 | if [ "${gerritProject}" = "voltha-go" ]; then |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 114 | IMAGES="rw_core ro_core " |
| 115 | elif [ "${gerritProject}" = "ofagent-py" ]; then |
| 116 | IMAGES="ofagent " |
| 117 | elif [ "${gerritProject}" = "voltha-onos" ]; then |
| 118 | IMAGES="onos " |
| 119 | elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
| 120 | IMAGES="adapter_open_olt " |
| 121 | elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
| 122 | IMAGES="adapter_open_onu " |
| 123 | elif [ "${gerritProject}" = "voltha-api-server" ]; then |
| 124 | IMAGES="afrouter afrouterd " |
| 125 | elif [ "${gerritProject}" = "bbsim" ]; then |
| 126 | IMAGES="bbsim " |
Zack Williams | 0499750 | 2019-10-04 14:32:20 -0700 | [diff] [blame] | 127 | else |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 128 | echo "No images to push" |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 129 | fi |
| 130 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 131 | for I in \$IMAGES |
| 132 | do |
| 133 | EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never " |
| 134 | done |
| 135 | |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 136 | if [ "${gerritProject}" = "voltha-helm-charts" ]; then |
Andy Bavier | 4540634 | 2019-10-02 16:45:40 -0700 | [diff] [blame] | 137 | export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts |
| 138 | export VOLTHA_CHART=\$CHART_PATH/voltha |
| 139 | export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt |
| 140 | export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 141 | helm dep update \$VOLTHA_CHART |
| 142 | helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART |
| 143 | helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART |
| 144 | fi |
| 145 | |
| 146 | cd $WORKSPACE/kind-voltha/ |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 147 | echo \$EXTRA_HELM_FLAGS |
| 148 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 149 | ./voltha up |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 150 | ''' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
Matteo Scandolo | 84e5f00 | 2020-02-10 11:50:05 -0800 | [diff] [blame^] | 154 | stage('ONOS Config') { |
| 155 | steps { |
| 156 | sh ''' |
| 157 | if [[ ${onosVersion} == "1.13.10" ]]; then |
| 158 | curl -sSL --user karaf:karaf \ |
| 159 | -X POST \ |
| 160 | -H Content-Type:application/json \ |
| 161 | http://localhost:8181/onos/v1/network/configuration/apps \ |
| 162 | --data @- << EOF |
| 163 | { |
| 164 | "org.opencord.sadis":{ |
| 165 | "sadis":{ |
| 166 | "integration":{ |
| 167 | "cache":{ |
| 168 | "enabled":false, |
| 169 | "maxsize":50, |
| 170 | "ttl":"PT0m" |
| 171 | } |
| 172 | }, |
| 173 | "entries":[ |
| 174 | { |
| 175 | "id":"BBSIM_OLT_0", |
| 176 | "hardwareIdentifier":"0f:f1:ce:c0:ff:ee", |
| 177 | "nasId":"BBSIMOLT000", |
| 178 | "uplinkPort":1048576 |
| 179 | }, |
| 180 | { |
| 181 | "id":"BBSM00000001-1", |
| 182 | "nasPortId":"BBSM00000001-1", |
| 183 | "circuitId":"BBSM00000001-1", |
| 184 | "remoteId":"BBSM00000001-1", |
| 185 | "uniTagList":[ |
| 186 | { |
| 187 | "ponCTag":900, |
| 188 | "ponSTag":900, |
| 189 | "technologyProfileId":64, |
| 190 | "downstreamBandwidthProfile":"Default", |
| 191 | "upstreamBandwidthProfile":"Default", |
| 192 | "isDhcpRequired":true |
| 193 | } |
| 194 | ] |
| 195 | } |
| 196 | ] |
| 197 | }, |
| 198 | "bandwidthprofile":{ |
| 199 | "integration":{ |
| 200 | "cache":{ |
| 201 | "enabled":true, |
| 202 | "maxsize":40, |
| 203 | "ttl":"PT1m" |
| 204 | } |
| 205 | }, |
| 206 | "entries":[ |
| 207 | { |
| 208 | "id":"Default", |
| 209 | "cir":1000000, |
| 210 | "cbs":1001, |
| 211 | "eir":1002, |
| 212 | "ebs":1003, |
| 213 | "air":1004 |
| 214 | } |
| 215 | ] |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | EOF |
| 220 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.opencord.olt.impl.OltFlowService enableDhcpOnProvisioning true" |
| 221 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.opencord.olt.impl.OltFlowService enableDhcpV4 true" |
| 222 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.opencord.olt.impl.OltFlowService enableEapol true" |
| 223 | else |
| 224 | echo "Using kind-voltha defaults" |
| 225 | fi |
| 226 | ''' |
| 227 | } |
| 228 | } |
| 229 | |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 230 | stage('Run E2E Tests') { |
| 231 | steps { |
| 232 | sh ''' |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 233 | mkdir -p $WORKSPACE/RobotLogs |
Andy Bavier | db00308 | 2020-02-04 11:57:36 -0700 | [diff] [blame] | 234 | |
| 235 | # By default, all tests tagged 'sanity' are run. This covers basic functionality |
| 236 | # like running through the ATT workflow for a single subscriber. |
| 237 | export TEST_TAGS=sanity |
| 238 | |
| 239 | # If the Gerrit comment contains a line with "functional tests" then run the full |
| 240 | # functional test suite. This covers tests tagged either 'sanity' or 'functional'. |
| 241 | # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line |
| 242 | REGEX="functional tests" |
| 243 | if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then |
| 244 | TEST_TAGS=sanityORfunctional |
| 245 | fi |
| 246 | |
| 247 | make -C $WORKSPACE/voltha/voltha-system-tests single-kind || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 248 | ''' |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | post { |
| 254 | always { |
| 255 | sh ''' |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 256 | set +e |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 257 | cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/ |
Andy Bavier | aec6038 | 2019-10-29 15:09:04 -0700 | [diff] [blame] | 258 | 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] | 259 | kubectl get nodes -o wide |
| 260 | kubectl get pods -o wide |
| 261 | kubectl get pods -n voltha -o wide |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 262 | |
| 263 | sync |
| 264 | pkill kail || true |
| 265 | |
| 266 | ## Pull out errors from log files |
| 267 | extract_errors_go() { |
| 268 | echo |
| 269 | echo "Error summary for $1:" |
| 270 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 271 | echo |
| 272 | } |
| 273 | |
| 274 | extract_errors_python() { |
| 275 | echo |
| 276 | echo "Error summary for $1:" |
| 277 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 278 | echo |
| 279 | } |
| 280 | |
| 281 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 282 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 283 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 284 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 285 | |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 286 | gzip $WORKSPACE/onos-voltha-combined.log |
| 287 | |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 288 | ## shut down kind-voltha |
| 289 | cd $WORKSPACE/kind-voltha |
| 290 | WAIT_ON_DOWN=y ./voltha down |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 291 | ''' |
| 292 | step([$class: 'RobotPublisher', |
| 293 | disableArchiveOutput: false, |
| 294 | logFileName: 'RobotLogs/log*.html', |
| 295 | otherFiles: '', |
| 296 | outputFileName: 'RobotLogs/output*.xml', |
| 297 | outputPath: '.', |
| 298 | passThreshold: 80, |
| 299 | reportFileName: 'RobotLogs/report*.html', |
| 300 | unstableThreshold: 0]); |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 301 | archiveArtifacts artifacts: '*.log,*.gz' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 302 | |
| 303 | } |
| 304 | } |
| 305 | } |