blob: 9adf4fe74de335c0fa5a016d83d60dff721a6f61 [file] [log] [blame]
Matteo Scandolofff6e062020-04-29 13:36:33 -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 {
23 label "${params.buildNode}"
24 }
25 options {
26 timeout(time: 90, unit: 'MINUTES')
27 }
28 environment {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
Andrea Campanella919361e2020-09-21 14:27:19 +020031 PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Matteo Scandolo4d1a12f2020-12-07 16:17:12 -080032 NAME="minimal"
Matteo Scandolofff6e062020-04-29 13:36:33 -070033 FANCY=0
34 WITH_SIM_ADAPTERS="n"
35 WITH_RADIUS="y"
36 WITH_BBSIM="y"
37 DEPLOY_K8S="y"
38 VOLTHA_LOG_LEVEL="DEBUG"
Andrea Campanellaa0cd5be2020-09-07 15:47:18 +020039 CONFIG_SADIS="external"
40 BBSIM_CFG="configs/bbsim-sadis-att.yaml"
Matteo Scandolofff6e062020-04-29 13:36:33 -070041 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
Andrea Campanellae8e2e012021-01-22 10:59:07 +010042 EXTRA_HELM_FLAGS=" --set global.image_registry=mirror.registry.opennetworking.org/ "
Matteo Scandolofff6e062020-04-29 13:36:33 -070043 }
Matteo Scandolofff6e062020-04-29 13:36:33 -070044 stages {
Andrea Campanella919361e2020-09-21 14:27:19 +020045 stage('Clone kind-voltha') {
Matteo Scandolofff6e062020-04-29 13:36:33 -070046 steps {
Andrea Campanella919361e2020-09-21 14:27:19 +020047 checkout([
48 $class: 'GitSCM',
49 userRemoteConfigs: [[
50 url: "https://gerrit.opencord.org/kind-voltha",
51 refspec: "${kindVolthaChange}"
52 ]],
53 branches: [[ name: "master", ]],
54 extensions: [
55 [$class: 'WipeWorkspace'],
56 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
57 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
58 ],
59 ])
60 sh """
61 if [ '${kindVolthaChange}' != '' ] ; then
62 cd $WORKSPACE/kind-voltha
63 git fetch https://gerrit.opencord.org/kind-voltha ${kindVolthaChange} && git checkout FETCH_HEAD
64 fi
65 """
Matteo Scandolofff6e062020-04-29 13:36:33 -070066 }
67 }
Andrea Campanella919361e2020-09-21 14:27:19 +020068 stage('Clone voltha-system-tests') {
69 steps {
70 checkout([
71 $class: 'GitSCM',
72 userRemoteConfigs: [[
73 url: "https://gerrit.opencord.org/voltha-system-tests",
74 refspec: "${volthaSystemTestsChange}"
75 ]],
76 branches: [[ name: "${branch}", ]],
77 extensions: [
78 [$class: 'WipeWorkspace'],
79 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
80 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
81 ],
82 ])
83 sh """
84 if [ '${volthaSystemTestsChange}' != '' ] ; then
85 cd $WORKSPACE/voltha-system-tests
86 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
87 fi
88 """
89 }
90 }
91 // If the repo under test is not kind-voltha
92 // then download it and checkout the patch
93 stage('Download Patch') {
94 when {
95 expression {
96 return "${gerritProject}" != 'kind-voltha';
97 }
98 }
99 steps {
100 checkout([
101 $class: 'GitSCM',
102 userRemoteConfigs: [[
103 url: "https://gerrit.opencord.org/${gerritProject}",
104 refspec: "${gerritRefspec}"
105 ]],
106 branches: [[ name: "${branch}", ]],
107 extensions: [
108 [$class: 'WipeWorkspace'],
109 [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gerritProject}"],
110 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
111 ],
112 ])
113 sh """
114 pushd $WORKSPACE/${gerritProject}
115 git fetch https://gerrit.opencord.org/${gerritProject} ${gerritRefspec} && git checkout FETCH_HEAD
116 echo "Currently on commit: \n"
117 git log -1 --oneline
118 popd
119 """
120 }
121 }
122 // If the repo under test is kind-voltha we don't need to download it again,
123 // as we already have it, simply checkout the patch
124 stage('Checkout kind-voltha patch') {
125 when {
126 expression {
127 return "${gerritProject}" == 'kind-voltha';
128 }
129 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700130 steps {
131 sh """
Andrea Campanella919361e2020-09-21 14:27:19 +0200132 cd $WORKSPACE/kind-voltha
133 git fetch https://gerrit.opencord.org/kind-voltha ${gerritRefspec} && git checkout FETCH_HEAD
134 """
Matteo Scandolofff6e062020-04-29 13:36:33 -0700135 }
136 }
137 stage('Create K8s Cluster') {
138 steps {
139 sh """
Andrea Campanella919361e2020-09-21 14:27:19 +0200140 cd $WORKSPACE/kind-voltha/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700141 JUST_K8S=y ./voltha up
Andrea Campanella919361e2020-09-21 14:27:19 +0200142 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
Matteo Scandolofff6e062020-04-29 13:36:33 -0700143 """
144 }
145 }
146
147 stage('Build Images') {
148 steps {
149 sh """
Matteo Scandolo4adf1192020-12-15 09:44:14 -1000150 make -C $WORKSPACE/voltha-openonu-adapter-go DOCKER_REGISTRY=mirror.registry.opennetworking.org/ DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
Matteo Scandolofff6e062020-04-29 13:36:33 -0700151 """
152 }
153 }
154
155 stage('Push Images') {
156 steps {
157 sh '''
158 docker images | grep citest
Matteo Scandolo4adf1192020-12-15 09:44:14 -1000159 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
Matteo Scandolofff6e062020-04-29 13:36:33 -0700160 '''
161 }
162 }
163 stage('Deploy Voltha') {
164 steps {
165 sh '''
TorstenThieme326e7972021-01-19 14:27:59 +0000166 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Matteo Scandolofff6e062020-04-29 13:36:33 -0700167
168 IMAGES="adapter_open_onu_go"
169
170 for I in \$IMAGES
171 do
172 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
173 done
174
Andrea Campanella919361e2020-09-21 14:27:19 +0200175 cd $WORKSPACE/kind-voltha/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700176 echo \$EXTRA_HELM_FLAGS
Matteo Scandoloaca27622020-12-11 09:04:07 -0800177
Matteo Scandolofff6e062020-04-29 13:36:33 -0700178 ./voltha up
179 '''
180 }
181 }
182
Andrea Campanellaa2f32c32020-12-17 18:30:47 +0100183 stage('Run E2E Tests 1t8gem') {
184 environment {
185 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/1t8gem"
186 }
187 steps {
188 sh '''
189 cd $WORKSPACE/kind-voltha/
190 #source $NAME-env.sh
191 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
192
TorstenThieme326e7972021-01-19 14:27:59 +0000193 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Andrea Campanellaa2f32c32020-12-17 18:30:47 +0100194
195 IMAGES="adapter_open_onu_go"
196
197 for I in \$IMAGES
198 do
199 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
200 done
201 #1t8gem
202 mkdir -p $WORKSPACE/1t8gem
Matteo Scandolof566cc42020-12-11 14:05:29 -0800203 _TAG=kail-1t8gem kail -n voltha -n default > $WORKSPACE/1t8gem/onos-voltha-combined.log &
204
Andrea Campanellaa2f32c32020-12-17 18:30:47 +0100205 DEPLOY_K8S=n ./voltha up
206
Matteo Scandolof566cc42020-12-11 14:05:29 -0800207 mkdir -p $ROBOT_LOGS_DIR/1t8gem
Andrea Campanellaa2f32c32020-12-17 18:30:47 +0100208 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Matteo Scandolof566cc42020-12-11 14:05:29 -0800209 export TARGET_1T8GEM=1t8gem-openonu-go-adapter-test
Matteo Scandoloaf7ef5f2021-01-22 16:09:03 -0800210 export NAME=voltha_voltha
Matteo Scandolof566cc42020-12-11 14:05:29 -0800211
212 make -C $WORKSPACE/voltha-system-tests \$TARGET_1T8GEM || true
213
214 # stop logging
215 P_IDS="$(ps e -ww -A | grep "_TAG=kail-1t8gem" | grep -v grep | awk '{print $1}')"
216 if [ -n "$P_IDS" ]; then
217 echo $P_IDS
218 for P_ID in $P_IDS; do
219 kill -9 $P_ID
220 done
221 fi
222
223 # get pods information
224 kubectl get pods -o wide --all-namespaces > $WORKSPACE/1t8gem/pods.txt || true
Matteo Scandolofff6e062020-04-29 13:36:33 -0700225 '''
226 }
227 }
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200228
TorstenThieme987a7302020-09-23 08:54:58 +0000229 stage('DT workflow') {
230 environment {
231 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DTWorkflow"
232 }
233 steps {
234 sh '''
235 cd $WORKSPACE/kind-voltha/
236 #source $NAME-env.sh
237 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
238
TorstenThieme326e7972021-01-19 14:27:59 +0000239 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
TorstenThieme987a7302020-09-23 08:54:58 +0000240
241 IMAGES="adapter_open_onu_go"
242
243 for I in \$IMAGES
244 do
245 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
246 done
247
248 # Workflow-specific flags
249 export WITH_RADIUS=no
250 export WITH_EAPOL=no
251 export WITH_DHCP=no
252 export WITH_IGMP=no
253 export CONFIG_SADIS="external"
254 export BBSIM_CFG="configs/bbsim-sadis-dt.yaml"
255
Matteo Scandoloaca27622020-12-11 09:04:07 -0800256 # start logging
257 mkdir -p $WORKSPACE/dt
258 _TAG=kail-dt kail -n voltha -n default > $WORKSPACE/dt/onos-voltha-combined.log &
259
TorstenThieme987a7302020-09-23 08:54:58 +0000260 DEPLOY_K8S=n ./voltha up
261
262 mkdir -p $ROBOT_LOGS_DIR
263 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
264
265 # By default, all tests tagged 'sanityDt' are run. This covers basic functionality
266 # like running through the DT workflow for a single subscriber.
267 export TARGET=sanity-kind-dt
268
269 # If the Gerrit comment contains a line with "functional tests" then run the full
270 # functional test suite. This covers tests tagged either 'sanityDt' or 'functionalDt'.
271 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
272 REGEX="functional tests"
273 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
274 TARGET=functional-single-kind-dt
275 fi
276
277 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Matteo Scandoloaca27622020-12-11 09:04:07 -0800278
279 # stop logging
280 P_IDS="$(ps e -ww -A | grep "_TAG=kail-dt" | grep -v grep | awk '{print $1}')"
281 if [ -n "$P_IDS" ]; then
282 echo $P_IDS
283 for P_ID in $P_IDS; do
284 kill -9 $P_ID
285 done
286 fi
287
288 # get pods information
Matteo Scandolof566cc42020-12-11 14:05:29 -0800289 kubectl get pods -o wide --all-namespaces > $WORKSPACE/dt/pods.txt || true
TorstenThieme987a7302020-09-23 08:54:58 +0000290 '''
291 }
292 }
293
TorstenThieme30b7a322020-09-28 11:13:18 +0000294 stage('ATT workflow') {
295 environment {
296 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ATTWorkflow"
297 }
298 steps {
299 sh '''
300 cd $WORKSPACE/kind-voltha/
301 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
Matteo Scandolofff6e062020-04-29 13:36:33 -0700302
TorstenThieme326e7972021-01-19 14:27:59 +0000303 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
TorstenThieme30b7a322020-09-28 11:13:18 +0000304
305 IMAGES="adapter_open_onu_go"
306
307 for I in \$IMAGES
308 do
309 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
310 done
311
312 # Workflow-specific flags
313 export WITH_RADIUS=yes
314 export WITH_EAPOL=yes
315 export WITH_BBSIM=yes
316 export DEPLOY_K8S=yes
317 export CONFIG_SADIS="external"
318 export BBSIM_CFG="configs/bbsim-sadis-att.yaml"
319
320 if [ "${gerritProject}" = "voltctl" ]; then
321 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltctl/VERSION)
322 cp $WORKSPACE/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
323 md5sum $WORKSPACE/kind-voltha/bin/voltctl
324 fi
325
Matteo Scandoloaca27622020-12-11 09:04:07 -0800326 # start logging
327 mkdir -p $WORKSPACE/att
328 _TAG=kail-att kail -n voltha -n default > $WORKSPACE/att/onos-voltha-combined.log &
329
TorstenThieme30b7a322020-09-28 11:13:18 +0000330 DEPLOY_K8S=n ./voltha up
331
332 mkdir -p $ROBOT_LOGS_DIR
333 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
334
335 # By default, all tests tagged 'sanity' are run. This covers basic functionality
336 # like running through the ATT workflow for a single subscriber.
337 export TARGET=sanity-single-kind
338
339 # If the Gerrit comment contains a line with "functional tests" then run the full
340 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
341 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
342 REGEX="functional tests"
343 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
344 TARGET=functional-single-kind
345 fi
346
347 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Matteo Scandoloaca27622020-12-11 09:04:07 -0800348
349 # stop logging
350 P_IDS="$(ps e -ww -A | grep "_TAG=kail-att" | grep -v grep | awk '{print $1}')"
351 if [ -n "$P_IDS" ]; then
352 echo $P_IDS
353 for P_ID in $P_IDS; do
354 kill -9 $P_ID
355 done
356 fi
357
358 # get pods information
Matteo Scandolof566cc42020-12-11 14:05:29 -0800359 kubectl get pods -o wide --all-namespaces > $WORKSPACE/att/pods.txt || true
TorstenThieme30b7a322020-09-28 11:13:18 +0000360 '''
361 }
362 }
Andrea Campanella50e3a0b2020-10-01 06:28:08 +0000363
364 stage('TT workflow') {
365 environment {
366 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/TTWorkflow"
367 }
368 steps {
369 sh '''
370 cd $WORKSPACE/kind-voltha/
371 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
372
TorstenThieme326e7972021-01-19 14:27:59 +0000373 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Andrea Campanella50e3a0b2020-10-01 06:28:08 +0000374
375 IMAGES="adapter_open_onu_go"
376
377 for I in \$IMAGES
378 do
379 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
380 done
381
382 # Workflow-specific flags
383 export WITH_RADIUS=no
384 export WITH_EAPOL=no
385 export WITH_DHCP=yes
386 export WITH_IGMP=yes
387 export CONFIG_SADIS="external"
388 export BBSIM_CFG="configs/bbsim-sadis-tt.yaml"
389
Matteo Scandoloaca27622020-12-11 09:04:07 -0800390 # start logging
391 mkdir -p $WORKSPACE/tt
392 _TAG=kail-tt kail -n voltha -n default > $WORKSPACE/tt/onos-voltha-combined.log &
393
Andrea Campanella50e3a0b2020-10-01 06:28:08 +0000394 DEPLOY_K8S=n ./voltha up
395
396 mkdir -p $ROBOT_LOGS_DIR
397 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
398
399 # By default, all tests tagged 'sanityTt' are run. This covers basic functionality
400 # like running through the TT workflow for a single subscriber.
401 export TARGET=sanity-kind-tt
402
403 # If the Gerrit comment contains a line with "functional tests" then run the full
404 # functional test suite. This covers tests tagged either 'sanityTt' or 'functionalTt'.
405 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
406 REGEX="functional tests"
407 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
408 TARGET=functional-single-kind-tt
409 fi
410
411 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Matteo Scandoloaca27622020-12-11 09:04:07 -0800412
413 # stop logging
414 P_IDS="$(ps e -ww -A | grep "_TAG=kail-tt" | grep -v grep | awk '{print $1}')"
415 if [ -n "$P_IDS" ]; then
416 echo $P_IDS
417 for P_ID in $P_IDS; do
418 kill -9 $P_ID
419 done
420 fi
421
422 # get pods information
Matteo Scandolof566cc42020-12-11 14:05:29 -0800423 kubectl get pods -o wide --all-namespaces > $WORKSPACE/tt/pods.txt || true
Andrea Campanella50e3a0b2020-10-01 06:28:08 +0000424 '''
425 }
426 }
TorstenThieme30b7a322020-09-28 11:13:18 +0000427 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700428 post {
429 always {
430 sh '''
431 set +e
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000432 # get pods information
433 kubectl get pods -o wide
434 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}"
435 helm ls
Matteo Scandolofff6e062020-04-29 13:36:33 -0700436
437 sync
438 pkill kail || true
Andrea Campanella919361e2020-09-21 14:27:19 +0200439 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Matteo Scandolofff6e062020-04-29 13:36:33 -0700440
441 ## Pull out errors from log files
442 extract_errors_go() {
443 echo
444 echo "Error summary for $1:"
445 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
446 echo
447 }
448
449 extract_errors_python() {
450 echo
451 echo "Error summary for $1:"
452 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
453 echo
454 }
455
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000456 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log || true
457 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log || true
458 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log || true
459 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log || true
Matteo Scandolofff6e062020-04-29 13:36:33 -0700460
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000461 gzip $WORKSPACE/onos-voltha-combined.log || true
Matteo Scandolofff6e062020-04-29 13:36:33 -0700462 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200463 step([$class: 'RobotPublisher',
464 disableArchiveOutput: false,
465 logFileName: 'RobotLogs/*/log*.html',
466 otherFiles: '',
467 outputFileName: 'RobotLogs/*/output*.xml',
468 outputPath: '.',
469 passThreshold: 100,
470 reportFileName: 'RobotLogs/*/report*.html',
471 unstableThreshold: 0]);
Matteo Scandoloaca27622020-12-11 09:04:07 -0800472 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt'
Matteo Scandolofff6e062020-04-29 13:36:33 -0700473 }
474 }
475}