blob: 57f8c3ba53b729fa2fc61ffe9c65bfc20a7b9d73 [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
TorstenThieme987a7302020-09-23 08:54:58 +0000201 stage('DT workflow') {
202 environment {
203 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DTWorkflow"
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
213 IMAGES="adapter_open_onu_go"
214
215 for I in \$IMAGES
216 do
217 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
218 done
219
220 # Workflow-specific flags
221 export WITH_RADIUS=no
222 export WITH_EAPOL=no
223 export WITH_DHCP=no
224 export WITH_IGMP=no
225 export CONFIG_SADIS="external"
226 export BBSIM_CFG="configs/bbsim-sadis-dt.yaml"
227
228 DEPLOY_K8S=n ./voltha up
229
230 mkdir -p $ROBOT_LOGS_DIR
231 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
232
233 # By default, all tests tagged 'sanityDt' are run. This covers basic functionality
234 # like running through the DT workflow for a single subscriber.
235 export TARGET=sanity-kind-dt
236
237 # If the Gerrit comment contains a line with "functional tests" then run the full
238 # functional test suite. This covers tests tagged either 'sanityDt' or 'functionalDt'.
239 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
240 REGEX="functional tests"
241 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
242 TARGET=functional-single-kind-dt
243 fi
244
245 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
246 '''
247 }
248 }
249
TorstenThieme30b7a322020-09-28 11:13:18 +0000250 stage('ATT workflow') {
251 environment {
252 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ATTWorkflow"
253 }
254 steps {
255 sh '''
256 cd $WORKSPACE/kind-voltha/
257 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
Matteo Scandolofff6e062020-04-29 13:36:33 -0700258
TorstenThieme30b7a322020-09-28 11:13:18 +0000259 export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} "
260
261 IMAGES="adapter_open_onu_go"
262
263 for I in \$IMAGES
264 do
265 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
266 done
267
268 # Workflow-specific flags
269 export WITH_RADIUS=yes
270 export WITH_EAPOL=yes
271 export WITH_BBSIM=yes
272 export DEPLOY_K8S=yes
273 export CONFIG_SADIS="external"
274 export BBSIM_CFG="configs/bbsim-sadis-att.yaml"
275
276 if [ "${gerritProject}" = "voltctl" ]; then
277 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltctl/VERSION)
278 cp $WORKSPACE/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
279 md5sum $WORKSPACE/kind-voltha/bin/voltctl
280 fi
281
282 DEPLOY_K8S=n ./voltha up
283
284 mkdir -p $ROBOT_LOGS_DIR
285 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
286
287 # By default, all tests tagged 'sanity' are run. This covers basic functionality
288 # like running through the ATT workflow for a single subscriber.
289 export TARGET=sanity-single-kind
290
291 # If the Gerrit comment contains a line with "functional tests" then run the full
292 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
293 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
294 REGEX="functional tests"
295 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
296 TARGET=functional-single-kind
297 fi
298
299 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
300 '''
301 }
302 }
303
304 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700305 post {
306 always {
307 sh '''
308 set +e
Andrea Campanella919361e2020-09-21 14:27:19 +0200309 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700310 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
311 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
312 kubectl get nodes -o wide
313 kubectl get pods -o wide
314 kubectl get pods -n voltha -o wide
315
316 sync
317 pkill kail || true
Andrea Campanella919361e2020-09-21 14:27:19 +0200318 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Matteo Scandolofff6e062020-04-29 13:36:33 -0700319
320 ## Pull out errors from log files
321 extract_errors_go() {
322 echo
323 echo "Error summary for $1:"
324 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
325 echo
326 }
327
328 extract_errors_python() {
329 echo
330 echo "Error summary for $1:"
331 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
332 echo
333 }
334
335 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
336 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
337 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
338 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
339
340 gzip $WORKSPACE/onos-voltha-combined.log
341
342
343 ## shut down kind-voltha
344 if [ "${branch}" != "master" ]; then
345 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andrea Campanella919361e2020-09-21 14:27:19 +0200346 source "$WORKSPACE/kind-voltha/releases/${branch}"
Matteo Scandolofff6e062020-04-29 13:36:33 -0700347 else
348 echo "on master, using default settings for kind-voltha"
349 fi
350
Andrea Campanella919361e2020-09-21 14:27:19 +0200351 cd $WORKSPACE/kind-voltha
Matteo Scandolofff6e062020-04-29 13:36:33 -0700352 WAIT_ON_DOWN=y ./voltha down
353 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200354 step([$class: 'RobotPublisher',
355 disableArchiveOutput: false,
356 logFileName: 'RobotLogs/*/log*.html',
357 otherFiles: '',
358 outputFileName: 'RobotLogs/*/output*.xml',
359 outputPath: '.',
360 passThreshold: 100,
361 reportFileName: 'RobotLogs/*/report*.html',
362 unstableThreshold: 0]);
Matteo Scandolofff6e062020-04-29 13:36:33 -0700363 archiveArtifacts artifacts: '*.log,*.gz'
364 }
365 }
366}