blob: 3238fcdf371b40d9260a0e6b87a5b405a22bcc3c [file] [log] [blame]
Suchitra Vemuri376859a2020-07-08 17:04:44 -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 {
Hardik Windlass6c22b202021-07-02 03:46:37 +000026 timeout(time: 210, unit: 'MINUTES')
Suchitra Vemuri376859a2020-07-08 17:04:44 -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 {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070036 stage('Clone kind-voltha') {
Suchitra Vemuri376859a2020-07-08 17:04:44 -070037 steps {
38 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070039 checkout([
40 $class: 'GitSCM',
41 userRemoteConfigs: [[
42 url: "https://gerrit.opencord.org/kind-voltha",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000043 refspec: "${kindVolthaChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070044 ]],
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",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000060 refspec: "${volthaSystemTestsChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070061 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000062 branches: [[ name: "${branch}", ]],
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070063 extensions: [
64 [$class: 'WipeWorkspace'],
65 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
66 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
67 ],
68 ])
Hardik Windlass81f67dc2021-03-05 16:15:42 +053069 script {
70 sh(script:"""
71 if [ '${volthaSystemTestsChange}' != '' ] ; then
72 cd $WORKSPACE/voltha-system-tests;
73 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
74 fi
75 """)
76 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070077 }
78 }
79 stage('Clone cord-tester') {
80 steps {
81 checkout([
82 $class: 'GitSCM',
83 userRemoteConfigs: [[
84 url: "https://gerrit.opencord.org/cord-tester",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000085 refspec: "${cordTesterChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070086 ]],
87 branches: [[ name: "master", ]],
88 extensions: [
89 [$class: 'WipeWorkspace'],
90 [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"],
91 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
92 ],
93 ])
94 }
95 }
96 // This checkout allows us to show changes in Jenkins
97 // we only do this on master as we don't branch all the repos for all the releases
98 // (we should compute the difference by tracking the container version, not the code)
99 stage('Download All the VOLTHA repos') {
100 when {
101 expression {
102 return "${branch}" == 'master';
103 }
104 }
105 steps {
106 checkout(changelog: true,
107 poll: false,
108 scm: [$class: 'RepoScm',
109 manifestRepositoryUrl: "${params.manifestUrl}",
110 manifestBranch: "${params.branch}",
111 currentBranch: true,
112 destinationDir: 'voltha',
113 forceSync: true,
114 resetFirst: true,
115 quiet: true,
116 jobs: 4,
117 showAllChanges: true]
118 )
119 }
120 }
121 stage ('Initialize') {
122 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +0000123 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700124 script {
125 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
126 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700127 sh returnStdout: false, script: """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700128 mkdir -p $WORKSPACE/bin
129 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
130 cd $WORKSPACE
Hardik Windlass6f854a12021-07-12 13:20:21 +0000131 if [ "${params.branch}" == "voltha-2.8" ]; then
132 VOLTCTL_VERSION=1.6.10
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700133 else
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700134 VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700135 fi
136
137 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
138 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
139 if [ \$HOSTARCH == "x86_64" ]; then
140 HOSTARCH="amd64"
141 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700142 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH}
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700143 chmod 755 $WORKSPACE/bin/voltctl
144 voltctl version --clientonly
145
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200146
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700147 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
148 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
149 # We should change this. In the meantime here is a workaround.
150 if [ "${params.branch}" == "master" ]; then
151 set +e
152
153
154 # Remove noise from voltha-core logs
155 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
156 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
157 # Remove noise from openolt logs
158 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
159 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
160 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
161 fi
162 """
163 }
164 }
165
166 stage('Functional Tests') {
167 environment {
168 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
169 ROBOT_FILE="Voltha_TT_PODTests.robot"
170 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
171 }
172 steps {
173 sh """
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700174 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700175 ./log-collector.sh > /dev/null &
176 ./log-combine.sh > /dev/null &
177
178 mkdir -p $ROBOT_LOGS_DIR
179 if ( ${powerSwitch} ); then
Hardik Windlass44461ee2021-05-26 07:19:53 +0000180 export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -i PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700181 else
Hardik Windlass44461ee2021-05-26 07:19:53 +0000182 export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -e PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700183 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700184 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700185 """
186 }
187 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530188
189 stage('Failure/Recovery Tests') {
190 environment {
191 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
192 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
193 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
194 }
195 steps {
196 sh """
197 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000198 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000199 if ( ${powerSwitch} ); then
200 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
201 else
202 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
203 fi
204 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530205 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530206 """
207 }
208 }
209
Hardik Windlass6a233e82021-05-27 04:08:50 +0000210 stage('Multi-Tcont Tests') {
211 environment {
212 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
213 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
214 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
215 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
216 }
217 steps {
218 sh """
219 mkdir -p $ROBOT_LOGS_DIR
220 if [ "${params.branch}" == "master" ]; then
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000221 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000222 if ( ${powerSwitch} ); then
Hardik Windlass6a233e82021-05-27 04:08:50 +0000223 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE"
Hardik Windlass6598b032021-07-02 10:12:01 +0000224 else
Hardik Windlass6a233e82021-05-27 04:08:50 +0000225 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE"
Hardik Windlass6598b032021-07-02 10:12:01 +0000226 fi
227 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
228 fi
Hardik Windlass6a233e82021-05-27 04:08:50 +0000229 fi
230 """
231 }
232 }
233
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700234 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700235 post {
236 always {
237 sh returnStdout: false, script: '''
238 set +e
239 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
240 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
241 kubectl get nodes -o wide
242 kubectl get pods -n voltha -o wide
Suchitra Vemuri179643b2020-11-02 10:06:20 -0800243 kubectl get pods -o wide
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700244
245 sleep 60 # Wait for log-collector and log-combine to complete
246
247 # Clean up "announcer" pod used by the tests if present
248 kubectl delete pod announcer || true
249
250 ## Pull out errors from log files
251 extract_errors_go() {
252 echo
253 echo "Error summary for $1:"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700254 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700255 echo
256 }
257
258 extract_errors_python() {
259 echo
260 echo "Error summary for $1:"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700261 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700262 echo
263 }
264
265 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
266 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
267 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
268 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
269 extract_errors_python onos >> $WORKSPACE/error-report.log
270
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200271 gzip error-report.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200272 rm error-report.log || true
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200273
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700274 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700275 tar czf $WORKSPACE/container-logs.tgz *
Andrea Campanellac9c80682020-09-30 12:02:01 +0200276 rm * || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700277
278 cd $WORKSPACE
279 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200280 rm *-combined.log || true
Andrea Campanellaa20a9332021-03-09 09:18:42 +0100281
282 # store information on running charts
283 helm ls > $WORKSPACE/helm-list.txt || true
284
285 # store information on the running pods
Andrea Campanellae0c839f2021-03-16 17:53:40 +0100286 kubectl get pods --all-namespaces -o wide > $WORKSPACE/pods.txt || true
Andrea Campanellaa20a9332021-03-09 09:18:42 +0100287 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $WORKSPACE/pod-images.txt || true
288 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee $WORKSPACE/pod-imagesId.txt || true
289
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700290 '''
291 script {
292 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100293 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
294 sh returnStdout: false, script: """
295 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
296 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
297 """
298 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700299 }
300 }
301 step([$class: 'RobotPublisher',
302 disableArchiveOutput: false,
303 logFileName: '**/log*.html',
304 otherFiles: '',
305 outputFileName: '**/output*.xml',
306 outputPath: 'RobotLogs',
307 passThreshold: 100,
308 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200309 unstableThreshold: 0,
310 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700311 ]);
312 archiveArtifacts artifacts: '*.log,*.gz,*.tgz'
313 }
314 unstable {
315 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
316 }
317 }
318}