blob: 86b88efbb329c6d1d13682ff1507133b8fa01d87 [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"
40 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs -v teardown_device:False"
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
67 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
68 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
69 popd
70 """
71 }
72 }
73 stage('Create K8s Cluster') {
74 steps {
75 sh """
Kailashaad71012019-08-27 10:36:53 -070076 git clone https://github.com/ciena/kind-voltha.git
77 cd kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -070078 JUST_K8S=y ./voltha up
79 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
Kailashaad71012019-08-27 10:36:53 -070080 """
81 }
82 }
83
84 stage('Build Images') {
85 steps {
86 sh """
Matteo Scandolodbbc8d42020-02-12 10:47:35 -080087 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -070088 cd $WORKSPACE/voltha/${gerritProject}/
89 make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
90 fi
Kailashaad71012019-08-27 10:36:53 -070091 """
92 }
93 }
94
95 stage('Push Images') {
96 steps {
97 sh '''
hwchiu9140fd22019-10-10 15:48:30 -070098 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -070099 export GOROOT=/usr/local/go
100 export GOPATH=\$(pwd)
Andy Bavier07615f92019-10-03 12:31:18 -0700101 docker images | grep citest
102 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
103 fi
Kailashaad71012019-08-27 10:36:53 -0700104 '''
105 }
106 }
107 stage('Deploy Voltha') {
108 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700109 sh '''
Andy Bavier4af02722020-01-15 10:24:24 -0700110 export EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700111
Andy Bavier4af02722020-01-15 10:24:24 -0700112 IMAGES=""
Kailashaad71012019-08-27 10:36:53 -0700113 if [ "${gerritProject}" = "voltha-go" ]; then
Andy Bavier4af02722020-01-15 10:24:24 -0700114 IMAGES="rw_core ro_core "
115 elif [ "${gerritProject}" = "ofagent-py" ]; then
116 IMAGES="ofagent "
117 elif [ "${gerritProject}" = "voltha-onos" ]; then
118 IMAGES="onos "
119 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
120 IMAGES="adapter_open_olt "
121 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
122 IMAGES="adapter_open_onu "
123 elif [ "${gerritProject}" = "voltha-api-server" ]; then
124 IMAGES="afrouter afrouterd "
125 elif [ "${gerritProject}" = "bbsim" ]; then
126 IMAGES="bbsim "
Zack Williams04997502019-10-04 14:32:20 -0700127 else
Andy Bavier4af02722020-01-15 10:24:24 -0700128 echo "No images to push"
Scott Baker9ac23712019-10-02 09:26:50 -0700129 fi
130
Andy Bavier4af02722020-01-15 10:24:24 -0700131 for I in \$IMAGES
132 do
133 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
134 done
135
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700136 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700137 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
138 export VOLTHA_CHART=\$CHART_PATH/voltha
139 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
140 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700141 helm dep update \$VOLTHA_CHART
142 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
143 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
144 fi
145
146 cd $WORKSPACE/kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -0700147 echo \$EXTRA_HELM_FLAGS
148 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
149 ./voltha up
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700150 '''
Kailashaad71012019-08-27 10:36:53 -0700151 }
152 }
153
Matteo Scandolo84e5f002020-02-10 11:50:05 -0800154 stage('ONOS Config') {
155 steps {
156 sh '''
157 if [[ ${onosVersion} == "1.13.10" ]]; then
Matteo Scandolodbbc8d42020-02-12 10:47:35 -0800158 sshpass -p karaf ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 "cfg set org.opencord.olt.impl.OltFlowService enableDhcpOnProvisioning true"
159 sshpass -p karaf ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 "cfg set org.opencord.olt.impl.OltFlowService enableDhcpV4 true"
160 sshpass -p karaf ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 "cfg set org.opencord.olt.impl.OltFlowService enableEapol true"
Matteo Scandolo84e5f002020-02-10 11:50:05 -0800161 else
162 echo "Using kind-voltha defaults"
163 fi
164 '''
165 }
166 }
167
Kailashaad71012019-08-27 10:36:53 -0700168 stage('Run E2E Tests') {
169 steps {
170 sh '''
Andy Bavier4af02722020-01-15 10:24:24 -0700171 mkdir -p $WORKSPACE/RobotLogs
Andy Bavierdb003082020-02-04 11:57:36 -0700172
173 # By default, all tests tagged 'sanity' are run. This covers basic functionality
174 # like running through the ATT workflow for a single subscriber.
175 export TEST_TAGS=sanity
176
177 # If the Gerrit comment contains a line with "functional tests" then run the full
178 # functional test suite. This covers tests tagged either 'sanity' or 'functional'.
179 # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
180 REGEX="functional tests"
181 if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
182 TEST_TAGS=sanityORfunctional
183 fi
184
Matteo Scandolobebfc5f2020-02-12 13:06:17 -0800185 if [[ ${onosVersion} == "1.13.10" ]]; then
186 ROBOT_MISC_ARGS+=" -v sadis.file:../data/onos-sadis-bbsim-new-apps.json"
187 fi
188
Andy Bavierdb003082020-02-04 11:57:36 -0700189 make -C $WORKSPACE/voltha/voltha-system-tests single-kind || true
Kailashaad71012019-08-27 10:36:53 -0700190 '''
191 }
192 }
193 }
194
195 post {
196 always {
197 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700198 set +e
Andy Bavier4af02722020-01-15 10:24:24 -0700199 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Andy Bavieraec60382019-10-29 15:09:04 -0700200 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
Kailashaad71012019-08-27 10:36:53 -0700201 kubectl get nodes -o wide
202 kubectl get pods -o wide
203 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700204
205 sync
206 pkill kail || true
207
208 ## Pull out errors from log files
209 extract_errors_go() {
210 echo
211 echo "Error summary for $1:"
212 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
213 echo
214 }
215
216 extract_errors_python() {
217 echo
218 echo "Error summary for $1:"
219 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
220 echo
221 }
222
223 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
224 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
225 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
226 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
227
Andy Bavier2178d102020-02-06 16:22:11 -0700228 gzip $WORKSPACE/onos-voltha-combined.log
229
Andy Bavier4af02722020-01-15 10:24:24 -0700230 ## shut down kind-voltha
231 cd $WORKSPACE/kind-voltha
232 WAIT_ON_DOWN=y ./voltha down
Kailashaad71012019-08-27 10:36:53 -0700233 '''
234 step([$class: 'RobotPublisher',
235 disableArchiveOutput: false,
236 logFileName: 'RobotLogs/log*.html',
237 otherFiles: '',
238 outputFileName: 'RobotLogs/output*.xml',
239 outputPath: '.',
240 passThreshold: 80,
241 reportFileName: 'RobotLogs/report*.html',
242 unstableThreshold: 0]);
Andy Bavier2178d102020-02-06 16:22:11 -0700243 archiveArtifacts artifacts: '*.log,*.gz'
Kailashaad71012019-08-27 10:36:53 -0700244
245 }
246 }
247}