blob: 461ce881823291a82f48f23d19b98bbbf777fe08 [file] [log] [blame]
Joey Armstrongbeef4cd2023-01-18 09:59:58 -05001// -*- groovy -*-
2// -----------------------------------------------------------------------
Joey Armstrong6a9013e2024-02-01 17:56:57 -05003// Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
Suchitra Vemuri376859a2020-07-08 17:04:44 -07004//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
Joey Armstrongbeef4cd2023-01-18 09:59:58 -050016// -----------------------------------------------------------------------
Suchitra Vemuri376859a2020-07-08 17:04:44 -070017
Matteo Scandolo712514a2021-07-20 09:49:09 -070018library identifier: 'cord-jenkins-libraries@master',
19 retriever: modernSCM([
20 $class: 'GitSCMSource',
21 remote: 'https://gerrit.opencord.org/ci-management.git'
22])
23
Suchitra Vemuri376859a2020-07-08 17:04:44 -070024node {
25 // Need this so that deployment_config has global scope when it's read later
26 deployment_config = null
27}
28
Hardik Windlass7e4e3152021-09-29 06:42:05 +000029def infraNamespace = "infra"
30def volthaNamespace = "voltha"
31
Suchitra Vemuri376859a2020-07-08 17:04:44 -070032pipeline {
33 /* no label, executor is determined by JJB */
34 agent {
35 label "${params.buildNode}"
36 }
37 options {
Hardik Windlassd0f01662021-09-03 08:07:15 +000038 timeout(time: "${timeout}", unit: 'MINUTES')
Suchitra Vemuri376859a2020-07-08 17:04:44 -070039 }
40
41 environment {
42 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Jan Klarece1bc812023-09-28 13:15:52 +020043 VOLTCONFIG="$HOME/.volt/config"
Suchitra Vemuri376859a2020-07-08 17:04:44 -070044 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
45 }
46
47 stages {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070048 stage('Clone voltha-system-tests') {
49 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000050 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070051 checkout([
52 $class: 'GitSCM',
53 userRemoteConfigs: [[
54 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000055 refspec: "${volthaSystemTestsChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070056 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000057 branches: [[ name: "${branch}", ]],
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070058 extensions: [
59 [$class: 'WipeWorkspace'],
60 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
61 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
62 ],
63 ])
Hardik Windlass81f67dc2021-03-05 16:15:42 +053064 script {
65 sh(script:"""
66 if [ '${volthaSystemTestsChange}' != '' ] ; then
67 cd $WORKSPACE/voltha-system-tests;
68 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
69 fi
70 """)
71 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070072 }
73 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070074 // This checkout allows us to show changes in Jenkins
75 // we only do this on master as we don't branch all the repos for all the releases
76 // (we should compute the difference by tracking the container version, not the code)
77 stage('Download All the VOLTHA repos') {
78 when {
79 expression {
80 return "${branch}" == 'master';
81 }
82 }
83 steps {
84 checkout(changelog: true,
85 poll: false,
86 scm: [$class: 'RepoScm',
87 manifestRepositoryUrl: "${params.manifestUrl}",
88 manifestBranch: "${params.branch}",
89 currentBranch: true,
90 destinationDir: 'voltha',
91 forceSync: true,
92 resetFirst: true,
93 quiet: true,
94 jobs: 4,
95 showAllChanges: true]
96 )
97 }
98 }
Joey Armstrongbeef4cd2023-01-18 09:59:58 -050099 stage ('Initialize')
100 {
101 steps
102 {
103 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
104 script
105 {
106 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
107 }
108
Hardik Windlass9658cd22021-10-25 11:13:25 +0000109 installVoltctl("${branch}")
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500110
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700111 sh returnStdout: false, script: """
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500112 mkdir -p "$WORKSPACE/bin"
113
114 # install kail
115 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200116
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700117 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
118 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
119 # We should change this. In the meantime here is a workaround.
120 if [ "${params.branch}" == "master" ]; then
121 set +e
122
123
124 # Remove noise from voltha-core logs
125 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
126 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
127 # Remove noise from openolt logs
128 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
129 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
130 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
131 fi
132 """
133 }
134 }
135
136 stage('Functional Tests') {
137 environment {
138 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
139 ROBOT_FILE="Voltha_TT_PODTests.robot"
140 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
141 }
142 steps {
143 sh """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700144 mkdir -p $ROBOT_LOGS_DIR
145 if ( ${powerSwitch} ); then
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000146 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}"
Hardik Windlass28a7bd02022-04-12 13:14:54 +0000147 if ( ${powerCycleOlt} ); then
148 ROBOT_MISC_ARGS+=" -v power_cycle_olt:True"
149 fi
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700150 else
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000151 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 -0700152 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000153 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700154 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700155 """
156 }
157 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530158
159 stage('Failure/Recovery Tests') {
160 environment {
161 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
162 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
163 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
164 }
165 steps {
166 sh """
167 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000168 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000169 if ( ${powerSwitch} ); then
170 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}"
171 else
172 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}"
173 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000174 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass6598b032021-07-02 10:12:01 +0000175 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530176 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530177 """
178 }
179 }
180
Hardik Windlass6a233e82021-05-27 04:08:50 +0000181 stage('Multi-Tcont Tests') {
Mahir Gunyel0793b6f2023-11-30 14:52:27 -0800182 when {
183 expression {
184 return params.runMultiTcontTests
185 }
186 }
Hardik Windlass6a233e82021-05-27 04:08:50 +0000187 environment {
188 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
189 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
190 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
191 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
192 }
193 steps {
194 sh """
195 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000196 if [ ${params.enableMultiUni} = false ]; then
197 if ( ${powerSwitch} ); then
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000198 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:False -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 Windlass92dba5d2021-07-14 06:37:44 +0000199 else
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000200 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:False -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"
201 fi
202 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
203 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
204 fi
205 """
206 }
207 }
208
209 stage('Multicast Tests') {
210 environment {
211 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
212 ROBOT_FILE="Voltha_TT_MulticastTests.robot"
213 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
214 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
215 }
216 steps {
217 sh """
218 mkdir -p $ROBOT_LOGS_DIR
219 if [ ${params.enableMultiUni} = true ]; then
220 if ( ${powerSwitch} ); then
221 export ROBOT_MISC_ARGS="--removekeywords wuks -i multicastTT -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:False -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"
222 else
223 export ROBOT_MISC_ARGS="--removekeywords wuks -i multicastTT -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:False -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 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000225 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000226 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000227 fi
228 """
229 }
230 }
231
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700232 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700233 post {
234 always {
Hardik Windlassceb56312021-07-21 16:12:25 +0000235 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700236 sh returnStdout: false, script: '''
237 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700238
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700239 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700240 cd $WORKSPACE
241 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200242 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700243 '''
244 script {
245 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100246 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
247 sh returnStdout: false, script: """
248 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
Girish Gowdra1cdfeb52021-10-28 15:12:45 -0700249 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100250 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
Girish Gowdra1cdfeb52021-10-28 15:12:45 -0700251 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100252 """
253 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700254 }
255 }
256 step([$class: 'RobotPublisher',
257 disableArchiveOutput: false,
258 logFileName: '**/log*.html',
259 otherFiles: '',
260 outputFileName: '**/output*.xml',
261 outputPath: 'RobotLogs',
262 passThreshold: 100,
263 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200264 unstableThreshold: 0,
265 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700266 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700267 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700268 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700269 }
270}