blob: e31f1fda6cc2ebc6a69c24b1cec1c9c5f5a60888 [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 }
88 stage ('Initialize') {
89 steps {
Suchitra Vemuri2a5a5ea2020-03-27 22:53:11 -070090 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070091 script {
92 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
93 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070094 sh returnStdout: false, script: """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070095 mkdir -p $WORKSPACE/bin
96 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
97 cd $WORKSPACE
Suchitra Vemuri13421432020-06-05 17:34:33 -070098 if [ "${params.branch}" != "master" ]; then
99 cd $WORKSPACE/kind-voltha
100 source releases/${params.branch}
Suchitra Vemuri13421432020-06-05 17:34:33 -0700101 else
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700102 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 -0700103 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700104
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700105 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
106 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
107 if [ \$HOSTARCH == "x86_64" ]; then
108 HOSTARCH="amd64"
109 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700110 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 -0700111 chmod 755 $WORKSPACE/bin/voltctl
112 voltctl version --clientonly
Andrea Campanella9b234332020-04-24 12:22:18 +0200113
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700114
Andrea Campanella9b234332020-04-24 12:22:18 +0200115 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
116 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
117 # We should change this. In the meantime here is a workaround.
Suchitra Vemuri13421432020-06-05 17:34:33 -0700118 if [ "${params.branch}" == "master" ]; then
119 set +e
Andrea Campanella9b234332020-04-24 12:22:18 +0200120
Andrea Campanella9b234332020-04-24 12:22:18 +0200121
122 # Remove noise from voltha-core logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700123 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
124 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Andrea Campanella9b234332020-04-24 12:22:18 +0200125 # Remove noise from openolt logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700126 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
127 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
128 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Suchitra Vemuri13421432020-06-05 17:34:33 -0700129 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700130 """
131 }
132 }
133
134 stage('Functional Tests') {
135 environment {
Suchitra Vemurie4a5bcc2020-03-16 12:43:03 -0700136 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700137 ROBOT_FILE="Voltha_DT_PODTests.robot"
Andrea Campanellad924ce22020-04-20 16:40:41 +0200138 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700139 }
140 steps {
141 sh """
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700142 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700143 ./log-collector.sh > /dev/null &
144 ./log-combine.sh > /dev/null &
145
146 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700147 if ( ${powerSwitch} ); then
148 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"
149 else
150 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"
151 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700152 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700153 """
154 }
155 }
Andrea Campanellad924ce22020-04-20 16:40:41 +0200156
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200157 stage('Failure/Recovery Tests') {
158 environment {
159 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
160 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
161 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
162 }
163 steps {
164 sh """
165 mkdir -p $ROBOT_LOGS_DIR
166 if ( ${powerSwitch} ); then
167 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"
168 else
169 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"
170 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700171 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200172 """
173 }
174 }
175
Andy Bavier5ad87c92020-05-11 16:31:35 -0700176 stage('Dataplane Tests') {
177 environment {
Andy Bavier1541da82020-05-15 09:41:38 -0700178 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Andy Bavier5ad87c92020-05-11 16:31:35 -0700179 ROBOT_FILE="Voltha_DT_PODTests.robot"
180 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
181 }
182 steps {
183 sh """
184 mkdir -p $ROBOT_LOGS_DIR
Andy Bavier2dac06b2020-05-27 16:58:32 -0700185 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 -0700186 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andy Bavier5ad87c92020-05-11 16:31:35 -0700187 """
188 }
189 }
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700190 stage('HA Tests') {
191 environment {
192 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
193 ROBOT_FILE="Voltha_ONOSHATests.robot"
194 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
195 }
196 steps {
197 sh """
198 mkdir -p $ROBOT_LOGS_DIR
199 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 -0700200 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700201 """
202 }
203 }
Andy Bavier5ad87c92020-05-11 16:31:35 -0700204
Andrea Campanellad924ce22020-04-20 16:40:41 +0200205 stage('Error Scenario Tests') {
206 environment {
207 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
208 ROBOT_FILE="Voltha_ErrorScenarios.robot"
209 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
210 }
211 steps {
212 sh """
213 mkdir -p $ROBOT_LOGS_DIR
214 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 -0700215 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Andrea Campanellad924ce22020-04-20 16:40:41 +0200216 """
217 }
Andrea Campanella71666372020-04-21 10:56:17 +0200218 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700219 }
220 post {
221 always {
222 sh returnStdout: false, script: '''
223 set +e
Matteo Scandolo97b12572020-04-13 12:44:46 -0700224 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
225 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700226 kubectl get nodes -o wide
227 kubectl get pods -n voltha -o wide
228
229 sleep 60 # Wait for log-collector and log-combine to complete
230
231 # Clean up "announcer" pod used by the tests if present
232 kubectl delete pod announcer || true
233
234 ## Pull out errors from log files
235 extract_errors_go() {
236 echo
237 echo "Error summary for $1:"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700238 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700239 echo
240 }
241
242 extract_errors_python() {
243 echo
244 echo "Error summary for $1:"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700245 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700246 echo
247 }
248
249 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
250 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
251 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
252 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
253 extract_errors_python onos >> $WORKSPACE/error-report.log
254
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200255 gzip error-report.log || true
256
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700257 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700258 tar czf $WORKSPACE/container-logs.tgz *
259
260 cd $WORKSPACE
261 gzip *-combined.log || true
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700262
263 # collect ETCD cluster logs
264 mkdir -p $WORKSPACE/etcd
265 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 -0700266 '''
267 script {
268 deployment_config.olts.each { olt ->
269 sh returnStdout: false, script: """
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700270 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 -0700271 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 -0700272 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 -0700273 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 -0700274 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 -0700275 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 -0700276 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
277 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 -0700278 """
279 }
280 }
281 step([$class: 'RobotPublisher',
282 disableArchiveOutput: false,
283 logFileName: '**/log*.html',
284 otherFiles: '',
285 outputFileName: '**/output*.xml',
286 outputPath: 'RobotLogs',
287 passThreshold: 100,
288 reportFileName: '**/report*.html',
289 unstableThreshold: 0
290 ]);
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700291 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700292 }
293 unstable {
294 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
295 }
296 }
297}