blob: 040c0657cff899dcf018f363b649e1feb9dbf3e1 [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
Matteo Scandolo0d0f2902021-07-15 16:16:33 -070015library identifier: 'cord-jenkins-libraries@master',
16 retriever: modernSCM([
17 $class: 'GitSCMSource',
18 remote: 'https://gerrit.opencord.org/ci-management.git'
19])
20
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070021node {
22 // Need this so that deployment_config has global scope when it's read later
23 deployment_config = null
24}
25
26pipeline {
27 /* no label, executor is determined by JJB */
28 agent {
29 label "${params.buildNode}"
30 }
31 options {
Suchitra Vemuri6ec07572021-02-22 10:47:05 -080032 timeout(time: 640, unit: 'MINUTES')
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070033 }
34
35 environment {
36 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
37 VOLTCONFIG="$HOME/.volt/config-minimal"
38 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
39 }
40
41 stages {
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070042 stage('Clone voltha-system-tests') {
43 steps {
Matteo Scandolo67842812021-07-13 16:52:13 -070044 step([$class: 'WsCleanup'])
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070045 checkout([
46 $class: 'GitSCM',
47 userRemoteConfigs: [[
48 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000049 refspec: "${volthaSystemTestsChange}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070050 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000051 branches: [[ name: "${branch}", ]],
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070052 extensions: [
53 [$class: 'WipeWorkspace'],
54 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
55 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
56 ],
57 ])
Suchitra Vemuria38e5412021-02-23 15:28:28 -080058 script {
59 sh(script:"""
60 if [ '${volthaSystemTestsChange}' != '' ] ; then
61 cd $WORKSPACE/voltha-system-tests;
62 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
63 fi
64 """)
65 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070066 }
67 }
Matteo Scandolo92a5cb62020-09-15 16:02:08 -070068 // This checkout allows us to show changes in Jenkins
69 // we only do this on master as we don't branch all the repos for all the releases
70 // (we should compute the difference by tracking the container version, not the code)
71 stage('Download All the VOLTHA repos') {
72 when {
73 expression {
74 return "${branch}" == 'master';
75 }
76 }
77 steps {
78 checkout(changelog: true,
79 poll: false,
80 scm: [$class: 'RepoScm',
81 manifestRepositoryUrl: "${params.manifestUrl}",
82 manifestBranch: "${params.branch}",
83 currentBranch: true,
84 destinationDir: 'voltha',
85 forceSync: true,
86 resetFirst: true,
87 quiet: true,
88 jobs: 4,
89 showAllChanges: true]
90 )
91 }
92 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070093 stage ('Initialize') {
94 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000095 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070096 script {
97 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
98 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070099 sh returnStdout: false, script: """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700100 mkdir -p $WORKSPACE/bin
101 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
102 cd $WORKSPACE
Hardik Windlass6f854a12021-07-12 13:20:21 +0000103 if [ "${params.branch}" == "voltha-2.8" ]; then
104 VOLTCTL_VERSION=1.6.10
Suchitra Vemuri13421432020-06-05 17:34:33 -0700105 else
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700106 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 -0700107 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700108
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700109 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
110 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
111 if [ \$HOSTARCH == "x86_64" ]; then
112 HOSTARCH="amd64"
113 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700114 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 -0700115 chmod 755 $WORKSPACE/bin/voltctl
116 voltctl version --clientonly
Andrea Campanella9b234332020-04-24 12:22:18 +0200117
Matteo Scandolo3fbb0652020-07-22 08:50:02 -0700118
Andrea Campanella9b234332020-04-24 12:22:18 +0200119 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
120 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
121 # We should change this. In the meantime here is a workaround.
Suchitra Vemuri13421432020-06-05 17:34:33 -0700122 if [ "${params.branch}" == "master" ]; then
123 set +e
Andrea Campanella9b234332020-04-24 12:22:18 +0200124
Andrea Campanella9b234332020-04-24 12:22:18 +0200125
126 # Remove noise from voltha-core logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700127 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
128 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Andrea Campanella9b234332020-04-24 12:22:18 +0200129 # Remove noise from openolt logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700130 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
131 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
132 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Suchitra Vemuri13421432020-06-05 17:34:33 -0700133 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700134 """
135 }
136 }
137
138 stage('Functional Tests') {
139 environment {
Suchitra Vemurie4a5bcc2020-03-16 12:43:03 -0700140 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700141 ROBOT_FILE="Voltha_DT_PODTests.robot"
Andrea Campanellad924ce22020-04-20 16:40:41 +0200142 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700143 }
144 steps {
145 sh """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700146 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700147 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100148 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700149 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100150 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700151 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
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100167 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200168 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100169 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200170 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
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100185 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
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 {
Matteo Scandolo67842812021-07-13 16:52:13 -0700197 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
200 make -C $WORKSPACE/voltha-system-tests voltha-test || true
201 """
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700202 }
203 }
Andy Bavier5ad87c92020-05-11 16:31:35 -0700204
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800205 stage('Multiple OLT Tests') {
206 environment {
207 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
208 ROBOT_FILE="Voltha_DT_MultiOLT_Tests.robot"
209 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/MultipleOLTScenarios"
210 }
211 steps {
212 sh """
213 mkdir -p $ROBOT_LOGS_DIR
214 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100215 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800216 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100217 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800218 fi
219 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
220 """
221 }
222 }
223
224
Andrea Campanellad924ce22020-04-20 16:40:41 +0200225 stage('Error Scenario Tests') {
226 environment {
227 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
228 ROBOT_FILE="Voltha_ErrorScenarios.robot"
229 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
230 }
231 steps {
232 sh """
233 mkdir -p $ROBOT_LOGS_DIR
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100234 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700235 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Andrea Campanellad924ce22020-04-20 16:40:41 +0200236 """
237 }
Andrea Campanella71666372020-04-21 10:56:17 +0200238 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700239 }
240 post {
241 always {
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700242 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700243 sh returnStdout: false, script: '''
244 set +e
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700245
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700246 # collect logs collected in the Robot Framework StartLogging keyword
247 cd $WORKSPACE
248 gzip *-combined.log || true
249 rm *-combined.log || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700250 '''
251 script {
252 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100253 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
254 sh returnStdout: false, script: """
255 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
256 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
257 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
258 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
259 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
260 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
261 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
262 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
263 """
264 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700265 }
266 }
267 step([$class: 'RobotPublisher',
268 disableArchiveOutput: false,
269 logFileName: '**/log*.html',
270 otherFiles: '',
271 outputFileName: '**/output*.xml',
272 outputPath: 'RobotLogs',
273 passThreshold: 100,
274 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200275 unstableThreshold: 0,
276 onlyCritical: true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700277 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700278 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700279 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700280 }
281}