blob: 223fa7917001d34b60f9d149148dda100ef5e2db [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
Matteo Scandolofff6e062020-04-29 13:36:33 -0700250 }
251
252 post {
253 always {
254 sh '''
255 set +e
Andrea Campanella919361e2020-09-21 14:27:19 +0200256 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700257 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
258 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
259 kubectl get nodes -o wide
260 kubectl get pods -o wide
261 kubectl get pods -n voltha -o wide
262
263 sync
264 pkill kail || true
Andrea Campanella919361e2020-09-21 14:27:19 +0200265 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Matteo Scandolofff6e062020-04-29 13:36:33 -0700266
267 ## Pull out errors from log files
268 extract_errors_go() {
269 echo
270 echo "Error summary for $1:"
271 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
272 echo
273 }
274
275 extract_errors_python() {
276 echo
277 echo "Error summary for $1:"
278 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
279 echo
280 }
281
282 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
283 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
284 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
285 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
286
287 gzip $WORKSPACE/onos-voltha-combined.log
288
289
290 ## shut down kind-voltha
291 if [ "${branch}" != "master" ]; then
292 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andrea Campanella919361e2020-09-21 14:27:19 +0200293 source "$WORKSPACE/kind-voltha/releases/${branch}"
Matteo Scandolofff6e062020-04-29 13:36:33 -0700294 else
295 echo "on master, using default settings for kind-voltha"
296 fi
297
Andrea Campanella919361e2020-09-21 14:27:19 +0200298 cd $WORKSPACE/kind-voltha
Matteo Scandolofff6e062020-04-29 13:36:33 -0700299 WAIT_ON_DOWN=y ./voltha down
300 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200301 step([$class: 'RobotPublisher',
302 disableArchiveOutput: false,
303 logFileName: 'RobotLogs/*/log*.html',
304 otherFiles: '',
305 outputFileName: 'RobotLogs/*/output*.xml',
306 outputPath: '.',
307 passThreshold: 100,
308 reportFileName: 'RobotLogs/*/report*.html',
309 unstableThreshold: 0]);
Matteo Scandolofff6e062020-04-29 13:36:33 -0700310 archiveArtifacts artifacts: '*.log,*.gz'
311 }
312 }
313}