blob: f752dbbb778022faeb4e2e26d884ec465ae33356 [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
Matteo Scandolofff6e062020-04-29 13:36:33 -0700201 }
202
203 post {
204 always {
205 sh '''
206 set +e
Andrea Campanella919361e2020-09-21 14:27:19 +0200207 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Matteo Scandolofff6e062020-04-29 13:36:33 -0700208 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
209 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
210 kubectl get nodes -o wide
211 kubectl get pods -o wide
212 kubectl get pods -n voltha -o wide
213
214 sync
215 pkill kail || true
Andrea Campanella919361e2020-09-21 14:27:19 +0200216 md5sum $WORKSPACE/kind-voltha/bin/voltctl
Matteo Scandolofff6e062020-04-29 13:36:33 -0700217
218 ## Pull out errors from log files
219 extract_errors_go() {
220 echo
221 echo "Error summary for $1:"
222 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
223 echo
224 }
225
226 extract_errors_python() {
227 echo
228 echo "Error summary for $1:"
229 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
230 echo
231 }
232
233 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
234 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
235 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
236 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
237
238 gzip $WORKSPACE/onos-voltha-combined.log
239
240
241 ## shut down kind-voltha
242 if [ "${branch}" != "master" ]; then
243 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Andrea Campanella919361e2020-09-21 14:27:19 +0200244 source "$WORKSPACE/kind-voltha/releases/${branch}"
Matteo Scandolofff6e062020-04-29 13:36:33 -0700245 else
246 echo "on master, using default settings for kind-voltha"
247 fi
248
Andrea Campanella919361e2020-09-21 14:27:19 +0200249 cd $WORKSPACE/kind-voltha
Matteo Scandolofff6e062020-04-29 13:36:33 -0700250 WAIT_ON_DOWN=y ./voltha down
251 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200252 step([$class: 'RobotPublisher',
253 disableArchiveOutput: false,
254 logFileName: 'RobotLogs/*/log*.html',
255 otherFiles: '',
256 outputFileName: 'RobotLogs/*/output*.xml',
257 outputPath: '.',
258 passThreshold: 100,
259 reportFileName: 'RobotLogs/*/report*.html',
260 unstableThreshold: 0]);
Matteo Scandolofff6e062020-04-29 13:36:33 -0700261 archiveArtifacts artifacts: '*.log,*.gz'
262 }
263 }
264}