blob: bc23869b2a81f4540948a5a4db1ca2cc3ba4241b [file] [log] [blame]
Suchitra Vemurif4461652020-09-03 21:47:19 -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 {
26 timeout(time: 280, unit: 'MINUTES')
27 }
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
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080035
Suchitra Vemurif4461652020-09-03 21:47:19 -070036 stages {
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080037 stage('Clone kind-voltha') {
Suchitra Vemurif4461652020-09-03 21:47:19 -070038 steps {
39 step([$class: 'WsCleanup'])
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080040 checkout([
41 $class: 'GitSCM',
42 userRemoteConfigs: [[
43 url: "https://gerrit.opencord.org/kind-voltha",
44 refspec: "${kindVolthaChange}"
45 ]],
46 branches: [[ name: "master", ]],
47 extensions: [
48 [$class: 'WipeWorkspace'],
49 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
50 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
51 ],
52 ])
53 }
54 }
55 stage('Clone voltha-system-tests') {
56 steps {
57 checkout([
58 $class: 'GitSCM',
59 userRemoteConfigs: [[
60 url: "https://gerrit.opencord.org/voltha-system-tests",
61 refspec: "${volthaSystemTestsChange}"
62 ]],
63 branches: [[ name: "${branch}", ]],
64 extensions: [
65 [$class: 'WipeWorkspace'],
66 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
67 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
68 ],
69 ])
Suchitra Vemurif4461652020-09-03 21:47:19 -070070 script {
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080071 sh(script:"""
72 if [ '${volthaSystemTestsChange}' != '' ] ; then
73 cd $WORKSPACE/voltha-system-tests;
74 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
75 fi
76 """)
Suchitra Vemurif4461652020-09-03 21:47:19 -070077 }
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080078 }
79 }
80 stage('Clone cord-tester') {
81 steps {
82 checkout([
83 $class: 'GitSCM',
84 userRemoteConfigs: [[
85 url: "https://gerrit.opencord.org/cord-tester",
86 refspec: "${cordTesterChange}"
87 ]],
88 branches: [[ name: "master", ]],
89 extensions: [
90 [$class: 'WipeWorkspace'],
91 [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"],
92 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
93 ],
94 ])
95 }
96 }
97 // 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 }
122 stage ('Initialize') {
123 steps {
124 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
125 script {
126 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
127 }
Suchitra Vemurif4461652020-09-03 21:47:19 -0700128 sh returnStdout: false, script: """
Suchitra Vemurif4461652020-09-03 21:47:19 -0700129 mkdir -p $WORKSPACE/bin
130 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
131 cd $WORKSPACE
132 if [ "${params.branch}" != "master" ]; then
133 cd $WORKSPACE/kind-voltha
134 source releases/${params.branch}
135 VC_VERSION=1.1.8
136 else
137 VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
138 fi
139
140 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
141 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
142 if [ \$HOSTARCH == "x86_64" ]; then
143 HOSTARCH="amd64"
144 fi
145 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH}
146 chmod 755 $WORKSPACE/bin/voltctl
147 voltctl version --clientonly
148
149 if [ "${params.branch}" == "master" ]; then
150 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
151 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
152 # We should change this. In the meantime here is a workaround.
153 set +e
154
155 # Remove noise from voltha-core logs
156 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
157 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
158 # Remove noise from openolt logs
159 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
160 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
161 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
162 fi
163 """
164 }
165 }
166
167 stage('Functional Tests') {
168 environment {
169 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700170 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700171 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700172 }
173 steps {
174 sh """
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800175 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemurif4461652020-09-03 21:47:19 -0700176 ./log-collector.sh > /dev/null &
177 ./log-combine.sh > /dev/null &
178
179 mkdir -p $ROBOT_LOGS_DIR
180 if [ "${params.testType}" == "Functional" ]; then
181 if ( ${powerSwitch} ); then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000182 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700183 else
Hardik Windlassc6eae662021-05-19 11:58:23 +0000184 export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700185 fi
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800186 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700187 fi
188 """
189 }
190 }
191
192 stage('Failure/Recovery Tests') {
193 environment {
194 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700195 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700196 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700197 }
198 steps {
199 sh """
200 mkdir -p $ROBOT_LOGS_DIR
201 if [ "${params.testType}" == "Failure" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000202 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i soak -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800203 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700204 fi
205 """
206 }
207 }
208
209 stage('Dataplane Tests') {
210 environment {
211 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700212 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700213 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700214 }
215 steps {
216 sh """
217 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri60603032020-09-10 17:13:37 -0700218 if [ "${params.testType}" == "Dataplane" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000219 export ROBOT_MISC_ARGS="--removekeywords wuks -i soakDataplane -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800220 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700221 fi
222 """
223 }
224 }
225
226 }
227 post {
228 always {
229 sh returnStdout: false, script: '''
230 set +e
231 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
232 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
233 kubectl get nodes -o wide
234 kubectl get pods -n voltha -o wide
235
236 sleep 60 # Wait for log-collector and log-combine to complete
237
238 # Clean up "announcer" pod used by the tests if present
239 kubectl delete pod announcer || true
240
241 ## Pull out errors from log files
242 extract_errors_go() {
243 echo
244 echo "Error summary for $1:"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800245 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemurif4461652020-09-03 21:47:19 -0700246 echo
247 }
248
249 extract_errors_python() {
250 echo
251 echo "Error summary for $1:"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800252 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemurif4461652020-09-03 21:47:19 -0700253 echo
254 }
255
256 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
257 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
258 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
259 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
260 extract_errors_python onos >> $WORKSPACE/error-report.log
261
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800262 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemurif4461652020-09-03 21:47:19 -0700263 tar czf $WORKSPACE/container-logs.tgz *
264
265 cd $WORKSPACE
266 gzip *-combined.log || true
267
268 # collect ETCD cluster logs
269 mkdir -p $WORKSPACE/etcd
Girish Gowdra3eb96f62020-10-15 12:48:34 -0700270 printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I% bash -c "kubectl logs % > $WORKSPACE/etcd/%.log"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700271 '''
272 script {
273 deployment_config.olts.each { olt ->
274 sh returnStdout: false, script: """
275 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
276 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
277 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
278 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
279 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
280 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
281 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
282 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
283 """
284 }
285 }
286 step([$class: 'RobotPublisher',
287 disableArchiveOutput: false,
288 logFileName: '**/log*.html',
289 otherFiles: '',
290 outputFileName: '**/output*.xml',
291 outputPath: 'RobotLogs',
292 passThreshold: 100,
293 reportFileName: '**/report*.html',
294 unstableThreshold: 0
295 ]);
296 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
297 }
298 unstable {
299 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
300 }
301 }
302}