blob: 0b73874f43713c84d92df9b1a53fa130a1f01618 [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",
43 refspec: "${kindVolthaChange}"
44 ]],
45 branches: [[ name: "master", ]],
46 extensions: [
47 [$class: 'WipeWorkspace'],
48 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
49 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
50 ],
51 ])
52 }
53 }
54 stage('Clone voltha-system-tests') {
55 steps {
56 checkout([
57 $class: 'GitSCM',
58 userRemoteConfigs: [[
59 url: "https://gerrit.opencord.org/voltha-system-tests",
60 refspec: "${volthaSystemTestsChange}"
61 ]],
62 branches: [[ name: "${branch}", ]],
63 extensions: [
64 [$class: 'WipeWorkspace'],
65 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
66 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
67 ],
68 ])
69 }
70 }
71 stage('Clone cord-tester') {
72 steps {
73 checkout([
74 $class: 'GitSCM',
75 userRemoteConfigs: [[
76 url: "https://gerrit.opencord.org/cord-tester",
77 refspec: "${cordTesterChange}"
78 ]],
79 branches: [[ name: "master", ]],
80 extensions: [
81 [$class: 'WipeWorkspace'],
82 [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"],
83 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
84 ],
85 ])
86 }
87 }
Matteo Scandolo92a5cb62020-09-15 16:02:08 -070088 // This checkout allows us to show changes in Jenkins
89 // we only do this on master as we don't branch all the repos for all the releases
90 // (we should compute the difference by tracking the container version, not the code)
91 stage('Download All the VOLTHA repos') {
92 when {
93 expression {
94 return "${branch}" == 'master';
95 }
96 }
97 steps {
98 checkout(changelog: true,
99 poll: false,
100 scm: [$class: 'RepoScm',
101 manifestRepositoryUrl: "${params.manifestUrl}",
102 manifestBranch: "${params.branch}",
103 currentBranch: true,
104 destinationDir: 'voltha',
105 forceSync: true,
106 resetFirst: true,
107 quiet: true,
108 jobs: 4,
109 showAllChanges: true]
110 )
111 }
112 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700113 stage ('Initialize') {
114 steps {
Suchitra Vemuri2a5a5ea2020-03-27 22:53:11 -0700115 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700116 script {
117 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
118 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700119 sh returnStdout: false, script: """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700120 mkdir -p $WORKSPACE/bin
121 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
122 cd $WORKSPACE
Suchitra Vemuri13421432020-06-05 17:34:33 -0700123 if [ "${params.branch}" != "master" ]; then
124 cd $WORKSPACE/kind-voltha
125 source releases/${params.branch}
Suchitra Vemuri13421432020-06-05 17:34:33 -0700126 else
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700127 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 -0700128 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700129
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700130 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
131 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
132 if [ \$HOSTARCH == "x86_64" ]; then
133 HOSTARCH="amd64"
134 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700135 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 -0700136 chmod 755 $WORKSPACE/bin/voltctl
137 voltctl version --clientonly
Andrea Campanella9b234332020-04-24 12:22:18 +0200138
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700139
Andrea Campanella9b234332020-04-24 12:22:18 +0200140 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
141 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
142 # We should change this. In the meantime here is a workaround.
Suchitra Vemuri13421432020-06-05 17:34:33 -0700143 if [ "${params.branch}" == "master" ]; then
144 set +e
Andrea Campanella9b234332020-04-24 12:22:18 +0200145
Andrea Campanella9b234332020-04-24 12:22:18 +0200146
147 # Remove noise from voltha-core logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700148 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
149 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Andrea Campanella9b234332020-04-24 12:22:18 +0200150 # Remove noise from openolt logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700151 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
152 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
153 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Suchitra Vemuri13421432020-06-05 17:34:33 -0700154 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700155 """
156 }
157 }
158
159 stage('Functional Tests') {
160 environment {
Suchitra Vemurie4a5bcc2020-03-16 12:43:03 -0700161 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700162 ROBOT_FILE="Voltha_DT_PODTests.robot"
Andrea Campanellad924ce22020-04-20 16:40:41 +0200163 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700164 }
165 steps {
166 sh """
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700167 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700168 ./log-collector.sh > /dev/null &
169 ./log-combine.sh > /dev/null &
170
171 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700172 if ( ${powerSwitch} ); then
173 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"
174 else
175 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"
176 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700177 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700178 """
179 }
180 }
Andrea Campanellad924ce22020-04-20 16:40:41 +0200181
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200182 stage('Failure/Recovery Tests') {
183 environment {
184 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
185 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
186 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
187 }
188 steps {
189 sh """
190 mkdir -p $ROBOT_LOGS_DIR
191 if ( ${powerSwitch} ); then
192 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"
193 else
194 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"
195 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700196 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200197 """
198 }
199 }
200
Andy Bavier5ad87c92020-05-11 16:31:35 -0700201 stage('Dataplane Tests') {
202 environment {
Andy Bavier1541da82020-05-15 09:41:38 -0700203 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Andy Bavier5ad87c92020-05-11 16:31:35 -0700204 ROBOT_FILE="Voltha_DT_PODTests.robot"
205 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
206 }
207 steps {
208 sh """
209 mkdir -p $ROBOT_LOGS_DIR
Andy Bavier2dac06b2020-05-27 16:58:32 -0700210 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 -0700211 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andy Bavier5ad87c92020-05-11 16:31:35 -0700212 """
213 }
214 }
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700215 stage('HA Tests') {
216 environment {
217 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
218 ROBOT_FILE="Voltha_ONOSHATests.robot"
219 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
220 }
221 steps {
222 sh """
223 mkdir -p $ROBOT_LOGS_DIR
224 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 -0700225 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700226 """
227 }
228 }
Andy Bavier5ad87c92020-05-11 16:31:35 -0700229
Andrea Campanellad924ce22020-04-20 16:40:41 +0200230 stage('Error Scenario Tests') {
231 environment {
232 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
233 ROBOT_FILE="Voltha_ErrorScenarios.robot"
234 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
235 }
236 steps {
237 sh """
238 mkdir -p $ROBOT_LOGS_DIR
239 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 -0700240 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Andrea Campanellad924ce22020-04-20 16:40:41 +0200241 """
242 }
Andrea Campanella71666372020-04-21 10:56:17 +0200243 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700244 }
245 post {
246 always {
247 sh returnStdout: false, script: '''
248 set +e
Matteo Scandolo97b12572020-04-13 12:44:46 -0700249 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
250 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700251 kubectl get nodes -o wide
252 kubectl get pods -n voltha -o wide
253
254 sleep 60 # Wait for log-collector and log-combine to complete
255
256 # Clean up "announcer" pod used by the tests if present
257 kubectl delete pod announcer || true
258
259 ## Pull out errors from log files
260 extract_errors_go() {
261 echo
262 echo "Error summary for $1:"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700263 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700264 echo
265 }
266
267 extract_errors_python() {
268 echo
269 echo "Error summary for $1:"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700270 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700271 echo
272 }
273
274 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
275 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
276 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
277 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
278 extract_errors_python onos >> $WORKSPACE/error-report.log
279
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200280 gzip error-report.log || true
281
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700282 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700283 tar czf $WORKSPACE/container-logs.tgz *
284
285 cd $WORKSPACE
286 gzip *-combined.log || true
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700287
288 # collect ETCD cluster logs
289 mkdir -p $WORKSPACE/etcd
290 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 -0700291 '''
292 script {
293 deployment_config.olts.each { olt ->
294 sh returnStdout: false, script: """
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700295 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 -0700296 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 -0700297 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 -0700298 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 -0700299 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 -0700300 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 -0700301 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
302 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 -0700303 """
304 }
305 }
306 step([$class: 'RobotPublisher',
307 disableArchiveOutput: false,
308 logFileName: '**/log*.html',
309 otherFiles: '',
310 outputFileName: '**/output*.xml',
311 outputPath: 'RobotLogs',
312 passThreshold: 100,
313 reportFileName: '**/report*.html',
314 unstableThreshold: 0
315 ]);
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700316 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700317 }
318 unstable {
319 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
320 }
321 }
322}