blob: 2c5bfbbe9bee07c1c3c6f44a998755eac5a67d27 [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 Scandolofff6e062020-04-29 13:36:33 -070032 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"
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"
42 }
Matteo Scandolofff6e062020-04-29 13:36:33 -070043 stages {
Andrea Campanella919361e2020-09-21 14:27:19 +020044 stage('Clone kind-voltha') {
Matteo Scandolofff6e062020-04-29 13:36:33 -070045 steps {
Andrea Campanella919361e2020-09-21 14:27:19 +020046 checkout([
47 $class: 'GitSCM',
48 userRemoteConfigs: [[
49 url: "https://gerrit.opencord.org/kind-voltha",
50 refspec: "${kindVolthaChange}"
51 ]],
52 branches: [[ name: "master", ]],
53 extensions: [
54 [$class: 'WipeWorkspace'],
55 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
56 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
57 ],
58 ])
59 sh """
60 if [ '${kindVolthaChange}' != '' ] ; then
61 cd $WORKSPACE/kind-voltha
62 git fetch https://gerrit.opencord.org/kind-voltha ${kindVolthaChange} && git checkout FETCH_HEAD
63 fi
64 """
Matteo Scandolofff6e062020-04-29 13:36:33 -070065 }
66 }
Andrea Campanella919361e2020-09-21 14:27:19 +020067 stage('Clone voltha-system-tests') {
68 steps {
69 checkout([
70 $class: 'GitSCM',
71 userRemoteConfigs: [[
72 url: "https://gerrit.opencord.org/voltha-system-tests",
73 refspec: "${volthaSystemTestsChange}"
74 ]],
75 branches: [[ name: "${branch}", ]],
76 extensions: [
77 [$class: 'WipeWorkspace'],
78 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
79 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
80 ],
81 ])
82 sh """
83 if [ '${volthaSystemTestsChange}' != '' ] ; then
84 cd $WORKSPACE/voltha-system-tests
85 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
86 fi
87 """
88 }
89 }
90 // If the repo under test is not kind-voltha
91 // then download it and checkout the patch
92 stage('Download Patch') {
93 when {
94 expression {
95 return "${gerritProject}" != 'kind-voltha';
96 }
97 }
98 steps {
99 checkout([
100 $class: 'GitSCM',
101 userRemoteConfigs: [[
102 url: "https://gerrit.opencord.org/${gerritProject}",
103 refspec: "${gerritRefspec}"
104 ]],
105 branches: [[ name: "${branch}", ]],
106 extensions: [
107 [$class: 'WipeWorkspace'],
108 [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gerritProject}"],
109 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
110 ],
111 ])
112 sh """
113 pushd $WORKSPACE/${gerritProject}
114 git fetch https://gerrit.opencord.org/${gerritProject} ${gerritRefspec} && git checkout FETCH_HEAD
115 echo "Currently on commit: \n"
116 git log -1 --oneline
117 popd
118 """
119 }
120 }
121 // If the repo under test is kind-voltha we don't need to download it again,
122 // as we already have it, simply checkout the patch
123 stage('Checkout kind-voltha patch') {
124 when {
125 expression {
126 return "${gerritProject}" == 'kind-voltha';
127 }
128 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700129 steps {
130 sh """
Andrea Campanella919361e2020-09-21 14:27:19 +0200131 cd $WORKSPACE/kind-voltha
132 git fetch https://gerrit.opencord.org/kind-voltha ${gerritRefspec} && git checkout FETCH_HEAD
133 """
Matteo Scandolofff6e062020-04-29 13:36:33 -0700134 }
135 }
136 stage('Create K8s Cluster') {
137 steps {
138 sh """
Andrea Campanella919361e2020-09-21 14:27:19 +0200139 cd $WORKSPACE/kind-voltha/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700140 JUST_K8S=y ./voltha up
Andrea Campanella919361e2020-09-21 14:27:19 +0200141 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
Matteo Scandolofff6e062020-04-29 13:36:33 -0700142 """
143 }
144 }
145
146 stage('Build Images') {
147 steps {
148 sh """
Andrea Campanella919361e2020-09-21 14:27:19 +0200149 make -C $WORKSPACE/voltha-openonu-adapter-go DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
Matteo Scandolofff6e062020-04-29 13:36:33 -0700150 """
151 }
152 }
153
154 stage('Push Images') {
155 steps {
156 sh '''
157 docker images | grep citest
158 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
159 '''
160 }
161 }
162 stage('Deploy Voltha') {
163 steps {
164 sh '''
Matteo Scandolof21ae312020-04-29 21:04:15 -0700165 export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} "
Matteo Scandolofff6e062020-04-29 13:36:33 -0700166
167 IMAGES="adapter_open_onu_go"
168
169 for I in \$IMAGES
170 do
171 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
172 done
173
Andrea Campanella919361e2020-09-21 14:27:19 +0200174 cd $WORKSPACE/kind-voltha/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700175 echo \$EXTRA_HELM_FLAGS
176 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
177 ./voltha up
178 '''
179 }
180 }
181
182 stage('Run E2E Tests') {
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200183 environment {
184 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/openonu-go"
185 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700186 steps {
187 sh '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200188 mkdir -p $ROBOT_LOGS_DIR
189 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Andrea Campanella27ddf062020-08-07 10:35:15 +0200190 export TARGET_DEFAULT=openonu-go-adapter-test
Matteo Scandolofff6e062020-04-29 13:36:33 -0700191
Andrea Campanella919361e2020-09-21 14:27:19 +0200192 make -C $WORKSPACE/voltha-system-tests \$TARGET_DEFAULT || true
Andrea Campanella27ddf062020-08-07 10:35:15 +0200193
194 export TARGET_1T8GEM=1t8gem-openonu-go-adapter-test
195
Andrea Campanella919361e2020-09-21 14:27:19 +0200196 make -C $WORKSPACE/voltha-system-tests \$TARGET_1T8GEM || true
Matteo Scandolofff6e062020-04-29 13:36:33 -0700197 '''
198 }
199 }
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200200
TorstenThieme0a0fc522020-10-08 10:31:29 +0000201 stage('Run MIB Upload Tests') {
202 environment {
203 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/openonu-go-MIB"
204 }
205 steps {
206 sh '''
207 cd $WORKSPACE/kind-voltha/
208 #source $NAME-env.sh
209 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
210
211 export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} "
212
Andrea Campanella12146d52020-10-13 23:35:17 +0200213 export EXTRA_HELM_FLAGS+="--set pon=2,onu=2,controlledActivation=only-onu "
TorstenThieme0a0fc522020-10-08 10:31:29 +0000214
215 IMAGES="adapter_open_onu_go"
216
217 for I in \$IMAGES
218 do
219 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
220 done
221
222 DEPLOY_K8S=n ./voltha up
223
224 mkdir -p $ROBOT_LOGS_DIR
225 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
226 export TARGET_DEFAULT=mib-upload-templating-openonu-go-adapter-test
227
228 make -C $WORKSPACE/voltha-system-tests \$TARGET_DEFAULT || true
229 '''
230 }
231 }
232
TorstenThieme987a7302020-09-23 08:54:58 +0000233 stage('DT workflow') {
234 environment {
235 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DTWorkflow"
236 }
237 steps {
238 sh '''
239 cd $WORKSPACE/kind-voltha/
240 #source $NAME-env.sh
241 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
242
243 export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} "
244
245 IMAGES="adapter_open_onu_go"
246
247 for I in \$IMAGES
248 do
249 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
250 done
251
252 # Workflow-specific flags
253 export WITH_RADIUS=no
254 export WITH_EAPOL=no
255 export WITH_DHCP=no
256 export WITH_IGMP=no
257 export CONFIG_SADIS="external"
258 export BBSIM_CFG="configs/bbsim-sadis-dt.yaml"
259
260 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
278 '''
279 }
280 }
281
TorstenThieme30b7a322020-09-28 11:13:18 +0000282 stage('ATT workflow') {
283 environment {
284 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ATTWorkflow"
285 }
286 steps {
287 sh '''
288 cd $WORKSPACE/kind-voltha/
289 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
Matteo Scandolofff6e062020-04-29 13:36:33 -0700290
TorstenThieme30b7a322020-09-28 11:13:18 +0000291 export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} "
292
293 IMAGES="adapter_open_onu_go"
294
295 for I in \$IMAGES
296 do
297 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
298 done
299
300 # Workflow-specific flags
301 export WITH_RADIUS=yes
302 export WITH_EAPOL=yes
303 export WITH_BBSIM=yes
304 export DEPLOY_K8S=yes
305 export CONFIG_SADIS="external"
306 export BBSIM_CFG="configs/bbsim-sadis-att.yaml"
307
308 if [ "${gerritProject}" = "voltctl" ]; then
309 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltctl/VERSION)
310 cp $WORKSPACE/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
311 md5sum $WORKSPACE/kind-voltha/bin/voltctl
312 fi
313
314 DEPLOY_K8S=n ./voltha up
315
316 mkdir -p $ROBOT_LOGS_DIR
317 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
318
319 # By default, all tests tagged 'sanity' are run. This covers basic functionality
320 # like running through the ATT workflow for a single subscriber.
321 export TARGET=sanity-single-kind
322
323 # If the Gerrit comment contains a line with "functional tests" then run the full
324 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
325 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
326 REGEX="functional tests"
327 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
328 TARGET=functional-single-kind
329 fi
330
331 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
332 '''
333 }
334 }
TorstenThieme30b7a322020-09-28 11:13:18 +0000335 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700336 post {
337 always {
338 sh '''
339 set +e
Andrea Campanella919361e2020-09-21 14:27:19 +0200340 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700341 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
342 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
343 kubectl get nodes -o wide
344 kubectl get pods -o wide
345 kubectl get pods -n voltha -o wide
346
347 sync
348 pkill kail || true
Andrea Campanella919361e2020-09-21 14:27:19 +0200349 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Matteo Scandolofff6e062020-04-29 13:36:33 -0700350
351 ## Pull out errors from log files
352 extract_errors_go() {
353 echo
354 echo "Error summary for $1:"
355 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
356 echo
357 }
358
359 extract_errors_python() {
360 echo
361 echo "Error summary for $1:"
362 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
363 echo
364 }
365
366 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
367 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
368 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
369 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
370
371 gzip $WORKSPACE/onos-voltha-combined.log
372
373
374 ## shut down kind-voltha
375 if [ "${branch}" != "master" ]; then
376 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andrea Campanella919361e2020-09-21 14:27:19 +0200377 source "$WORKSPACE/kind-voltha/releases/${branch}"
Matteo Scandolofff6e062020-04-29 13:36:33 -0700378 else
379 echo "on master, using default settings for kind-voltha"
380 fi
381
Andrea Campanella919361e2020-09-21 14:27:19 +0200382 cd $WORKSPACE/kind-voltha
Matteo Scandolofff6e062020-04-29 13:36:33 -0700383 WAIT_ON_DOWN=y ./voltha down
384 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200385 step([$class: 'RobotPublisher',
386 disableArchiveOutput: false,
387 logFileName: 'RobotLogs/*/log*.html',
388 otherFiles: '',
389 outputFileName: 'RobotLogs/*/output*.xml',
390 outputPath: '.',
391 passThreshold: 100,
392 reportFileName: 'RobotLogs/*/report*.html',
393 unstableThreshold: 0]);
Matteo Scandolofff6e062020-04-29 13:36:33 -0700394 archiveArtifacts artifacts: '*.log,*.gz'
395 }
396 }
397}