blob: 6df0505282ca59e97a3503ec31a2df0b8fd3e928 [file] [log] [blame]
Andy Bavier61c5b2a2019-11-12 12:08:19 -07001// Copyright 2019-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// deploy VOLTHA built from patchset on a physical pod and run e2e test
16// uses kind-voltha to deploy voltha-2.X
17
18node {
19 // Need this so that deployment_config has global scope when it's read later
20 deployment_config = null
21 localDeploymentConfigFile = null
22 localKindVolthaValuesFile = null
23 localSadisConfigFile = null
24}
25
26pipeline {
27
28 /* no label, executor is determined by JJB */
29 agent {
30 label "${params.buildNode}"
31 }
32 options {
33 timeout(time: 60, unit: 'MINUTES')
34 }
35
36 environment {
37 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
38 VOLTCONFIG="$HOME/.volt/config-minimal"
39 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin"
40 TYPE="minimal"
41 FANCY=0
42 //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
43 ONOS_SSH_PORT=30115
44 ONOS_API_PORT=30120
45 }
46
47 stages {
48 stage ('Initialize') {
49 steps {
50 sh returnStdout: true, script: """
51 test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down
52 cd $WORKSPACE
53 rm -rf $WORKSPACE/*
54 """
55 script {
56 if (env.configRepo && ! env.localConfigDir) {
57 env.localConfigDir = "$WORKSPACE"
58 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configRepo}"
59 }
60 localDeploymentConfigFile = "${env.localConfigDir}/${params.deploymentConfigFile}"
61 localKindVolthaValuesFile = "${env.localConfigDir}/${params.kindVolthaValuesFile}"
62 localSadisConfigFile = "${env.localConfigDir}/${params.sadisConfigFile}"
63 if ( ! params.withPatchset ) {
64 sh returnStdout: false, script: """
65 mkdir -p voltha
66 cd voltha
67 git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests
68 """
69 }
70 try {
71 deployment_config = readYaml file: "${localDeploymentConfigFile}"
72 } catch (err) {
73 echo "Error reading ${localDeploymentConfigFile}"
74 throw err
75 }
76 sh returnStdout: false, script: """
77 if [ ! -e ${localKindVolthaValuesFile} ]; then echo "${localKindVolthaValuesFile} not found"; exit 1; fi
78 if [ ! -e ${localSadisConfigFile} ]; then echo "${localSadisConfigFile} not found"; exit 1; fi
79 """
80 }
81 }
82 }
83
84 stage('Get Patch') {
85 when {
86 expression { params.withPatchset }
87 }
88 steps {
89 checkout(changelog: false, \
90 poll: false,
91 scm: [$class: 'RepoScm', \
92 manifestRepositoryUrl: "${params.manifestUrl}", \
93 manifestBranch: "${params.manifestBranch}", \
94 currentBranch: true, \
95 destinationDir: 'voltha', \
96 forceSync: true,
97 resetFirst: true, \
98 quiet: true, \
99 jobs: 4, \
100 showAllChanges: true] \
101 )
102 sh returnStdout: false, script: """
103 cd voltha
104 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
105 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
106 """
107 }
108 }
109
110 stage('Create KinD Cluster') {
111 steps {
112 sh returnStdout: false, script: """
113 git clone https://github.com/ciena/kind-voltha.git
114 cd kind-voltha/
115 JUST_K8S=y ./voltha up
116 """
117 }
118 }
119
120 stage('Build and Push Images') {
121 when {
122 expression { params.withPatchset }
123 }
124 steps {
125 sh returnStdout: false, script: """
126 if ! [[ "${gerritProject}" =~ ^(voltha-system-tests)\$ ]]; then
127 make -C $WORKSPACE/voltha/${gerritProject} DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
128 docker images | grep citest
129 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}")
130 do
131 echo "Pushing \$image to nodes"
132 kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2
133 docker rmi \$image:citest \$image:latest || true
134 done
135 fi
136 """
137 }
138 }
139
140 stage('Deploy Voltha') {
141 environment {
142 WITH_SIM_ADAPTERS="n"
143 WITH_RADIUS="y"
144 DEPLOY_K8S="n"
145 VOLTHA_LOG_LEVEL="debug"
146 }
147 steps {
148 script {
149 if ( params.withPatchset ) {
150 sh returnStdout: false, script: """
151 export EXTRA_HELM_FLAGS='-f ${localKindVolthaValuesFile} '
152
153 IMAGES=""
154 if [ "${gerritProject}" = "voltha-go" ]; then
155 IMAGES="cli ofagent rw_core ro_core "
156 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
157 IMAGES="adapter_open_olt "
158 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
159 IMAGES="adapter_open_onu "
160 elif [ "${gerritProject}" = "voltha-api-server" ]; then
161 IMAGES="afrouter afrouterd "
162 else
163 echo "No images to push"
164 fi
165
166 for I in \$IMAGES
167 do
168 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
169 done
170
171 cd $WORKSPACE/kind-voltha/
172 echo \$EXTRA_HELM_FLAGS
173 ./voltha up
174 """
175 } else {
176 sh returnStdout: false, script: """
177 export EXTRA_HELM_FLAGS='-f ${localKindVolthaValuesFile} '
178 cd $WORKSPACE/kind-voltha/
179 echo \$EXTRA_HELM_FLAGS
180 ./voltha up
181 """
182 }
183 }
184 }
185 }
186
187 stage('Push Tech-Profile') {
188 when {
189 expression { params.profile != "Default" }
190 }
191 steps {
192 sh returnStdout: false, script: """
193 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
194 kubectl cp $WORKSPACE/voltha/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
195 kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/xgspon/64'
196 """
197 }
198 }
199
200 stage('Push Sadis-config') {
201 steps {
202 sh returnStdout: false, script: """
203 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:$ONOS_API_PORT/onos/v1/network/configuration --data @${localSadisConfigFile}
204 """
205 }
206 }
207
208 stage('Reinstall OLT software') {
209 when {
210 expression { params.reinstallOlt }
211 }
212 steps {
213 script {
214 deployment_config.olts.each { olt ->
215 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true"
216 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true"
217 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'"
218 waitUntil {
219 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
220 return olt_sw_present.toInteger() == 0
221 }
222 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'"
223 waitUntil {
224 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
225 return olt_sw_present.toInteger() == 1
226 }
227 if ( olt.fortygig ) {
228 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
229 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'echo port ce128 sp=40000 >> /broadcom/qax.soc ; /opt/bcm68620/svk_init.sh'"
230 }
231 }
232 }
233 }
234 }
235
236 stage('Restart OLT processes') {
237 steps {
238 script {
239 deployment_config.olts.each { olt ->
240 sh returnStdout: true, script: """
241 ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts
242 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true
243 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true
244 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/bal_core_dist.log /var/log/openolt.log'
245 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist start &'
246 sleep 5
247 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt start &'
248 """
249 waitUntil {
250 onu_discovered = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'grep \"onu discover indication\" /var/log/openolt.log | wc -l'"
251 return onu_discovered.toInteger() > 0
252 }
253 }
254 }
255 }
256 }
257
258 stage('Run E2E Tests') {
259 environment {
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700260 ROBOT_CONFIG_FILE="${localDeploymentConfigFile}"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700261 ROBOT_MISC_ARGS="--removekeywords wuks -d $WORKSPACE/RobotLogs"
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700262 ROBOT_FILE="Voltha_PODTests.robot"
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700263 }
264 steps {
265 sh returnStdout: false, script: """
266 cd voltha
267 git clone -b ${branch} ${cordRepoUrl}/cord-tester
268 git clone -b ${branch} ${cordRepoUrl}/voltha # VOL-2104 recommends we get rid of this
269 mkdir -p $WORKSPACE/RobotLogs
Andy Bavierbda4c6b2019-11-12 17:06:22 -0700270 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
Andy Bavier61c5b2a2019-11-12 12:08:19 -0700271 """
272 }
273 }
274 }
275
276 post {
277 always {
278 sh returnStdout: true, script: """
279 set +e
280 cp kind-voltha/install-minimal.log $WORKSPACE/
281 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
282 kubectl get nodes -o wide
283 kubectl get pods -o wide
284 kubectl get pods -n voltha -o wide
285 ## get default pod logs
286 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
287 do
288 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
289 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
290 else
291 kubectl logs \$pod> $WORKSPACE/\$pod.log;
292 fi
293 done
294 ## get voltha pod logs
295 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
296 do
297 if [[ \$pod == *"-api-"* ]]; then
298 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
299 elif [[ \$pod == "bbsim-"* ]]; then
300 kubectl logs \$pod -n voltha -p > $WORKSPACE/\$pod.log;
301 else
302 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
303 fi
304 done
305 """
306 step([$class: 'RobotPublisher',
307 disableArchiveOutput: false,
308 logFileName: 'RobotLogs/log*.html',
309 otherFiles: '',
310 outputFileName: 'RobotLogs/output*.xml',
311 outputPath: '.',
312 passThreshold: 80,
313 reportFileName: 'RobotLogs/report*.html',
314 unstableThreshold: 0]);
315 archiveArtifacts artifacts: '*.log'
316 }
317 }
318}