blob: 2eb282e6748e8042ffb31b361afcb2950799b077 [file] [log] [blame]
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -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
15node {
16 // Need this so that deployment_config has global scope when it's read later
17 deployment_config = null
18}
19
20pipeline {
21 /* no label, executor is determined by JJB */
22 agent {
23 label "${params.buildNode}"
24 }
25 options {
Andrea Campanella56c8d782020-08-07 10:25:09 +020026 timeout(time: 240, unit: 'MINUTES')
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070027 }
28
29 environment {
30 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
31 VOLTCONFIG="$HOME/.volt/config-minimal"
32 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
33 }
34
35 stages {
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070036 stage('Clone kind-voltha') {
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070037 steps {
38 step([$class: 'WsCleanup'])
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070039 checkout([
40 $class: 'GitSCM',
41 userRemoteConfigs: [[
42 url: "https://gerrit.opencord.org/kind-voltha",
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070043 ]],
44 branches: [[ name: "master", ]],
45 extensions: [
46 [$class: 'WipeWorkspace'],
47 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
48 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
49 ],
50 ])
Matteo Scandolo01d596c2020-09-18 16:37:55 -070051 sh """
52 cd $WORKSPACE/kind-voltha
53 git fetch https://gerrit.opencord.org/kind-voltha ${gerritRefspec} && git checkout FETCH_HEAD
54 """
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070055 }
56 }
57 stage('Clone voltha-system-tests') {
58 steps {
59 checkout([
60 $class: 'GitSCM',
61 userRemoteConfigs: [[
62 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070063 ]],
64 branches: [[ name: "${branch}", ]],
65 extensions: [
66 [$class: 'WipeWorkspace'],
67 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
68 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
69 ],
70 ])
Matteo Scandolo01d596c2020-09-18 16:37:55 -070071 sh """
72 cd $WORKSPACE/voltha-system-tests
73 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
74 """
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070075 }
76 }
77 stage('Clone cord-tester') {
78 steps {
79 checkout([
80 $class: 'GitSCM',
81 userRemoteConfigs: [[
82 url: "https://gerrit.opencord.org/cord-tester",
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070083 ]],
84 branches: [[ name: "master", ]],
85 extensions: [
86 [$class: 'WipeWorkspace'],
87 [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"],
88 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
89 ],
90 ])
Matteo Scandolo01d596c2020-09-18 16:37:55 -070091 sh """
92 cd $WORKSPACE/cord-tester
93 git fetch https://gerrit.opencord.org/voltha-system-tests ${cordTesterChange} && git checkout FETCH_HEAD
94 """
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070095 }
96 }
Matteo Scandolo92a5cb62020-09-15 16:02:08 -070097 // This checkout allows us to show changes in Jenkins
98 // we only do this on master as we don't branch all the repos for all the releases
99 // (we should compute the difference by tracking the container version, not the code)
100 stage('Download All the VOLTHA repos') {
101 when {
102 expression {
103 return "${branch}" == 'master';
104 }
105 }
106 steps {
107 checkout(changelog: true,
108 poll: false,
109 scm: [$class: 'RepoScm',
110 manifestRepositoryUrl: "${params.manifestUrl}",
111 manifestBranch: "${params.branch}",
112 currentBranch: true,
113 destinationDir: 'voltha',
114 forceSync: true,
115 resetFirst: true,
116 quiet: true,
117 jobs: 4,
118 showAllChanges: true]
119 )
120 }
121 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700122 stage ('Initialize') {
123 steps {
Suchitra Vemuri2a5a5ea2020-03-27 22:53:11 -0700124 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700125 script {
126 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
127 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700128 sh returnStdout: false, script: """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700129 mkdir -p $WORKSPACE/bin
130 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
131 cd $WORKSPACE
Suchitra Vemuri13421432020-06-05 17:34:33 -0700132 if [ "${params.branch}" != "master" ]; then
133 cd $WORKSPACE/kind-voltha
134 source releases/${params.branch}
Suchitra Vemuri13421432020-06-05 17:34:33 -0700135 else
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700136 VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
Suchitra Vemuri13421432020-06-05 17:34:33 -0700137 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700138
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700139 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
140 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
141 if [ \$HOSTARCH == "x86_64" ]; then
142 HOSTARCH="amd64"
143 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700144 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH}
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700145 chmod 755 $WORKSPACE/bin/voltctl
146 voltctl version --clientonly
Andrea Campanella9b234332020-04-24 12:22:18 +0200147
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700148
Andrea Campanella9b234332020-04-24 12:22:18 +0200149 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
150 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
151 # We should change this. In the meantime here is a workaround.
Suchitra Vemuri13421432020-06-05 17:34:33 -0700152 if [ "${params.branch}" == "master" ]; then
153 set +e
Andrea Campanella9b234332020-04-24 12:22:18 +0200154
Andrea Campanella9b234332020-04-24 12:22:18 +0200155
156 # Remove noise from voltha-core logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700157 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
158 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Andrea Campanella9b234332020-04-24 12:22:18 +0200159 # Remove noise from openolt logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700160 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
161 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
162 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Suchitra Vemuri13421432020-06-05 17:34:33 -0700163 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700164 """
165 }
166 }
167
168 stage('Functional Tests') {
169 environment {
Suchitra Vemurie4a5bcc2020-03-16 12:43:03 -0700170 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700171 ROBOT_FILE="Voltha_DT_PODTests.robot"
Andrea Campanellad924ce22020-04-20 16:40:41 +0200172 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700173 }
174 steps {
175 sh """
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700176 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700177 ./log-collector.sh > /dev/null &
178 ./log-combine.sh > /dev/null &
179
180 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700181 if ( ${powerSwitch} ); then
182 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanityDt -i functionalDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
183 else
184 export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanityDt -i functionalDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
185 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700186 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700187 """
188 }
189 }
Andrea Campanellad924ce22020-04-20 16:40:41 +0200190
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200191 stage('Failure/Recovery Tests') {
192 environment {
193 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
194 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
195 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
196 }
197 steps {
198 sh """
199 mkdir -p $ROBOT_LOGS_DIR
200 if ( ${powerSwitch} ); then
201 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalDt -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
202 else
203 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalDt -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
204 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700205 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200206 """
207 }
208 }
209
Andy Bavier5ad87c92020-05-11 16:31:35 -0700210 stage('Dataplane Tests') {
211 environment {
Andy Bavier1541da82020-05-15 09:41:38 -0700212 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Andy Bavier5ad87c92020-05-11 16:31:35 -0700213 ROBOT_FILE="Voltha_DT_PODTests.robot"
214 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
215 }
216 steps {
217 sh """
218 mkdir -p $ROBOT_LOGS_DIR
Andy Bavier2dac06b2020-05-27 16:58:32 -0700219 export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700220 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andy Bavier5ad87c92020-05-11 16:31:35 -0700221 """
222 }
223 }
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700224 stage('HA Tests') {
225 environment {
226 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
227 ROBOT_FILE="Voltha_ONOSHATests.robot"
228 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
229 }
230 steps {
231 sh """
232 mkdir -p $ROBOT_LOGS_DIR
233 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700234 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700235 """
236 }
237 }
Andy Bavier5ad87c92020-05-11 16:31:35 -0700238
Andrea Campanellad924ce22020-04-20 16:40:41 +0200239 stage('Error Scenario Tests') {
240 environment {
241 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
242 ROBOT_FILE="Voltha_ErrorScenarios.robot"
243 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
244 }
245 steps {
246 sh """
247 mkdir -p $ROBOT_LOGS_DIR
248 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700249 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Andrea Campanellad924ce22020-04-20 16:40:41 +0200250 """
251 }
Andrea Campanella71666372020-04-21 10:56:17 +0200252 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700253 }
254 post {
255 always {
256 sh returnStdout: false, script: '''
257 set +e
Matteo Scandolo97b12572020-04-13 12:44:46 -0700258 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
259 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700260 kubectl get nodes -o wide
261 kubectl get pods -n voltha -o wide
262
263 sleep 60 # Wait for log-collector and log-combine to complete
264
265 # Clean up "announcer" pod used by the tests if present
266 kubectl delete pod announcer || true
267
268 ## Pull out errors from log files
269 extract_errors_go() {
270 echo
271 echo "Error summary for $1:"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700272 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700273 echo
274 }
275
276 extract_errors_python() {
277 echo
278 echo "Error summary for $1:"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700279 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700280 echo
281 }
282
283 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
284 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
285 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
286 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
287 extract_errors_python onos >> $WORKSPACE/error-report.log
288
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200289 gzip error-report.log || true
290
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700291 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700292 tar czf $WORKSPACE/container-logs.tgz *
293
294 cd $WORKSPACE
295 gzip *-combined.log || true
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700296
297 # collect ETCD cluster logs
298 mkdir -p $WORKSPACE/etcd
299 printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I@ bash -c "kubectl logs @ > $WORKSPACE/etcd/@.log"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700300 '''
301 script {
302 deployment_config.olts.each { olt ->
303 sh returnStdout: false, script: """
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700304 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
Suchitra Vemuria0695662020-07-17 09:41:49 -0700305 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700306 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
Suchitra Vemuri8228c162020-07-19 13:55:11 -0700307 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700308 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/startup.log $WORKSPACE/startup-${olt.sship}.log || true
Matteo Scandolo43fe7802020-07-22 09:17:38 -0700309 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
Girish Gowdra201b7e42020-07-28 15:58:07 -0700310 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt_process_watchdog.log $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true
311 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700312 """
313 }
314 }
315 step([$class: 'RobotPublisher',
316 disableArchiveOutput: false,
317 logFileName: '**/log*.html',
318 otherFiles: '',
319 outputFileName: '**/output*.xml',
320 outputPath: 'RobotLogs',
321 passThreshold: 100,
322 reportFileName: '**/report*.html',
323 unstableThreshold: 0
324 ]);
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700325 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700326 }
327 unstable {
328 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
329 }
330 }
331}