blob: 569cf1dfbef4e86120d5d662b5e94cf8ed7c2b66 [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 // -----------------------------------------------------------------------
Joey Armstrongdf24f602023-03-02 18:18:21 -050072 stage('Clone voltha-system-tests')
73 {
74 steps
75 {
Joey Armstrongdb892b52023-03-03 10:44:06 -050076 iam(this) { enter = true }
77
Joey Armstrongdf24f602023-03-02 18:18:21 -050078 step([$class: 'WsCleanup'])
79 checkout([
80 $class: 'GitSCM',
81 userRemoteConfigs: [[
82 url: "https://gerrit.opencord.org/voltha-system-tests",
83 refspec: "${volthaSystemTestsChange}"
84 ]],
85 branches: [[ name: "${branch}" ]],
86 extensions: [
87 [$class: 'WipeWorkspace'],
88 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
89 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
90 ],
91 ]) // checkout
92
93 script
94 {
95 sh(
96 returnStatus: true,
97 // returnStdout: true,
98 script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -050099 if [ '${volthaSystemTestsChange}' != '' ] ; then
Joey Armstrongdf24f602023-03-02 18:18:21 -0500100 cd "$WORKSPACE/voltha-system-tests"
101 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange}
102 git checkout FETCH_HEAD
103 exit 1 # verify fail
Joey Armstrong980e37f2023-02-28 18:57:41 -0500104 fi
105 """)
Joey Armstrongdb892b52023-03-03 10:44:06 -0500106
107 iam(this) { leave = true }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500108 } // step
109 } // steps
110 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500111
Joey Armstrongdf24f602023-03-02 18:18:21 -0500112 // -----------------------------------------------------------------------
113 // This checkout allows us to show changes in Jenkins
114 // we only do this on master as we don't branch all the repos for all the releases
115 // (we should compute the difference by tracking the container version, not the code)
116 // -----------------------------------------------------------------------
117 stage('Download All the VOLTHA repos')
118 {
119 when {
120 expression { return "${branch}" == 'master'; }
121 }
122
123 steps {
124 checkout(changelog: true,
125 poll: false,
126 scm: [$class: 'RepoScm',
127 manifestRepositoryUrl: "${params.manifestUrl}",
128 manifestBranch: "${params.branch}",
129 currentBranch: true,
130 destinationDir: 'voltha',
131 forceSync: true,
132 resetFirst: true,
133 quiet: true,
134 jobs: 4,
135 showAllChanges: true]
136 )
137 }
138 }
139
140 // -----------------------------------------------------------------------
141 // -----------------------------------------------------------------------
142 stage ('Initialize')
143 {
144 steps
145 {
146 sh(
147 returnStatus: true,
148 returnStdout: false,
149 script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
150 )
151 script
152 {
153 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
154 }
155
156 installVoltctl("${branch}")
157
158 sh(
159 returnStatus: true,
160 returnStdout: false,
161 script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500162 mkdir -p "$WORKSPACE/bin"
163
164 # install kail
165 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
166
167 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
168 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
169 # We should change this. In the meantime here is a workaround.
170 if [ "${params.branch}" == "master" ]; then
171 set +e
172
Joey Armstrong980e37f2023-02-28 18:57:41 -0500173 # Remove noise from voltha-core logs
174 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
175 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
176 # Remove noise from openolt logs
177 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
178 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
179 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
180 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500181 """)
182 } // step
183 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500184
Joey Armstrongdf24f602023-03-02 18:18:21 -0500185 // -----------------------------------------------------------------------
186 // -----------------------------------------------------------------------
187 stage('Functional Tests')
188 {
189 environment
190 {
191 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
192 ROBOT_FILE="Voltha_TT_PODTests.robot"
193 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
194 }
195
196 steps {
197 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500198 mkdir -p $ROBOT_LOGS_DIR
199 if ( ${powerSwitch} ); then
200 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}"
201 if ( ${powerCycleOlt} ); then
202 ROBOT_MISC_ARGS+=" -v power_cycle_olt:True"
203 fi
204 else
205 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}"
206 fi
207 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Joey Armstrongdf24f602023-03-02 18:18:21 -0500208 make -C $WORKSPACE/voltha-system-tests voltha-tt-test
209 """)
Joey Armstrong980e37f2023-02-28 18:57:41 -0500210 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500211 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500212
Joey Armstrongdf24f602023-03-02 18:18:21 -0500213 // -----------------------------------------------------------------------
214 // -----------------------------------------------------------------------
215 stage('Failure/Recovery Tests')
216 {
217 environment
218 {
219 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
220 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
221 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
222 }
223
224 steps
225 {
226 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500227 mkdir -p $ROBOT_LOGS_DIR
228 if [ ${params.enableMultiUni} = false ]; then
229 if ( ${powerSwitch} ); then
230 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}"
231 else
232 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}"
233 fi
234 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
235 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
236 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500237 """)
238 }
239 } // stage
Joey Armstrong980e37f2023-02-28 18:57:41 -0500240
Joey Armstrongdf24f602023-03-02 18:18:21 -0500241 // -----------------------------------------------------------------------
242 // -----------------------------------------------------------------------
243 stage('Multi-Tcont Tests')
244 {
245 environment
246 {
247 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
248 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
249 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
250 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
251 }
252
253 steps
254 {
255 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500256 mkdir -p $ROBOT_LOGS_DIR
257 if [ ${params.enableMultiUni} = false ]; then
258 if ( ${powerSwitch} ); then
259 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"
260 else
261 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"
262 fi
263 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
264 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
265 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500266 """)
267 }
268 }
269
270 // -----------------------------------------------------------------------
271 // -----------------------------------------------------------------------
272 stage('Multicast Tests')
273 {
274 environment
275 {
276 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
277 ROBOT_FILE="Voltha_TT_MulticastTests.robot"
278 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
279 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
280 }
Joey Armstrong980e37f2023-02-28 18:57:41 -0500281
Joey Armstrongdf24f602023-03-02 18:18:21 -0500282 steps
283 {
284 sh("""
Joey Armstrong980e37f2023-02-28 18:57:41 -0500285 mkdir -p $ROBOT_LOGS_DIR
286 if [ ${params.enableMultiUni} = true ]; then
287 if ( ${powerSwitch} ); then
288 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"
289 else
290 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"
291 fi
292 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
293 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
294 fi
Joey Armstrongdf24f602023-03-02 18:18:21 -0500295 """)
296 }
297 }
Joey Armstrong980e37f2023-02-28 18:57:41 -0500298 }
299
Joey Armstrongdf24f602023-03-02 18:18:21 -0500300 post
301 {
302 always
303 {
304 getPodsInfo("$WORKSPACE/pods")
305 sh(returnStdout: false, script: '''
Joey Armstrong980e37f2023-02-28 18:57:41 -0500306 set +e
307
308 # collect logs collected in the Robot Framework StartLogging keyword
309 cd $WORKSPACE
310 gzip *-combined.log || true
311 rm *-combined.log || true
Joey Armstrongdf24f602023-03-02 18:18:21 -0500312 ''')
313
314 script {
Joey Armstrong980e37f2023-02-28 18:57:41 -0500315 deployment_config.olts.each { olt ->
Joey Armstrongdf24f602023-03-02 18:18:21 -0500316 if (olt.type == null || olt.type == "" || olt.type == "openolt")
317 {
318 sh(returnStdout: false, script: """
Joey Armstrong980e37f2023-02-28 18:57:41 -0500319 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
320 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
321 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
322 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 -0500323 """)
324 }
325 }
326 }
327
328 step([$class: 'RobotPublisher',
329 disableArchiveOutput: false,
330 logFileName: '**/log*.html',
331 otherFiles: '',
332 outputFileName: '**/output*.xml',
333 outputPath: 'RobotLogs',
334 passThreshold: 100,
335 reportFileName: '**/report*.html',
336 unstableThreshold: 0,
337 onlyCritical: true
338 ]);
339 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
340 } // always
341 } // post
342} // pipeline
343
344// [EOF]