blob: b1a7413ed01e1935f88563cc6744ed9f277e784c [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"
31 PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
32 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"
39 CONFIG_SADIS="n"
Andy Baviere234fa52020-02-24 11:32:03 -070040 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
Kailashaad71012019-08-27 10:36:53 -070041 }
42
43 stages {
44
45 stage('Repo') {
46 steps {
Andy Bavier4af02722020-01-15 10:24:24 -070047 step([$class: 'WsCleanup'])
Kailashaad71012019-08-27 10:36:53 -070048 checkout(changelog: false, \
49 poll: false,
50 scm: [$class: 'RepoScm', \
51 manifestRepositoryUrl: "${params.manifestUrl}", \
52 manifestBranch: "${params.manifestBranch}", \
53 currentBranch: true, \
54 destinationDir: 'voltha', \
55 forceSync: true,
56 resetFirst: true, \
57 quiet: true, \
58 jobs: 4, \
59 showAllChanges: true] \
60 )
61 }
62 }
63 stage('Patch') {
64 steps {
65 sh """
66 pushd voltha
Andy Bavier5b523532020-02-24 15:31:25 -070067 repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
Kailashaad71012019-08-27 10:36:53 -070068 popd
69 """
70 }
71 }
72 stage('Create K8s Cluster') {
73 steps {
74 sh """
Kailashaad71012019-08-27 10:36:53 -070075 git clone https://github.com/ciena/kind-voltha.git
76 cd kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -070077 JUST_K8S=y ./voltha up
78 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
Kailashaad71012019-08-27 10:36:53 -070079 """
80 }
81 }
82
83 stage('Build Images') {
84 steps {
85 sh """
Andy Bavierb99c3d32020-02-18 11:14:17 -070086 make-local () {
87 make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
88 }
Andy Bavier0ed77062020-02-18 10:09:19 -070089 if [ "${gerritProject}" = "pyvoltha" ]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -070090 make -C $WORKSPACE/voltha/pyvoltha/ dist
Andy Bavier0ed77062020-02-18 10:09:19 -070091 export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/
Andy Bavierb99c3d32020-02-18 11:14:17 -070092 make-local voltha-openonu-adapter
93 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
94 make -C $WORKSPACE/voltha/voltha-lib-go/ build
95 export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/
96 make-local voltha-go
97 make-local voltha-openolt-adapter
98 elif [ "${gerritProject}" = "voltha-protos" ]; then
99 make -C $WORKSPACE/voltha/voltha-protos/ build
100 export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/
101 make-local voltha-go
102 make-local voltha-openolt-adapter
103 make-local voltha-openonu-adapter
104 make-local ofagent-py
Andy Bavier0ed77062020-02-18 10:09:19 -0700105 elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavierb99c3d32020-02-18 11:14:17 -0700106 make-local ${gerritProject}
Andy Bavier07615f92019-10-03 12:31:18 -0700107 fi
Kailashaad71012019-08-27 10:36:53 -0700108 """
109 }
110 }
111
112 stage('Push Images') {
113 steps {
114 sh '''
Andy Bavier0ed77062020-02-18 10:09:19 -0700115 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -0700116 export GOROOT=/usr/local/go
117 export GOPATH=\$(pwd)
Andy Bavier07615f92019-10-03 12:31:18 -0700118 docker images | grep citest
119 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
120 fi
Kailashaad71012019-08-27 10:36:53 -0700121 '''
122 }
123 }
124 stage('Deploy Voltha') {
125 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700126 sh '''
Andy Bavier4af02722020-01-15 10:24:24 -0700127 export EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700128
Andy Bavier4af02722020-01-15 10:24:24 -0700129 IMAGES=""
Kailashaad71012019-08-27 10:36:53 -0700130 if [ "${gerritProject}" = "voltha-go" ]; then
Andy Bavier4af02722020-01-15 10:24:24 -0700131 IMAGES="rw_core ro_core "
132 elif [ "${gerritProject}" = "ofagent-py" ]; then
133 IMAGES="ofagent "
134 elif [ "${gerritProject}" = "voltha-onos" ]; then
135 IMAGES="onos "
136 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
137 IMAGES="adapter_open_olt "
138 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
139 IMAGES="adapter_open_onu "
140 elif [ "${gerritProject}" = "voltha-api-server" ]; then
141 IMAGES="afrouter afrouterd "
142 elif [ "${gerritProject}" = "bbsim" ]; then
143 IMAGES="bbsim "
Andy Bavierec0c10d2020-02-14 13:06:27 -0700144 elif [ "${gerritProject}" = "pyvoltha" ]; then
145 IMAGES="adapter_open_onu "
Andy Bavierb99c3d32020-02-18 11:14:17 -0700146 elif [ "${gerritProject}" = "voltha-lib-go" ]; then
147 IMAGES="rw_core ro_core adapter_open_olt "
148 elif [ "${gerritProject}" = "voltha-protos" ]; then
149 IMAGES="rw_core ro_core adapter_open_olt adapter_open_onu ofagent "
Zack Williams04997502019-10-04 14:32:20 -0700150 else
Andy Bavier4af02722020-01-15 10:24:24 -0700151 echo "No images to push"
Scott Baker9ac23712019-10-02 09:26:50 -0700152 fi
153
Andy Bavier4af02722020-01-15 10:24:24 -0700154 for I in \$IMAGES
155 do
156 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
157 done
158
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700159 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700160 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
161 export VOLTHA_CHART=\$CHART_PATH/voltha
162 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
163 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700164 helm dep update \$VOLTHA_CHART
165 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
166 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
167 fi
168
169 cd $WORKSPACE/kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -0700170 echo \$EXTRA_HELM_FLAGS
171 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
172 ./voltha up
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700173 '''
Kailashaad71012019-08-27 10:36:53 -0700174 }
175 }
176
177 stage('Run E2E Tests') {
178 steps {
179 sh '''
Andy Bavier4af02722020-01-15 10:24:24 -0700180 mkdir -p $WORKSPACE/RobotLogs
Andy Bavierdb003082020-02-04 11:57:36 -0700181
182 # By default, all tests tagged 'sanity' are run. This covers basic functionality
183 # like running through the ATT workflow for a single subscriber.
184 export TEST_TAGS=sanity
185
186 # If the Gerrit comment contains a line with "functional tests" then run the full
187 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
188 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
189 REGEX="functional tests"
190 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
191 TEST_TAGS=sanityORfunctional
192 fi
193
194 make -C $WORKSPACE/voltha/voltha-system-tests single-kind || true
Kailashaad71012019-08-27 10:36:53 -0700195 '''
196 }
197 }
198 }
199
200 post {
201 always {
202 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700203 set +e
Andy Bavier4af02722020-01-15 10:24:24 -0700204 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Andy Bavieraec60382019-10-29 15:09:04 -0700205 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
Kailashaad71012019-08-27 10:36:53 -0700206 kubectl get nodes -o wide
207 kubectl get pods -o wide
208 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700209
210 sync
211 pkill kail || true
212
213 ## Pull out errors from log files
214 extract_errors_go() {
215 echo
216 echo "Error summary for $1:"
217 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
218 echo
219 }
220
221 extract_errors_python() {
222 echo
223 echo "Error summary for $1:"
224 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
225 echo
226 }
227
228 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
229 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
230 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
231 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
232
Andy Bavier2178d102020-02-06 16:22:11 -0700233 gzip $WORKSPACE/onos-voltha-combined.log
234
Andy Bavier4af02722020-01-15 10:24:24 -0700235 ## shut down kind-voltha
236 cd $WORKSPACE/kind-voltha
237 WAIT_ON_DOWN=y ./voltha down
Kailashaad71012019-08-27 10:36:53 -0700238 '''
239 step([$class: 'RobotPublisher',
240 disableArchiveOutput: false,
241 logFileName: 'RobotLogs/log*.html',
242 otherFiles: '',
243 outputFileName: 'RobotLogs/output*.xml',
244 outputPath: '.',
245 passThreshold: 80,
246 reportFileName: 'RobotLogs/report*.html',
247 unstableThreshold: 0]);
Andy Bavier2178d102020-02-06 16:22:11 -0700248 archiveArtifacts artifacts: '*.log,*.gz'
Kailashaad71012019-08-27 10:36:53 -0700249 }
250 }
251}