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