blob: 485fdbf1f87df593b72630f1c7bbf0933be96046 [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 {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
Andy Bavierb5c8caf2020-04-06 14:12:07 -070031 PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Andy Bavier4af02722020-01-15 10:24:24 -070032 TYPE="minimal"
Andy Bavier8b118b72020-04-28 12:59:30 -070033 VOLTHA_LOG_LEVEL="DEBUG"
Andy Bavier4af02722020-01-15 10:24:24 -070034 FANCY=0
35 WITH_SIM_ADAPTERS="n"
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
137 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
138 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
160 export CONFIG_SADIS=no
161
Zack Williams03ebb272020-03-27 09:42:33 -0700162 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700163
Andy Bavier4af02722020-01-15 10:24:24 -0700164 IMAGES=""
Kailashaad71012019-08-27 10:36:53 -0700165 if [ "${gerritProject}" = "voltha-go" ]; then
Andy Bavier4af02722020-01-15 10:24:24 -0700166 IMAGES="rw_core ro_core "
167 elif [ "${gerritProject}" = "ofagent-py" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700168 IMAGES="ofagent_py "
169 EXTRA_HELM_FLAGS+="--set use_ofagent_go=false "
Andy Bavier9c412a82020-03-23 12:00:28 -0700170 elif [ "${gerritProject}" = "ofagent-go" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700171 IMAGES="ofagent_go "
Andy Bavier4af02722020-01-15 10:24:24 -0700172 elif [ "${gerritProject}" = "voltha-onos" ]; then
173 IMAGES="onos "
174 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
175 IMAGES="adapter_open_olt "
176 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
177 IMAGES="adapter_open_onu "
178 elif [ "${gerritProject}" = "voltha-api-server" ]; then
179 IMAGES="afrouter afrouterd "
180 elif [ "${gerritProject}" = "bbsim" ]; then
181 IMAGES="bbsim "
Andy Bavierec0c10d2020-02-14 13:06:27 -0700182 elif [ "${gerritProject}" = "pyvoltha" ]; then
183 IMAGES="adapter_open_onu "
Andy Bavierb99c3d32020-02-18 11:14:17 -0700184 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
185 IMAGES="rw_core ro_core adapter_open_olt "
186 elif [ "${gerritProject}" = "voltha-protos" ]; then
187 IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent "
Zack Williams04997502019-10-04 14:32:20 -0700188 else
Andy Bavier4af02722020-01-15 10:24:24 -0700189 echo "No images to push"
Scott Baker9ac23712019-10-02 09:26:50 -0700190 fi
191
Andy Bavier4af02722020-01-15 10:24:24 -0700192 for I in \$IMAGES
193 do
194 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
195 done
196
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700197 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700198 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
199 export VOLTHA_CHART=\$CHART_PATH/voltha
200 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
201 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700202 helm dep update \$VOLTHA_CHART
203 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
204 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
205 fi
206
Andy Bavier178c47b2020-04-01 13:05:43 -0700207 if [ "${gerritProject}" = "voltctl" ]; then
208 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltha/voltctl/VERSION)
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700209 cp $WORKSPACE/voltha/voltctl/voltctl $WORKSPACE/voltha/kind-voltha/bin/voltctl
210 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
Andy Bavier178c47b2020-04-01 13:05:43 -0700211 fi
212
Andy Bavier8b118b72020-04-28 12:59:30 -0700213 printenv
Andy Bavier4af02722020-01-15 10:24:24 -0700214 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
Kailashaad71012019-08-27 10:36:53 -0700215
Andy Bavier8b118b72020-04-28 12:59:30 -0700216 cd $WORKSPACE/voltha/kind-voltha/
217 ./voltha up
218
219 # minimal-env.sh contains the environment we used
220 # Save value of EXTRA_HELM_FLAGS there to use in subsequent stages
221 echo export EXTRA_HELM_FLAGS=\\"\$EXTRA_HELM_FLAGS\\" >> minimal-env.sh
222
223 mkdir -p $ROBOT_LOGS_DIR
224 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Andy Bavierdb003082020-02-04 11:57:36 -0700225
226 # By default, all tests tagged 'sanity' are run. This covers basic functionality
227 # like running through the ATT workflow for a single subscriber.
Andy Bavier8b118b72020-04-28 12:59:30 -0700228 export TARGET=sanity-single-kind
Andy Bavierdb003082020-02-04 11:57:36 -0700229
230 # If the Gerrit comment contains a line with "functional tests" then run the full
231 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
232 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
233 REGEX="functional tests"
234 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
Andy Bavier8b118b72020-04-28 12:59:30 -0700235 TARGET=functional-single-kind
Andy Bavierdb003082020-02-04 11:57:36 -0700236 fi
237
Andy Bavier8b118b72020-04-28 12:59:30 -0700238 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
239 '''
240 }
241 }
242
243 stage('DT workflow') {
244 environment {
245 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DTWorkflow"
246 }
247 steps {
248 sh '''
249 cd $WORKSPACE/voltha/kind-voltha/
250 source minimal-env.sh
251 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
252
253 # Workflow-specific flags
254 export WITH_RADIUS=no
255 export WITH_EAPOL=no
256 export WITH_DHCP=no
257 export WITH_IGMP=no
258 export CONFIG_SADIS=no
259
260 DEPLOY_K8S=n ./voltha up
261
262 mkdir -p $ROBOT_LOGS_DIR
263 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
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/voltha-system-tests \$TARGET || true
Kailashaad71012019-08-27 10:36:53 -0700278 '''
279 }
280 }
281 }
282
283 post {
284 always {
285 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700286 set +e
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700287 cp $WORKSPACE/voltha/kind-voltha/install-minimal.log $WORKSPACE/
Matteo Scandolo97b12572020-04-13 12:44:46 -0700288 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
289 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Kailashaad71012019-08-27 10:36:53 -0700290 kubectl get nodes -o wide
291 kubectl get pods -o wide
292 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700293
294 sync
295 pkill kail || true
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700296 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
Andy Bavier4af02722020-01-15 10:24:24 -0700297
298 ## Pull out errors from log files
299 extract_errors_go() {
300 echo
301 echo "Error summary for $1:"
302 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
303 echo
304 }
305
306 extract_errors_python() {
307 echo
308 echo "Error summary for $1:"
309 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
310 echo
311 }
312
313 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
314 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
315 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
316 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
317
Andy Bavier2178d102020-02-06 16:22:11 -0700318 gzip $WORKSPACE/onos-voltha-combined.log
Kailashaad71012019-08-27 10:36:53 -0700319 '''
320 step([$class: 'RobotPublisher',
321 disableArchiveOutput: false,
Andy Bavier8b118b72020-04-28 12:59:30 -0700322 logFileName: 'RobotLogs/*/log*.html',
Kailashaad71012019-08-27 10:36:53 -0700323 otherFiles: '',
Andy Bavier8b118b72020-04-28 12:59:30 -0700324 outputFileName: 'RobotLogs/*/output*.xml',
Kailashaad71012019-08-27 10:36:53 -0700325 outputPath: '.',
Andy Bavier8b118b72020-04-28 12:59:30 -0700326 passThreshold: 100,
327 reportFileName: 'RobotLogs/*/report*.html',
Kailashaad71012019-08-27 10:36:53 -0700328 unstableThreshold: 0]);
Andy Bavier2178d102020-02-06 16:22:11 -0700329 archiveArtifacts artifacts: '*.log,*.gz'
Kailashaad71012019-08-27 10:36:53 -0700330 }
331 }
332}