blob: 2a0902fdad17020653bb7960cee9c049f397cea8 [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 {
Hardik Windlass6f854a12021-07-12 13:20:21 +0000124 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemurief0a6e92021-02-23 21:14:07 -0800125 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
Hardik Windlass6f854a12021-07-12 13:20:21 +0000132 if [ "${params.branch}" == "voltha-2.8" ]; then
133 VC_VERSION=1.6.10
Suchitra Vemurif4461652020-09-03 21:47:19 -0700134 else
135 VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
136 fi
137
138 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
139 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
140 if [ \$HOSTARCH == "x86_64" ]; then
141 HOSTARCH="amd64"
142 fi
143 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH}
144 chmod 755 $WORKSPACE/bin/voltctl
145 voltctl version --clientonly
146
147 if [ "${params.branch}" == "master" ]; then
148 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
149 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
150 # We should change this. In the meantime here is a workaround.
151 set +e
152
153 # Remove noise from voltha-core logs
154 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
155 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
156 # Remove noise from openolt logs
157 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
158 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
159 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
160 fi
161 """
162 }
163 }
164
165 stage('Functional Tests') {
166 environment {
167 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700168 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700169 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700170 }
171 steps {
172 sh """
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800173 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemurif4461652020-09-03 21:47:19 -0700174 ./log-collector.sh > /dev/null &
175 ./log-combine.sh > /dev/null &
176
177 mkdir -p $ROBOT_LOGS_DIR
178 if [ "${params.testType}" == "Functional" ]; then
179 if ( ${powerSwitch} ); then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000180 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 -0700181 else
Hardik Windlassc6eae662021-05-19 11:58:23 +0000182 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 -0700183 fi
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800184 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700185 fi
186 """
187 }
188 }
189
190 stage('Failure/Recovery Tests') {
191 environment {
192 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700193 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700194 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700195 }
196 steps {
197 sh """
198 mkdir -p $ROBOT_LOGS_DIR
199 if [ "${params.testType}" == "Failure" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000200 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 -0800201 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700202 fi
203 """
204 }
205 }
206
207 stage('Dataplane Tests') {
208 environment {
209 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700210 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700211 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700212 }
213 steps {
214 sh """
215 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri60603032020-09-10 17:13:37 -0700216 if [ "${params.testType}" == "Dataplane" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000217 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 -0800218 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700219 fi
220 """
221 }
222 }
223
224 }
225 post {
226 always {
227 sh returnStdout: false, script: '''
228 set +e
229 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
230 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
231 kubectl get nodes -o wide
232 kubectl get pods -n voltha -o wide
233
234 sleep 60 # Wait for log-collector and log-combine to complete
235
236 # Clean up "announcer" pod used by the tests if present
237 kubectl delete pod announcer || true
238
239 ## Pull out errors from log files
240 extract_errors_go() {
241 echo
242 echo "Error summary for $1:"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800243 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemurif4461652020-09-03 21:47:19 -0700244 echo
245 }
246
247 extract_errors_python() {
248 echo
249 echo "Error summary for $1:"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800250 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemurif4461652020-09-03 21:47:19 -0700251 echo
252 }
253
254 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
255 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
256 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
257 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
258 extract_errors_python onos >> $WORKSPACE/error-report.log
259
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800260 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemurif4461652020-09-03 21:47:19 -0700261 tar czf $WORKSPACE/container-logs.tgz *
262
263 cd $WORKSPACE
264 gzip *-combined.log || true
265
266 # collect ETCD cluster logs
267 mkdir -p $WORKSPACE/etcd
Girish Gowdra3eb96f62020-10-15 12:48:34 -0700268 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 -0700269 '''
270 script {
271 deployment_config.olts.each { olt ->
272 sh returnStdout: false, script: """
273 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
274 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
275 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
276 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${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/startup.log $WORKSPACE/startup-${olt.sship}.log || true
278 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
279 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
280 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
281 """
282 }
283 }
284 step([$class: 'RobotPublisher',
285 disableArchiveOutput: false,
286 logFileName: '**/log*.html',
287 otherFiles: '',
288 outputFileName: '**/output*.xml',
289 outputPath: 'RobotLogs',
290 passThreshold: 100,
291 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200292 unstableThreshold: 0,
293 onlyCritical: true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700294 ]);
295 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
296 }
Suchitra Vemurif4461652020-09-03 21:47:19 -0700297 }
298}