blob: 509e7cae8c90f9565df97d8aa9d19faf91896210 [file] [log] [blame]
Kailashaad71012019-08-27 10:36:53 -07001// 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
19pipeline {
20
21 /* no label, executor is determined by JJB */
22 agent {
Zack Williamsb3292082019-10-11 17:15:18 -070023 label "${params.buildNode}"
Kailashaad71012019-08-27 10:36:53 -070024 }
25 options {
Andy Bavier4af02722020-01-15 10:24:24 -070026 timeout(time: 90, unit: 'MINUTES')
27 }
28 environment {
Andy Bavierb5c8caf2020-04-06 14:12:07 -070029 PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Andy Bavier8b118b72020-04-28 12:59:30 -070030 VOLTHA_LOG_LEVEL="DEBUG"
Andy Bavier4af02722020-01-15 10:24:24 -070031 FANCY=0
32 WITH_SIM_ADAPTERS="n"
Matteo Scandolo39045a92020-07-29 08:58:29 -070033 NAME="test"
34 VOLTCONFIG="$HOME/.volt/config-$NAME"
35 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"
Kailashaad71012019-08-27 10:36:53 -070036 }
37
38 stages {
39
40 stage('Repo') {
41 steps {
Andy Bavier4af02722020-01-15 10:24:24 -070042 step([$class: 'WsCleanup'])
Kailashaad71012019-08-27 10:36:53 -070043 checkout(changelog: false, \
44 poll: false,
45 scm: [$class: 'RepoScm', \
46 manifestRepositoryUrl: "${params.manifestUrl}", \
Zack Williams03ebb272020-03-27 09:42:33 -070047 manifestBranch: "${params.branch}", \
Kailashaad71012019-08-27 10:36:53 -070048 currentBranch: true, \
49 destinationDir: 'voltha', \
50 forceSync: true,
51 resetFirst: true, \
52 quiet: true, \
53 jobs: 4, \
54 showAllChanges: true] \
55 )
56 }
57 }
58 stage('Patch') {
59 steps {
60 sh """
61 pushd voltha
Andy Bavierb35171c2020-03-06 15:47:29 -070062 if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ]
63 then
64 repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
65 else
66 echo "No patchset to download!"
67 fi
Kailashaad71012019-08-27 10:36:53 -070068 popd
69 """
70 }
71 }
72 stage('Create K8s Cluster') {
73 steps {
74 sh """
Zack Williams03ebb272020-03-27 09:42:33 -070075 if [ "${branch}" != "master" ]; then
76 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andy Bavierb5c8caf2020-04-06 14:12:07 -070077 source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
Zack Williams03ebb272020-03-27 09:42:33 -070078 else
79 echo "on master, using default settings for kind-voltha"
80 fi
81
Andy Bavierb5c8caf2020-04-06 14:12:07 -070082 cd $WORKSPACE/voltha/kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -070083 JUST_K8S=y ./voltha up
Andy Bavierb5c8caf2020-04-06 14:12:07 -070084 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin"
Kailashaad71012019-08-27 10:36:53 -070085 """
86 }
87 }
88
89 stage('Build Images') {
90 steps {
91 sh """
Andy Bavierb99c3d32020-02-18 11:14:17 -070092 make-local () {
93 make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
94 }
Andy Bavier0ed77062020-02-18 10:09:19 -070095 if [ "${gerritProject}" = "pyvoltha" ]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -070096 make -C $WORKSPACE/voltha/pyvoltha/ dist
Andy Bavier0ed77062020-02-18 10:09:19 -070097 export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/
Andy Bavierb99c3d32020-02-18 11:14:17 -070098 make-local voltha-openonu-adapter
99 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
100 make -C $WORKSPACE/voltha/voltha-lib-go/ build
101 export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/
102 make-local voltha-go
103 make-local voltha-openolt-adapter
104 elif [ "${gerritProject}" = "voltha-protos" ]; then
105 make -C $WORKSPACE/voltha/voltha-protos/ build
106 export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/
107 make-local voltha-go
108 make-local voltha-openolt-adapter
109 make-local voltha-openonu-adapter
110 make-local ofagent-py
Andy Bavier178c47b2020-04-01 13:05:43 -0700111 elif [ "${gerritProject}" = "voltctl" ]; then
Andy Bavierdecde3f2020-04-01 15:29:43 -0700112 # Set and handle GOPATH and PATH
113 export GOPATH=\${GOPATH:-$WORKSPACE/go}
114 export PATH=\$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:\$GOPATH/bin
Andy Bavier178c47b2020-04-01 13:05:43 -0700115 make -C $WORKSPACE/voltha/voltctl/ build
Andy Bavier4318f8d2020-04-09 13:50:53 -0700116 elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|kind-voltha)\$ ]]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -0700117 make-local ${gerritProject}
Andy Bavier07615f92019-10-03 12:31:18 -0700118 fi
Kailashaad71012019-08-27 10:36:53 -0700119 """
120 }
121 }
122
123 stage('Push Images') {
124 steps {
125 sh '''
Zack Williams03ebb272020-03-27 09:42:33 -0700126 if [ "${branch}" != "master" ]; then
127 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700128 source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
Zack Williams03ebb272020-03-27 09:42:33 -0700129 else
130 echo "on master, using default settings for kind-voltha"
131 fi
132
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700133 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|voltctl|kind-voltha)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -0700134 export GOROOT=/usr/local/go
135 export GOPATH=\$(pwd)
Andy Bavier07615f92019-10-03 12:31:18 -0700136 docker images | grep citest
Matteo Scandolo2e64c102020-07-29 19:41:02 -0700137 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$NAME --nodes voltha-\$NAME-worker,voltha-\$NAME-worker2; done
Andy Bavier07615f92019-10-03 12:31:18 -0700138 fi
Kailashaad71012019-08-27 10:36:53 -0700139 '''
140 }
141 }
Andy Bavier8b118b72020-04-28 12:59:30 -0700142
143 stage('ATT workflow') {
144 environment {
145 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ATTWorkflow"
146 }
Kailashaad71012019-08-27 10:36:53 -0700147 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700148 sh '''
Zack Williams03ebb272020-03-27 09:42:33 -0700149 if [ "${branch}" != "master" ]; then
150 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700151 source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
Zack Williams03ebb272020-03-27 09:42:33 -0700152 else
153 echo "on master, using default settings for kind-voltha"
154 fi
155
Andy Bavier8b118b72020-04-28 12:59:30 -0700156 # Workflow-specific flags
157 export WITH_RADIUS=yes
158 export WITH_BBSIM=yes
159 export DEPLOY_K8S=yes
Matteo Scandolo3d6a21d2020-09-04 07:34:24 -0700160 export CONFIG_SADIS="external"
161 export BBSIM_CFG="configs/bbsim-sadis-att.yaml"
Andy Bavier8b118b72020-04-28 12:59:30 -0700162
Zack Williams03ebb272020-03-27 09:42:33 -0700163 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700164
Andy Bavier4af02722020-01-15 10:24:24 -0700165 IMAGES=""
Kailashaad71012019-08-27 10:36:53 -0700166 if [ "${gerritProject}" = "voltha-go" ]; then
Andy Bavier4af02722020-01-15 10:24:24 -0700167 IMAGES="rw_core ro_core "
168 elif [ "${gerritProject}" = "ofagent-py" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700169 IMAGES="ofagent_py "
170 EXTRA_HELM_FLAGS+="--set use_ofagent_go=false "
Andy Bavier9c412a82020-03-23 12:00:28 -0700171 elif [ "${gerritProject}" = "ofagent-go" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700172 IMAGES="ofagent_go "
Andy Bavier4af02722020-01-15 10:24:24 -0700173 elif [ "${gerritProject}" = "voltha-onos" ]; then
174 IMAGES="onos "
175 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
176 IMAGES="adapter_open_olt "
177 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
178 IMAGES="adapter_open_onu "
179 elif [ "${gerritProject}" = "voltha-api-server" ]; then
180 IMAGES="afrouter afrouterd "
181 elif [ "${gerritProject}" = "bbsim" ]; then
182 IMAGES="bbsim "
Andy Bavierec0c10d2020-02-14 13:06:27 -0700183 elif [ "${gerritProject}" = "pyvoltha" ]; then
184 IMAGES="adapter_open_onu "
Andy Bavierb99c3d32020-02-18 11:14:17 -0700185 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
186 IMAGES="rw_core ro_core adapter_open_olt "
187 elif [ "${gerritProject}" = "voltha-protos" ]; then
188 IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent "
Zack Williams04997502019-10-04 14:32:20 -0700189 else
Andy Bavier4af02722020-01-15 10:24:24 -0700190 echo "No images to push"
Scott Baker9ac23712019-10-02 09:26:50 -0700191 fi
192
Andy Bavier4af02722020-01-15 10:24:24 -0700193 for I in \$IMAGES
194 do
195 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
196 done
197
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700198 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700199 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
200 export VOLTHA_CHART=\$CHART_PATH/voltha
201 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
202 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700203 helm dep update \$VOLTHA_CHART
204 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
205 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
206 fi
207
Andy Bavier178c47b2020-04-01 13:05:43 -0700208 if [ "${gerritProject}" = "voltctl" ]; then
209 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltha/voltctl/VERSION)
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700210 cp $WORKSPACE/voltha/voltctl/voltctl $WORKSPACE/voltha/kind-voltha/bin/voltctl
211 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
Andy Bavier178c47b2020-04-01 13:05:43 -0700212 fi
213
Andy Bavier8b118b72020-04-28 12:59:30 -0700214 printenv
Andy Bavier4af02722020-01-15 10:24:24 -0700215 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
Kailashaad71012019-08-27 10:36:53 -0700216
Andy Bavier8b118b72020-04-28 12:59:30 -0700217 cd $WORKSPACE/voltha/kind-voltha/
218 ./voltha up
219
Matteo Scandolo39045a92020-07-29 08:58:29 -0700220 # $NAME-env.sh contains the environment we used
Andy Bavier8b118b72020-04-28 12:59:30 -0700221 # Save value of EXTRA_HELM_FLAGS there to use in subsequent stages
Matteo Scandolo39045a92020-07-29 08:58:29 -0700222 echo export EXTRA_HELM_FLAGS=\\"\$EXTRA_HELM_FLAGS\\" >> $NAME-env.sh
Andy Bavier8b118b72020-04-28 12:59:30 -0700223
224 mkdir -p $ROBOT_LOGS_DIR
Andy Bavierd9870042020-06-23 13:16:47 -0700225 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
Andy Bavierdb003082020-02-04 11:57:36 -0700226
227 # By default, all tests tagged 'sanity' are run. This covers basic functionality
228 # like running through the ATT workflow for a single subscriber.
Andy Bavier8b118b72020-04-28 12:59:30 -0700229 export TARGET=sanity-single-kind
Andy Bavierdb003082020-02-04 11:57:36 -0700230
231 # If the Gerrit comment contains a line with "functional tests" then run the full
232 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
233 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
234 REGEX="functional tests"
235 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
Andy Bavier8b118b72020-04-28 12:59:30 -0700236 TARGET=functional-single-kind
Andy Bavierdb003082020-02-04 11:57:36 -0700237 fi
238
Andy Bavier8b118b72020-04-28 12:59:30 -0700239 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
240 '''
241 }
242 }
243
244 stage('DT workflow') {
245 environment {
246 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DTWorkflow"
247 }
248 steps {
249 sh '''
250 cd $WORKSPACE/voltha/kind-voltha/
Matteo Scandolo39045a92020-07-29 08:58:29 -0700251 source $NAME-env.sh
Andy Bavier8b118b72020-04-28 12:59:30 -0700252 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
253
254 # Workflow-specific flags
255 export WITH_RADIUS=no
256 export WITH_EAPOL=no
257 export WITH_DHCP=no
258 export WITH_IGMP=no
Matteo Scandolo3d6a21d2020-09-04 07:34:24 -0700259 export CONFIG_SADIS="external"
260 export BBSIM_CFG="configs/bbsim-sadis-dt.yaml"
Andy Bavier8b118b72020-04-28 12:59:30 -0700261
262 DEPLOY_K8S=n ./voltha up
263
264 mkdir -p $ROBOT_LOGS_DIR
Andy Bavierd9870042020-06-23 13:16:47 -0700265 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
Andy Bavier8b118b72020-04-28 12:59:30 -0700266
267 # By default, all tests tagged 'sanityDt' are run. This covers basic functionality
268 # like running through the DT workflow for a single subscriber.
269 export TARGET=sanity-kind-dt
270
271 # If the Gerrit comment contains a line with "functional tests" then run the full
272 # functional test suite. This covers tests tagged either 'sanityDt' or 'functionalDt'.
273 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
274 REGEX="functional tests"
275 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
276 TARGET=functional-single-kind-dt
277 fi
278
279 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
Kailashaad71012019-08-27 10:36:53 -0700280 '''
281 }
282 }
Matteo Scandolo294133a2020-09-04 11:19:43 -0700283
284 stage('TT workflow') {
285 environment {
286 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/TTWorkflow"
287 }
288 steps {
289 sh '''
290 cd $WORKSPACE/voltha/kind-voltha/
291 source $NAME-env.sh
292 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
293
294 # Workflow-specific flags
295 export WITH_RADIUS=no
296 export WITH_EAPOL=no
297 export WITH_DHCP=yes
298 export WITH_IGMP=yes
299 export CONFIG_SADIS="external"
300 export BBSIM_CFG="configs/bbsim-sadis-tt.yaml"
301
302 DEPLOY_K8S=n ./voltha up
303
304 mkdir -p $ROBOT_LOGS_DIR
305 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
306
307 # By default, all tests tagged 'sanityTt' are run. This covers basic functionality
308 # like running through the TT workflow for a single subscriber.
309 export TARGET=sanity-kind-tt
310
311 # If the Gerrit comment contains a line with "functional tests" then run the full
312 # functional test suite. This covers tests tagged either 'sanityTt' or 'functionalTt'.
313 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
314 REGEX="functional tests"
315 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
316 TARGET=functional-single-kind-tt
317 fi
318
319 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
320 '''
321 }
322 }
Kailashaad71012019-08-27 10:36:53 -0700323 }
324
325 post {
326 always {
327 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700328 set +e
Matteo Scandolo39045a92020-07-29 08:58:29 -0700329 cp $WORKSPACE/voltha/kind-voltha/install-$NAME.log $WORKSPACE/
Matteo Scandolo97b12572020-04-13 12:44:46 -0700330 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
331 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Kailashaad71012019-08-27 10:36:53 -0700332 kubectl get nodes -o wide
333 kubectl get pods -o wide
334 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700335
336 sync
337 pkill kail || true
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700338 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
Andy Bavier4af02722020-01-15 10:24:24 -0700339
340 ## Pull out errors from log files
341 extract_errors_go() {
342 echo
343 echo "Error summary for $1:"
344 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
345 echo
346 }
347
348 extract_errors_python() {
349 echo
350 echo "Error summary for $1:"
351 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
352 echo
353 }
354
355 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
356 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
357 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
358 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
359
Andy Bavier2178d102020-02-06 16:22:11 -0700360 gzip $WORKSPACE/onos-voltha-combined.log
Kailashaad71012019-08-27 10:36:53 -0700361 '''
362 step([$class: 'RobotPublisher',
363 disableArchiveOutput: false,
Andy Bavier8b118b72020-04-28 12:59:30 -0700364 logFileName: 'RobotLogs/*/log*.html',
Kailashaad71012019-08-27 10:36:53 -0700365 otherFiles: '',
Andy Bavier8b118b72020-04-28 12:59:30 -0700366 outputFileName: 'RobotLogs/*/output*.xml',
Kailashaad71012019-08-27 10:36:53 -0700367 outputPath: '.',
Andy Bavier8b118b72020-04-28 12:59:30 -0700368 passThreshold: 100,
369 reportFileName: 'RobotLogs/*/report*.html',
Kailashaad71012019-08-27 10:36:53 -0700370 unstableThreshold: 0]);
Andy Bavier2178d102020-02-06 16:22:11 -0700371 archiveArtifacts artifacts: '*.log,*.gz'
Kailashaad71012019-08-27 10:36:53 -0700372 }
373 }
374}