blob: 6dd6cbedae3fb3f41b3f6267522a6a2fad1572da [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 = [
35 'jjb',
36 'pipeline',
37 'voltha',
38 'playground',
39 'voltha-tt-physical-functional-tests.groovy'
40 ].join('/')
41 String iam = [src, func].join('::')
42 return iam
43}
44
Joey Armstrong980e37f2023-02-28 18:57:41 -050045def infraNamespace = "infra"
46def volthaNamespace = "voltha"
47
Joey Armstrongdf24f602023-03-02 18:18:21 -050048pipeline
49{
50 /* no label, executor is determined by JJB */
51 agent
52 {
53 label "${params.buildNode}"
54 }
Joey Armstrong980e37f2023-02-28 18:57:41 -050055
Joey Armstrongdf24f602023-03-02 18:18:21 -050056 options
57 {
58 timeout(time: "${timeout}", unit: 'MINUTES')
59 }
Joey Armstrong980e37f2023-02-28 18:57:41 -050060
Joey Armstrongdf24f602023-03-02 18:18:21 -050061 environment
62 {
63 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
64 VOLTCONFIG="$HOME/.volt/config-minimal"
65 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
66 }
67
68 stages {
69
70 // -----------------------------------------------------------------------
71 // -----------------------------------------------------------------------
72 stage('IAM')
73 {
74 String iam = get_iam('main')
75 println("** ${iam}: ENTER")
76 println("** ${iam}: LEAVE")
77 }
78
79 // -----------------------------------------------------------------------
80 // -----------------------------------------------------------------------
81 stage('Clone voltha-system-tests')
82 {
83 steps
84 {
85 step([$class: 'WsCleanup'])
86 checkout([
87 $class: 'GitSCM',
88 userRemoteConfigs: [[
89 url: "https://gerrit.opencord.org/voltha-system-tests",
90 refspec: "${volthaSystemTestsChange}"
91 ]],
92 branches: [[ name: "${branch}" ]],
93 extensions: [
94 [$class: 'WipeWorkspace'],
95 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
96 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
97 ],
98 ]) // checkout
99
100 script
101 {
102 sh(
103 returnStatus: true,
104 // returnStdout: true,
105 script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500106 if [ '${volthaSystemTestsChange}' != '' ] ; then
Joey Armstrongdf24f602023-03-02 18:18:21 -0500107 cd "$WORKSPACE/voltha-system-tests"
108 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange}
109 git checkout FETCH_HEAD
110 exit 1 # verify fail
Joey Armstrong980e37f2023-02-28 18:57:41 -0500111 fi
112 """)
Joey Armstrongdf24f602023-03-02 18:18:21 -0500113 } // step
114 } // steps
115 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500116
Joey Armstrongdf24f602023-03-02 18:18:21 -0500117 // -----------------------------------------------------------------------
118 // This checkout allows us to show changes in Jenkins
119 // we only do this on master as we don't branch all the repos for all the releases
120 // (we should compute the difference by tracking the container version, not the code)
121 // -----------------------------------------------------------------------
122 stage('Download All the VOLTHA repos')
123 {
124 when {
125 expression { return "${branch}" == 'master'; }
126 }
127
128 steps {
129 checkout(changelog: true,
130 poll: false,
131 scm: [$class: 'RepoScm',
132 manifestRepositoryUrl: "${params.manifestUrl}",
133 manifestBranch: "${params.branch}",
134 currentBranch: true,
135 destinationDir: 'voltha',
136 forceSync: true,
137 resetFirst: true,
138 quiet: true,
139 jobs: 4,
140 showAllChanges: true]
141 )
142 }
143 }
144
145 // -----------------------------------------------------------------------
146 // -----------------------------------------------------------------------
147 stage ('Initialize')
148 {
149 steps
150 {
151 sh(
152 returnStatus: true,
153 returnStdout: false,
154 script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
155 )
156 script
157 {
158 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
159 }
160
161 installVoltctl("${branch}")
162
163 sh(
164 returnStatus: true,
165 returnStdout: false,
166 script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500167 mkdir -p "$WORKSPACE/bin"
168
169 # install kail
170 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
171
172 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
173 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
174 # We should change this. In the meantime here is a workaround.
175 if [ "${params.branch}" == "master" ]; then
176 set +e
177
Joey Armstrong980e37f2023-02-28 18:57:41 -0500178 # Remove noise from voltha-core logs
179 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
180 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
181 # Remove noise from openolt logs
182 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
183 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
184 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
185 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500186 """)
187 } // step
188 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500189
Joey Armstrongdf24f602023-03-02 18:18:21 -0500190 // -----------------------------------------------------------------------
191 // -----------------------------------------------------------------------
192 stage('Functional Tests')
193 {
194 environment
195 {
196 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
197 ROBOT_FILE="Voltha_TT_PODTests.robot"
198 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
199 }
200
201 steps {
202 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500203 mkdir -p $ROBOT_LOGS_DIR
204 if ( ${powerSwitch} ); then
205 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}"
206 if ( ${powerCycleOlt} ); then
207 ROBOT_MISC_ARGS+=" -v power_cycle_olt:True"
208 fi
209 else
210 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}"
211 fi
212 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Joey Armstrongdf24f602023-03-02 18:18:21 -0500213 make -C $WORKSPACE/voltha-system-tests voltha-tt-test
214 """)
Joey Armstrong980e37f2023-02-28 18:57:41 -0500215 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500216 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500217
Joey Armstrongdf24f602023-03-02 18:18:21 -0500218 // -----------------------------------------------------------------------
219 // -----------------------------------------------------------------------
220 stage('Failure/Recovery Tests')
221 {
222 environment
223 {
224 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
225 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
226 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
227 }
228
229 steps
230 {
231 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500232 mkdir -p $ROBOT_LOGS_DIR
233 if [ ${params.enableMultiUni} = false ]; then
234 if ( ${powerSwitch} ); then
235 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}"
236 else
237 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}"
238 fi
239 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
240 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
241 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500242 """)
243 }
244 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500245
Joey Armstrongdf24f602023-03-02 18:18:21 -0500246 // -----------------------------------------------------------------------
247 // -----------------------------------------------------------------------
248 stage('Multi-Tcont Tests')
249 {
250 environment
251 {
252 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
253 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
254 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
255 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
256 }
257
258 steps
259 {
260 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500261 mkdir -p $ROBOT_LOGS_DIR
262 if [ ${params.enableMultiUni} = false ]; then
263 if ( ${powerSwitch} ); then
264 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"
265 else
266 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"
267 fi
268 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
269 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
270 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500271 """)
272 }
273 }
274
275 // -----------------------------------------------------------------------
276 // -----------------------------------------------------------------------
277 stage('Multicast Tests')
278 {
279 environment
280 {
281 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
282 ROBOT_FILE="Voltha_TT_MulticastTests.robot"
283 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
284 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
285 }
Joey Armstrong980e37f2023-02-28 18:57:41 -0500286
Joey Armstrongdf24f602023-03-02 18:18:21 -0500287 steps
288 {
289 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500290 mkdir -p $ROBOT_LOGS_DIR
291 if [ ${params.enableMultiUni} = true ]; then
292 if ( ${powerSwitch} ); then
293 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"
294 else
295 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"
296 fi
297 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
298 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
299 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500300 """)
301 }
302 }
Joey Armstrong980e37f2023-02-28 18:57:41 -0500303 }
304
Joey Armstrongdf24f602023-03-02 18:18:21 -0500305 post
306 {
307 always
308 {
309 getPodsInfo("$WORKSPACE/pods")
310 sh(returnStdout: false, script: '''
Joey Armstrong980e37f2023-02-28 18:57:41 -0500311 set +e
312
313 # collect logs collected in the Robot Framework StartLogging keyword
314 cd $WORKSPACE
315 gzip *-combined.log || true
316 rm *-combined.log || true
Joey Armstrongdf24f602023-03-02 18:18:21 -0500317 ''')
318
319 script {
Joey Armstrong980e37f2023-02-28 18:57:41 -0500320 deployment_config.olts.each { olt ->
Joey Armstrongdf24f602023-03-02 18:18:21 -0500321 if (olt.type == null || olt.type == "" || olt.type == "openolt")
322 {
323 sh(returnStdout: false, script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500324 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
325 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
326 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
327 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 -0500328 """)
329 }
330 }
331 }
332
333 step([$class: 'RobotPublisher',
334 disableArchiveOutput: false,
335 logFileName: '**/log*.html',
336 otherFiles: '',
337 outputFileName: '**/output*.xml',
338 outputPath: 'RobotLogs',
339 passThreshold: 100,
340 reportFileName: '**/report*.html',
341 unstableThreshold: 0,
342 onlyCritical: true
343 ]);
344 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
345 } // always
346 } // post
347} // pipeline
348
349// [EOF]