blob: 20573a7d5175b5cc48befd2743660b817270450c [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 {
Matteo Scandolo9aae4952020-09-14 13:05:53 -070029 PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Andy Bavier8b118b72020-04-28 12:59:30 -070030 VOLTHA_LOG_LEVEL="DEBUG"
Andy Bavier4af02722020-01-15 10:24:24 -070031 FANCY=0
32 WITH_SIM_ADAPTERS="n"
Matteo Scandolo39045a92020-07-29 08:58:29 -070033 NAME="test"
34 VOLTCONFIG="$HOME/.volt/config-$NAME"
35 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"
Matteo Scandolo697b8b82021-01-27 13:07:59 -080036 EXTRA_HELM_FLAGS=" --set global.image_registry=mirror.registry.opennetworking.org/ --set defaults.image_registry=mirror.registry.opennetworking.org/ "
Kailashaad71012019-08-27 10:36:53 -070037 }
38
39 stages {
Matteo Scandolo9aae4952020-09-14 13:05:53 -070040 stage('Clone kind-voltha') {
Kailashaad71012019-08-27 10:36:53 -070041 steps {
Matteo Scandolo9aae4952020-09-14 13:05:53 -070042 checkout([
43 $class: 'GitSCM',
44 userRemoteConfigs: [[
45 url: "https://gerrit.opencord.org/kind-voltha",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000046 refspec: "${kindVolthaChange}"
Matteo Scandolo9aae4952020-09-14 13:05:53 -070047 ]],
48 branches: [[ name: "master", ]],
49 extensions: [
50 [$class: 'WipeWorkspace'],
51 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
52 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
53 ],
54 ])
Matteo Scandolo57a06632020-09-18 18:38:54 -070055 sh """
56 if [ '${kindVolthaChange}' != '' ] ; then
57 cd $WORKSPACE/kind-voltha
58 git fetch https://gerrit.opencord.org/kind-voltha ${kindVolthaChange} && git checkout FETCH_HEAD
59 fi
60 """
Kailashaad71012019-08-27 10:36:53 -070061 }
62 }
Matteo Scandolo9aae4952020-09-14 13:05:53 -070063 stage('Clone voltha-system-tests') {
Kailashaad71012019-08-27 10:36:53 -070064 steps {
Matteo Scandolo9aae4952020-09-14 13:05:53 -070065 checkout([
66 $class: 'GitSCM',
67 userRemoteConfigs: [[
68 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000069 refspec: "${volthaSystemTestsChange}"
Matteo Scandolo9aae4952020-09-14 13:05:53 -070070 ]],
71 branches: [[ name: "${branch}", ]],
72 extensions: [
73 [$class: 'WipeWorkspace'],
74 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
75 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
76 ],
77 ])
Matteo Scandolo57a06632020-09-18 18:38:54 -070078 sh """
79 if [ '${volthaSystemTestsChange}' != '' ] ; then
80 cd $WORKSPACE/voltha-system-tests
81 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
82 fi
83 """
Matteo Scandolo9aae4952020-09-14 13:05:53 -070084 }
85 }
Matteo Scandolo8fc674c2020-09-14 18:05:37 -070086 // If the repo under test is not kind-voltha
87 // then download it and checkout the patch
Matteo Scandolo9aae4952020-09-14 13:05:53 -070088 stage('Download Patch') {
Matteo Scandolo8fc674c2020-09-14 18:05:37 -070089 when {
90 expression {
91 return "${gerritProject}" != 'kind-voltha';
92 }
93 }
Matteo Scandolo9aae4952020-09-14 13:05:53 -070094 steps {
95 checkout([
96 $class: 'GitSCM',
97 userRemoteConfigs: [[
98 url: "https://gerrit.opencord.org/${gerritProject}",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000099 refspec: "${gerritRefspec}"
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700100 ]],
101 branches: [[ name: "${branch}", ]],
102 extensions: [
103 [$class: 'WipeWorkspace'],
104 [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gerritProject}"],
105 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
106 ],
107 ])
Kailashaad71012019-08-27 10:36:53 -0700108 sh """
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700109 pushd $WORKSPACE/${gerritProject}
Matteo Scandolo57a06632020-09-18 18:38:54 -0700110 git fetch https://gerrit.opencord.org/${gerritProject} ${gerritRefspec} && git checkout FETCH_HEAD
111
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700112 echo "Currently on commit: \n"
113 git log -1 --oneline
114 popd
115 """
Kailashaad71012019-08-27 10:36:53 -0700116 }
117 }
Matteo Scandolo8fc674c2020-09-14 18:05:37 -0700118 // If the repo under test is kind-voltha we don't need to download it again,
119 // as we already have it, simply checkout the patch
120 stage('Checkout kind-voltha patch') {
121 when {
122 expression {
123 return "${gerritProject}" == 'kind-voltha';
124 }
125 }
126 steps {
127 sh """
128 cd $WORKSPACE/kind-voltha
129 git fetch https://gerrit.opencord.org/kind-voltha ${gerritRefspec} && git checkout FETCH_HEAD
130 """
131 }
132 }
Kailashaad71012019-08-27 10:36:53 -0700133 stage('Create K8s Cluster') {
134 steps {
135 sh """
Zack Williams03ebb272020-03-27 09:42:33 -0700136 if [ "${branch}" != "master" ]; then
137 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700138 source "$WORKSPACE/kind-voltha/releases/${branch}"
Zack Williams03ebb272020-03-27 09:42:33 -0700139 else
140 echo "on master, using default settings for kind-voltha"
141 fi
142
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700143 cd $WORKSPACE/kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -0700144 JUST_K8S=y ./voltha up
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700145 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
Kailashaad71012019-08-27 10:36:53 -0700146 """
147 }
148 }
149
150 stage('Build Images') {
151 steps {
152 sh """
Andy Bavierb99c3d32020-02-18 11:14:17 -0700153 make-local () {
Matteo Scandolo4adf1192020-12-15 09:44:14 -1000154 make -C $WORKSPACE/\$1 DOCKER_REGISTRY=mirror.registry.opennetworking.org/ DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
Andy Bavierb99c3d32020-02-18 11:14:17 -0700155 }
Andy Bavier0ed77062020-02-18 10:09:19 -0700156 if [ "${gerritProject}" = "pyvoltha" ]; then
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700157 make -C $WORKSPACE/pyvoltha/ dist
158 export LOCAL_PYVOLTHA=$WORKSPACE/pyvoltha/
Andy Bavierb99c3d32020-02-18 11:14:17 -0700159 make-local voltha-openonu-adapter
160 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700161 make -C $WORKSPACE/voltha-lib-go/ build
162 export LOCAL_LIB_GO=$WORKSPACE/voltha-lib-go/
Andy Bavierb99c3d32020-02-18 11:14:17 -0700163 make-local voltha-go
164 make-local voltha-openolt-adapter
165 elif [ "${gerritProject}" = "voltha-protos" ]; then
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700166 make -C $WORKSPACE/voltha-protos/ build
167 export LOCAL_PROTOS=$WORKSPACE/voltha-protos/
Andy Bavierb99c3d32020-02-18 11:14:17 -0700168 make-local voltha-go
169 make-local voltha-openolt-adapter
170 make-local voltha-openonu-adapter
171 make-local ofagent-py
Andy Bavier178c47b2020-04-01 13:05:43 -0700172 elif [ "${gerritProject}" = "voltctl" ]; then
Andy Bavierdecde3f2020-04-01 15:29:43 -0700173 # Set and handle GOPATH and PATH
174 export GOPATH=\${GOPATH:-$WORKSPACE/go}
175 export PATH=\$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:\$GOPATH/bin
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700176 make -C $WORKSPACE/voltctl/ build
Andy Bavier4318f8d2020-04-09 13:50:53 -0700177 elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|kind-voltha)\$ ]]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -0700178 make-local ${gerritProject}
Andy Bavier07615f92019-10-03 12:31:18 -0700179 fi
Kailashaad71012019-08-27 10:36:53 -0700180 """
181 }
182 }
183
184 stage('Push Images') {
185 steps {
186 sh '''
Zack Williams03ebb272020-03-27 09:42:33 -0700187 if [ "${branch}" != "master" ]; then
188 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700189 source "$WORKSPACE/kind-voltha/releases/${branch}"
Zack Williams03ebb272020-03-27 09:42:33 -0700190 else
191 echo "on master, using default settings for kind-voltha"
192 fi
193
Andy Bavierb5c8caf2020-04-06 14:12:07 -0700194 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|voltctl|kind-voltha)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -0700195 export GOROOT=/usr/local/go
196 export GOPATH=\$(pwd)
Andy Bavier07615f92019-10-03 12:31:18 -0700197 docker images | grep citest
Matteo Scandolo4adf1192020-12-15 09:44:14 -1000198 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
Andy Bavier07615f92019-10-03 12:31:18 -0700199 fi
Kailashaad71012019-08-27 10:36:53 -0700200 '''
201 }
202 }
Andy Bavier8b118b72020-04-28 12:59:30 -0700203
204 stage('ATT workflow') {
205 environment {
206 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ATTWorkflow"
207 }
Kailashaad71012019-08-27 10:36:53 -0700208 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700209 sh '''
Zack Williams03ebb272020-03-27 09:42:33 -0700210 if [ "${branch}" != "master" ]; then
211 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700212 source "$WORKSPACE/kind-voltha/releases/${branch}"
Zack Williams03ebb272020-03-27 09:42:33 -0700213 else
214 echo "on master, using default settings for kind-voltha"
215 fi
216
Matteo Scandolof72f4d12020-12-14 09:53:28 -1000217 if [[ "${gerritProject}" == voltha-helm-charts ]]; then
Andrea Campanellae8e2e012021-01-22 10:59:07 +0100218 export EXTRA_HELM_FLAGS+="--set global.image_tag=null "
Matteo Scandolof72f4d12020-12-14 09:53:28 -1000219 fi
220
Andy Bavier8b118b72020-04-28 12:59:30 -0700221 # Workflow-specific flags
222 export WITH_RADIUS=yes
223 export WITH_BBSIM=yes
224 export DEPLOY_K8S=yes
Matteo Scandolo3d6a21d2020-09-04 07:34:24 -0700225 export CONFIG_SADIS="external"
226 export BBSIM_CFG="configs/bbsim-sadis-att.yaml"
Andy Bavier8b118b72020-04-28 12:59:30 -0700227
Zack Williams03ebb272020-03-27 09:42:33 -0700228 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700229
Andy Bavier4af02722020-01-15 10:24:24 -0700230 IMAGES=""
Kailashaad71012019-08-27 10:36:53 -0700231 if [ "${gerritProject}" = "voltha-go" ]; then
Andy Bavier4af02722020-01-15 10:24:24 -0700232 IMAGES="rw_core ro_core "
233 elif [ "${gerritProject}" = "ofagent-py" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700234 IMAGES="ofagent_py "
235 EXTRA_HELM_FLAGS+="--set use_ofagent_go=false "
Andy Bavier9c412a82020-03-23 12:00:28 -0700236 elif [ "${gerritProject}" = "ofagent-go" ]; then
Andy Bavier8d816422020-03-23 15:34:26 -0700237 IMAGES="ofagent_go "
Andy Bavier4af02722020-01-15 10:24:24 -0700238 elif [ "${gerritProject}" = "voltha-onos" ]; then
239 IMAGES="onos "
Andrea Campanellae39825e2020-12-16 21:35:03 +0100240 EXTRA_HELM_FLAGS+="--set images.onos.repository=mirror.registry.opennetworking.org/voltha/voltha-onos "
Andy Bavier4af02722020-01-15 10:24:24 -0700241 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
242 IMAGES="adapter_open_olt "
243 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
244 IMAGES="adapter_open_onu "
245 elif [ "${gerritProject}" = "voltha-api-server" ]; then
246 IMAGES="afrouter afrouterd "
247 elif [ "${gerritProject}" = "bbsim" ]; then
248 IMAGES="bbsim "
Andy Bavierec0c10d2020-02-14 13:06:27 -0700249 elif [ "${gerritProject}" = "pyvoltha" ]; then
250 IMAGES="adapter_open_onu "
Andy Bavierb99c3d32020-02-18 11:14:17 -0700251 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
252 IMAGES="rw_core ro_core adapter_open_olt "
253 elif [ "${gerritProject}" = "voltha-protos" ]; then
254 IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent "
Zack Williams04997502019-10-04 14:32:20 -0700255 else
Andy Bavier4af02722020-01-15 10:24:24 -0700256 echo "No images to push"
Scott Baker9ac23712019-10-02 09:26:50 -0700257 fi
258
Andy Bavier4af02722020-01-15 10:24:24 -0700259 for I in \$IMAGES
260 do
261 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
262 done
263
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700264 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700265 export CHART_PATH=$WORKSPACE/voltha-helm-charts
Andy Bavier45406342019-10-02 16:45:40 -0700266 export VOLTHA_CHART=\$CHART_PATH/voltha
267 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
268 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700269 helm dep update \$VOLTHA_CHART
270 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
271 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
272 fi
273
Andy Bavier178c47b2020-04-01 13:05:43 -0700274 if [ "${gerritProject}" = "voltctl" ]; then
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700275 export VOLTCTL_VERSION=$(cat $WORKSPACE/voltctl/VERSION)
276 cp $WORKSPACE/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
277 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Andy Bavier178c47b2020-04-01 13:05:43 -0700278 fi
279
Andy Bavier8b118b72020-04-28 12:59:30 -0700280 printenv
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800281
282 # start logging
283 mkdir -p $WORKSPACE/att
284 _TAG=kail-att kail -n voltha -n default > $WORKSPACE/att/onos-voltha-combined.log &
Kailashaad71012019-08-27 10:36:53 -0700285
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700286 cd $WORKSPACE/kind-voltha/
Andy Bavier8b118b72020-04-28 12:59:30 -0700287 ./voltha up
288
Matteo Scandolo39045a92020-07-29 08:58:29 -0700289 # $NAME-env.sh contains the environment we used
Andy Bavier8b118b72020-04-28 12:59:30 -0700290 # Save value of EXTRA_HELM_FLAGS there to use in subsequent stages
Matteo Scandolo39045a92020-07-29 08:58:29 -0700291 echo export EXTRA_HELM_FLAGS=\\"\$EXTRA_HELM_FLAGS\\" >> $NAME-env.sh
Andy Bavier8b118b72020-04-28 12:59:30 -0700292
293 mkdir -p $ROBOT_LOGS_DIR
Andy Bavierd9870042020-06-23 13:16:47 -0700294 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
Andy Bavierdb003082020-02-04 11:57:36 -0700295
296 # By default, all tests tagged 'sanity' are run. This covers basic functionality
297 # like running through the ATT workflow for a single subscriber.
Andy Bavier8b118b72020-04-28 12:59:30 -0700298 export TARGET=sanity-single-kind
Andy Bavierdb003082020-02-04 11:57:36 -0700299
300 # If the Gerrit comment contains a line with "functional tests" then run the full
301 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
302 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
303 REGEX="functional tests"
304 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
Andy Bavier8b118b72020-04-28 12:59:30 -0700305 TARGET=functional-single-kind
Andy Bavierdb003082020-02-04 11:57:36 -0700306 fi
307
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700308 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800309
310 # stop logging
311 P_IDS="$(ps e -ww -A | grep "_TAG=kail-att" | grep -v grep | awk '{print $1}')"
312 if [ -n "$P_IDS" ]; then
313 echo $P_IDS
314 for P_ID in $P_IDS; do
315 kill -9 $P_ID
316 done
317 fi
318
319 # get pods information
320 kubectl get pods -o wide > $WORKSPACE/att/pods.txt || true
321 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $WORKSPACE/att/pod-images.txt || true
322 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee $WORKSPACE/att/pod-imagesId.txt || true
Andy Bavier8b118b72020-04-28 12:59:30 -0700323 '''
324 }
325 }
326
327 stage('DT workflow') {
328 environment {
329 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DTWorkflow"
330 }
331 steps {
332 sh '''
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700333 cd $WORKSPACE/kind-voltha/
Matteo Scandolo39045a92020-07-29 08:58:29 -0700334 source $NAME-env.sh
Andrea Campanella57735a82021-05-18 13:22:49 +0200335 if [ "${branch}" != "master" ]; then
336 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
337 source "$WORKSPACE/kind-voltha/releases/${branch}"
338 else
339 echo "on master, using default settings for kind-voltha"
340 fi
Andy Bavier8b118b72020-04-28 12:59:30 -0700341 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
342
343 # Workflow-specific flags
344 export WITH_RADIUS=no
345 export WITH_EAPOL=no
346 export WITH_DHCP=no
347 export WITH_IGMP=no
Matteo Scandolo3d6a21d2020-09-04 07:34:24 -0700348 export CONFIG_SADIS="external"
349 export BBSIM_CFG="configs/bbsim-sadis-dt.yaml"
Andy Bavier8b118b72020-04-28 12:59:30 -0700350
Matteo Scandolof72f4d12020-12-14 09:53:28 -1000351 if [[ "${gerritProject}" == voltha-helm-charts ]]; then
Andrea Campanellae8e2e012021-01-22 10:59:07 +0100352 export EXTRA_HELM_FLAGS+="--set global.image_tag=null "
Matteo Scandolof72f4d12020-12-14 09:53:28 -1000353 fi
354
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800355 # start logging
356 mkdir -p $WORKSPACE/dt
357 _TAG=kail-dt kail -n voltha -n default > $WORKSPACE/dt/onos-voltha-combined.log &
358
Andy Bavier8b118b72020-04-28 12:59:30 -0700359 DEPLOY_K8S=n ./voltha up
360
361 mkdir -p $ROBOT_LOGS_DIR
Andy Bavierd9870042020-06-23 13:16:47 -0700362 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
Andy Bavier8b118b72020-04-28 12:59:30 -0700363
364 # By default, all tests tagged 'sanityDt' are run. This covers basic functionality
365 # like running through the DT workflow for a single subscriber.
366 export TARGET=sanity-kind-dt
367
368 # If the Gerrit comment contains a line with "functional tests" then run the full
369 # functional test suite. This covers tests tagged either 'sanityDt' or 'functionalDt'.
370 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
371 REGEX="functional tests"
372 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
373 TARGET=functional-single-kind-dt
374 fi
375
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700376 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800377
378 # stop logging
379 P_IDS="$(ps e -ww -A | grep "_TAG=kail-dt" | grep -v grep | awk '{print $1}')"
380 if [ -n "$P_IDS" ]; then
381 echo $P_IDS
382 for P_ID in $P_IDS; do
383 kill -9 $P_ID
384 done
385 fi
386
387 # get pods information
388 kubectl get pods -o wide > $WORKSPACE/dt/pods.txt || true
389 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $WORKSPACE/dt/pod-images.txt || true
390 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee $WORKSPACE/dt/pod-imagesId.txt || true
Kailashaad71012019-08-27 10:36:53 -0700391 '''
392 }
393 }
Matteo Scandolo294133a2020-09-04 11:19:43 -0700394
395 stage('TT workflow') {
396 environment {
397 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/TTWorkflow"
398 }
399 steps {
400 sh '''
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700401 cd $WORKSPACE/kind-voltha/
Matteo Scandolo294133a2020-09-04 11:19:43 -0700402 source $NAME-env.sh
Andrea Campanella57735a82021-05-18 13:22:49 +0200403 if [ "${branch}" != "master" ]; then
404 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
405 source "$WORKSPACE/kind-voltha/releases/${branch}"
406 else
407 echo "on master, using default settings for kind-voltha"
408 fi
Matteo Scandolo294133a2020-09-04 11:19:43 -0700409 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
410
411 # Workflow-specific flags
412 export WITH_RADIUS=no
413 export WITH_EAPOL=no
414 export WITH_DHCP=yes
415 export WITH_IGMP=yes
416 export CONFIG_SADIS="external"
417 export BBSIM_CFG="configs/bbsim-sadis-tt.yaml"
418
Matteo Scandolof72f4d12020-12-14 09:53:28 -1000419 if [[ "${gerritProject}" == voltha-helm-charts ]]; then
Andrea Campanellae8e2e012021-01-22 10:59:07 +0100420 export EXTRA_HELM_FLAGS+="--set global.image_tag=null "
Matteo Scandolof72f4d12020-12-14 09:53:28 -1000421 fi
422
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800423 # start logging
424 mkdir -p $WORKSPACE/tt
425 _TAG=kail-tt kail -n voltha -n default > $WORKSPACE/tt/onos-voltha-combined.log &
426
Matteo Scandolo294133a2020-09-04 11:19:43 -0700427 DEPLOY_K8S=n ./voltha up
428
429 mkdir -p $ROBOT_LOGS_DIR
430 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
431
432 # By default, all tests tagged 'sanityTt' are run. This covers basic functionality
433 # like running through the TT workflow for a single subscriber.
434 export TARGET=sanity-kind-tt
435
436 # If the Gerrit comment contains a line with "functional tests" then run the full
437 # functional test suite. This covers tests tagged either 'sanityTt' or 'functionalTt'.
438 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
439 REGEX="functional tests"
440 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
441 TARGET=functional-single-kind-tt
442 fi
443
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700444 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800445
446 # stop logging
447 P_IDS="$(ps e -ww -A | grep "_TAG=kail-att" | grep -v grep | awk '{print $1}')"
448 if [ -n "$P_IDS" ]; then
449 echo $P_IDS
450 for P_ID in $P_IDS; do
451 kill -9 $P_ID
452 done
453 fi
454
455 # get pods information
456 kubectl get pods -o wide > $WORKSPACE/tt/pods.txt || true
457 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $WORKSPACE/tt/pod-images.txt || true
458 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee $WORKSPACE/tt/pod-imagesId.txt || true
Matteo Scandolo294133a2020-09-04 11:19:43 -0700459 '''
460 }
461 }
Kailashaad71012019-08-27 10:36:53 -0700462 }
463
464 post {
465 always {
466 sh '''
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000467
468 # get pods information
Matteo Scandolo52a4cd92021-01-25 10:17:44 -0800469 kubectl get pods -o wide --all-namespaces
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000470 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}"
Matteo Scandolo52a4cd92021-01-25 10:17:44 -0800471 helm ls --all-namespaces
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000472
Andy Bavier07615f92019-10-03 12:31:18 -0700473 set +e
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700474 cp $WORKSPACE/kind-voltha/install-$NAME.log $WORKSPACE/
Andy Bavier4af02722020-01-15 10:24:24 -0700475
476 sync
Matteo Scandolo9aae4952020-09-14 13:05:53 -0700477 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Andy Bavier4af02722020-01-15 10:24:24 -0700478
479 ## Pull out errors from log files
480 extract_errors_go() {
481 echo
482 echo "Error summary for $1:"
483 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
484 echo
485 }
486
487 extract_errors_python() {
488 echo
489 echo "Error summary for $1:"
490 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
491 echo
492 }
493
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000494 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log || true
495 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log || true
496 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log || true
497 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log || true
Andy Bavier4af02722020-01-15 10:24:24 -0700498
Matteo Scandolo7eba41c2020-12-15 08:59:36 -1000499 gzip $WORKSPACE/att/onos-voltha-combined.log || true
500 gzip $WORKSPACE/dt/onos-voltha-combined.log || true
501 gzip $WORKSPACE/tt/onos-voltha-combined.log || true
502
Kailashaad71012019-08-27 10:36:53 -0700503 '''
504 step([$class: 'RobotPublisher',
505 disableArchiveOutput: false,
Andy Bavier8b118b72020-04-28 12:59:30 -0700506 logFileName: 'RobotLogs/*/log*.html',
Kailashaad71012019-08-27 10:36:53 -0700507 otherFiles: '',
Andy Bavier8b118b72020-04-28 12:59:30 -0700508 outputFileName: 'RobotLogs/*/output*.xml',
Kailashaad71012019-08-27 10:36:53 -0700509 outputPath: '.',
Andy Bavier8b118b72020-04-28 12:59:30 -0700510 passThreshold: 100,
511 reportFileName: 'RobotLogs/*/report*.html',
Kailashaad71012019-08-27 10:36:53 -0700512 unstableThreshold: 0]);
Matteo Scandolobafd4f02020-12-09 12:14:55 -0800513 archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz'
Kailashaad71012019-08-27 10:36:53 -0700514 }
515 }
516}