blob: 9a3c84e852d7b5d8f6e322d2de45e29dda009d5c [file] [log] [blame]
Joey Armstrong980e37f2023-02-28 18:57:41 -05001// -*- groovy -*-
2// -----------------------------------------------------------------------
3// Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
4//
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.
16// -----------------------------------------------------------------------
17
18library identifier: 'cord-jenkins-libraries@master',
19 retriever: modernSCM([
20 $class: 'GitSCMSource',
21 remote: 'https://gerrit.opencord.org/ci-management.git'
22])
23
24node {
25 // Need this so that deployment_config has global scope when it's read later
26 deployment_config = null
27}
28
Joey Armstrongdf24f602023-03-02 18:18:21 -050029// -----------------------------------------------------------------------
30// -----------------------------------------------------------------------
31def getIam(String func)
32{
33 // Cannot rely on a stack trace due to jenkins manipulation
34 String src = [
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050035 'jjb',
36 'pipeline',
37 'voltha',
38 'playground',
39 'voltha-tt-physical-functional-tests.groovy'
Joey Armstrongdf24f602023-03-02 18:18:21 -050040 ].join('/')
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050041
Joey Armstrongdf24f602023-03-02 18:18:21 -050042 String iam = [src, func].join('::')
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050043 iam += sprintf('[ver:1.0]')
Joey Armstrongdf24f602023-03-02 18:18:21 -050044 return iam
45}
46
Joey Armstrong980e37f2023-02-28 18:57:41 -050047def infraNamespace = "infra"
48def volthaNamespace = "voltha"
49
Joey Armstrongdf24f602023-03-02 18:18:21 -050050pipeline
51{
52 /* no label, executor is determined by JJB */
53 agent
54 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050055 label "${params.buildNode}"
Joey Armstrongdf24f602023-03-02 18:18:21 -050056 }
Joey Armstrong980e37f2023-02-28 18:57:41 -050057
Joey Armstrongdf24f602023-03-02 18:18:21 -050058 options
59 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050060 timeout(time: "${timeout}", unit: 'MINUTES')
Joey Armstrongdf24f602023-03-02 18:18:21 -050061 }
Joey Armstrong980e37f2023-02-28 18:57:41 -050062
Joey Armstrongdf24f602023-03-02 18:18:21 -050063 environment
64 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050065 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
66 VOLTCONFIG="$HOME/.volt/config-minimal"
67 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Joey Armstrongdf24f602023-03-02 18:18:21 -050068 }
69
70 stages {
71
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050072 // -----------------------------------------------------------------------
73 // -----------------------------------------------------------------------
74 stage('Clone voltha-system-tests')
75 {
76 steps
77 {
Joey Armstrong9ed18e12023-03-07 10:40:14 -050078 iam
Joey Armstrongcd6aa772023-03-07 09:05:37 -050079 {
80 enter = true
81 label = getIam()
82 }
83
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050084 step([$class: 'WsCleanup'])
85 checkout([
86 $class: 'GitSCM',
87 userRemoteConfigs: [[
88 url: "https://gerrit.opencord.org/voltha-system-tests",
89 refspec: "${volthaSystemTestsChange}"
90 ]],
91 branches: [[ name: "${branch}" ]],
92 extensions: [
93 [$class: 'WipeWorkspace'],
94 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
95 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
96 ],
97 ]) // checkout
Joey Armstrongdf24f602023-03-02 18:18:21 -050098
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050099 script
100 {
101 sh(
102 returnStatus: true,
103 // returnStdout: true,
104 script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500105 if [ '${volthaSystemTestsChange}' != '' ] ; then
Joey Armstrongdf24f602023-03-02 18:18:21 -0500106 cd "$WORKSPACE/voltha-system-tests"
107 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange}
108 git checkout FETCH_HEAD
109 exit 1 # verify fail
Joey Armstrong980e37f2023-02-28 18:57:41 -0500110 fi
111 """)
Joey Armstrong0c689df2023-03-03 16:03:50 -0500112 } // step
Joey Armstrongdb892b52023-03-03 10:44:06 -0500113
Joey Armstrong9ed18e12023-03-07 10:40:14 -0500114 iam
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500115 {
116 leave = true
117 label = getIam()
118 }
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500119 } // steps
120 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500121
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500122 // -----------------------------------------------------------------------
123 // This checkout allows us to show changes in Jenkins
124 // we only do this on master as we don't branch all the repos for all the releases
125 // (we should compute the difference by tracking the container version, not the code)
126 // -----------------------------------------------------------------------
127 stage('Download All the VOLTHA repos')
128 {
129 when {
130 expression { return "${branch}" == 'master'; }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500131 }
132
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500133 steps {
134 checkout(changelog: true,
135 poll: false,
136 scm: [$class: 'RepoScm',
137 manifestRepositoryUrl: "${params.manifestUrl}",
138 manifestBranch: "${params.branch}",
139 currentBranch: true,
140 destinationDir: 'voltha',
141 forceSync: true,
142 resetFirst: true,
143 quiet: true,
144 jobs: 4,
145 showAllChanges: true]
146 )
147 }
148 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500149
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500150 // -----------------------------------------------------------------------
151 // -----------------------------------------------------------------------
152 stage ('Initialize')
153 {
Joey Armstrongdf24f602023-03-02 18:18:21 -0500154 steps
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500155 {
156 sh(
157 returnStatus: true,
158 returnStdout: false,
159 script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
160 )
161 script
162 {
163 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
164 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500165
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500166 installVoltctl("${branch}")
Joey Armstrongdf24f602023-03-02 18:18:21 -0500167
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500168 sh(
169 returnStatus: true,
170 returnStdout: false,
171 script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500172 mkdir -p "$WORKSPACE/bin"
173
174 # install kail
175 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
176
177 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
178 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
179 # We should change this. In the meantime here is a workaround.
180 if [ "${params.branch}" == "master" ]; then
181 set +e
182
Joey Armstrong980e37f2023-02-28 18:57:41 -0500183 # Remove noise from voltha-core logs
184 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
185 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
186 # Remove noise from openolt logs
187 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
188 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
189 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
190 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500191 """)
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500192 } // step
193 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500194
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500195 // -----------------------------------------------------------------------
196 // -----------------------------------------------------------------------
197 stage('Functional Tests')
198 {
199 environment
200 {
201 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
202 ROBOT_FILE="Voltha_TT_PODTests.robot"
203 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
204 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500205
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500206 steps {
207 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500208 mkdir -p $ROBOT_LOGS_DIR
209 if ( ${powerSwitch} ); then
210 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}"
211 if ( ${powerCycleOlt} ); then
212 ROBOT_MISC_ARGS+=" -v power_cycle_olt:True"
213 fi
214 else
215 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}"
216 fi
217 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Joey Armstrongdf24f602023-03-02 18:18:21 -0500218 make -C $WORKSPACE/voltha-system-tests voltha-tt-test
219 """)
Joey Armstrong980e37f2023-02-28 18:57:41 -0500220 }
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500221 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500222
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500223 // -----------------------------------------------------------------------
224 // -----------------------------------------------------------------------
225 stage('Failure/Recovery Tests')
226 {
227 environment
228 {
229 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
230 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
231 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
232 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500233
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500234 steps
235 {
236 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500237 mkdir -p $ROBOT_LOGS_DIR
238 if [ ${params.enableMultiUni} = false ]; then
239 if ( ${powerSwitch} ); then
240 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}"
241 else
242 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}"
243 fi
244 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
245 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
246 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500247 """)
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500248 }
249 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500250
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500251 // -----------------------------------------------------------------------
252 // -----------------------------------------------------------------------
253 stage('Multi-Tcont Tests')
254 {
255 environment
256 {
257 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
258 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
259 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
260 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
261 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500262
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500263 steps
264 {
265 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500266 mkdir -p $ROBOT_LOGS_DIR
267 if [ ${params.enableMultiUni} = false ]; then
268 if ( ${powerSwitch} ); then
269 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"
270 else
271 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"
272 fi
273 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
274 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
275 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500276 """)
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500277 }
278 }
Joey Armstrong980e37f2023-02-28 18:57:41 -0500279
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500280 // -----------------------------------------------------------------------
281 // -----------------------------------------------------------------------
282 stage('Multicast Tests')
283 {
284 environment
285 {
286 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
287 ROBOT_FILE="Voltha_TT_MulticastTests.robot"
288 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
289 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
290 }
291
292 steps
293 {
294 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500295 mkdir -p $ROBOT_LOGS_DIR
296 if [ ${params.enableMultiUni} = true ]; then
297 if ( ${powerSwitch} ); then
298 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"
299 else
300 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"
301 fi
302 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
303 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
304 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500305 """)
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500306 }
307 }
Joey Armstrong980e37f2023-02-28 18:57:41 -0500308 }
309
Joey Armstrongdf24f602023-03-02 18:18:21 -0500310 post
311 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500312 always
313 {
314 getPodsInfo("$WORKSPACE/pods")
315 sh(returnStdout: false, script: '''
Joey Armstrong980e37f2023-02-28 18:57:41 -0500316 set +e
317
318 # collect logs collected in the Robot Framework StartLogging keyword
319 cd $WORKSPACE
320 gzip *-combined.log || true
321 rm *-combined.log || true
Joey Armstrongdf24f602023-03-02 18:18:21 -0500322 ''')
323
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500324 script {
Joey Armstrong980e37f2023-02-28 18:57:41 -0500325 deployment_config.olts.each { olt ->
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500326 if (olt.type == null || olt.type == "" || olt.type == "openolt")
327 {
328 sh(returnStdout: false, script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500329 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
330 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
331 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
332 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
Joey Armstrongdf24f602023-03-02 18:18:21 -0500333 """)
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500334 }
335 }
336 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500337
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500338 step([$class: 'RobotPublisher',
339 disableArchiveOutput: false,
340 logFileName: '**/log*.html',
341 otherFiles: '',
342 outputFileName: '**/output*.xml',
343 outputPath: 'RobotLogs',
344 passThreshold: 100,
345 reportFileName: '**/report*.html',
346 unstableThreshold: 0,
347 onlyCritical: true
Joey Armstrongdf24f602023-03-02 18:18:21 -0500348 ]);
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500349 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
350 } // always
Joey Armstrongdf24f602023-03-02 18:18:21 -0500351 } // post
352} // pipeline
353
354// [EOF]