blob: 6f68e706612b85f1b2021bdd217e936d07f0d4c5 [file] [log] [blame]
Joey Armstrong56fdfec2024-03-01 13:43:36 -05001#!/usr/bin/env groovy
Joey Armstrongbeef4cd2023-01-18 09:59:58 -05002// -----------------------------------------------------------------------
Joey Armstrong56fdfec2024-03-01 13:43:36 -05003// Copyright 2017-2024 Open Networking Foundation 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// -----------------------------------------------------------------------
Joey Armstrong56fdfec2024-03-01 13:43:36 -050017// SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
18// SPDX-License-Identifier: Apache-2.0
19// -----------------------------------------------------------------------
20// Entropy: 0fcb5ffa-d1a4-11ee-be5e-9f44b7181764
21// -----------------------------------------------------------------------
22// Intent:
23// -----------------------------------------------------------------------
Suchitra Vemuri376859a2020-07-08 17:04:44 -070024
Matteo Scandolo712514a2021-07-20 09:49:09 -070025library identifier: 'cord-jenkins-libraries@master',
26 retriever: modernSCM([
27 $class: 'GitSCMSource',
28 remote: 'https://gerrit.opencord.org/ci-management.git'
29])
30
Suchitra Vemuri376859a2020-07-08 17:04:44 -070031node {
32 // Need this so that deployment_config has global scope when it's read later
33 deployment_config = null
34}
35
Hardik Windlass7e4e3152021-09-29 06:42:05 +000036def infraNamespace = "infra"
37def volthaNamespace = "voltha"
38
Suchitra Vemuri376859a2020-07-08 17:04:44 -070039pipeline {
40 /* no label, executor is determined by JJB */
41 agent {
42 label "${params.buildNode}"
43 }
44 options {
Hardik Windlassd0f01662021-09-03 08:07:15 +000045 timeout(time: "${timeout}", unit: 'MINUTES')
Suchitra Vemuri376859a2020-07-08 17:04:44 -070046 }
47
48 environment {
49 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Jan Klarece1bc812023-09-28 13:15:52 +020050 VOLTCONFIG="$HOME/.volt/config"
Suchitra Vemuri376859a2020-07-08 17:04:44 -070051 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
52 }
53
54 stages {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070055 stage('Clone voltha-system-tests') {
56 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000057 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070058 checkout([
59 $class: 'GitSCM',
60 userRemoteConfigs: [[
61 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000062 refspec: "${volthaSystemTestsChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070063 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000064 branches: [[ name: "${branch}", ]],
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070065 extensions: [
66 [$class: 'WipeWorkspace'],
67 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
68 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
69 ],
70 ])
Hardik Windlass81f67dc2021-03-05 16:15:42 +053071 script {
72 sh(script:"""
73 if [ '${volthaSystemTestsChange}' != '' ] ; then
74 cd $WORKSPACE/voltha-system-tests;
75 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
76 fi
77 """)
78 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070079 }
80 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070081 // This checkout allows us to show changes in Jenkins
82 // we only do this on master as we don't branch all the repos for all the releases
83 // (we should compute the difference by tracking the container version, not the code)
84 stage('Download All the VOLTHA repos') {
85 when {
86 expression {
87 return "${branch}" == 'master';
88 }
89 }
90 steps {
91 checkout(changelog: true,
92 poll: false,
93 scm: [$class: 'RepoScm',
94 manifestRepositoryUrl: "${params.manifestUrl}",
95 manifestBranch: "${params.branch}",
96 currentBranch: true,
97 destinationDir: 'voltha',
98 forceSync: true,
99 resetFirst: true,
100 quiet: true,
101 jobs: 4,
102 showAllChanges: true]
103 )
104 }
105 }
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500106 stage ('Initialize')
107 {
108 steps
109 {
110 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
111 script
112 {
113 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
114 }
Joey Armstrongdaa1f0a2024-04-03 18:07:59 -0400115
Hardik Windlass9658cd22021-10-25 11:13:25 +0000116 installVoltctl("${branch}")
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500117
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700118 sh returnStdout: false, script: """
Joey Armstrongbeef4cd2023-01-18 09:59:58 -0500119 mkdir -p "$WORKSPACE/bin"
120
121 # install kail
122 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200123
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700124 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
125 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
126 # We should change this. In the meantime here is a workaround.
127 if [ "${params.branch}" == "master" ]; then
128 set +e
129
130
131 # Remove noise from voltha-core logs
132 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
133 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
134 # Remove noise from openolt logs
135 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
136 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
137 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
138 fi
139 """
140 }
141 }
142
143 stage('Functional Tests') {
144 environment {
145 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
146 ROBOT_FILE="Voltha_TT_PODTests.robot"
147 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
148 }
149 steps {
150 sh """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700151 mkdir -p $ROBOT_LOGS_DIR
152 if ( ${powerSwitch} ); then
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000153 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 +0000154 if ( ${powerCycleOlt} ); then
155 ROBOT_MISC_ARGS+=" -v power_cycle_olt:True"
156 fi
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700157 else
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000158 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 -0700159 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000160 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700161 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700162 """
163 }
164 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530165
166 stage('Failure/Recovery Tests') {
167 environment {
168 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
169 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
170 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
171 }
172 steps {
173 sh """
174 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000175 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000176 if ( ${powerSwitch} ); then
177 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}"
178 else
179 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}"
180 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000181 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass6598b032021-07-02 10:12:01 +0000182 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530183 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530184 """
185 }
186 }
187
Hardik Windlass6a233e82021-05-27 04:08:50 +0000188 stage('Multi-Tcont Tests') {
Mahir Gunyel0793b6f2023-11-30 14:52:27 -0800189 when {
190 expression {
191 return params.runMultiTcontTests
192 }
193 }
Hardik Windlass6a233e82021-05-27 04:08:50 +0000194 environment {
195 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
196 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
197 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
198 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
199 }
200 steps {
201 sh """
202 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000203 if [ ${params.enableMultiUni} = false ]; then
204 if ( ${powerSwitch} ); then
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000205 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 +0000206 else
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000207 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"
208 fi
209 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
210 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
211 fi
212 """
213 }
214 }
215
216 stage('Multicast Tests') {
217 environment {
218 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
219 ROBOT_FILE="Voltha_TT_MulticastTests.robot"
220 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
221 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
222 }
223 steps {
224 sh """
225 mkdir -p $ROBOT_LOGS_DIR
226 if [ ${params.enableMultiUni} = true ]; then
227 if ( ${powerSwitch} ); then
228 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"
229 else
230 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 +0000231 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000232 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000233 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000234 fi
235 """
236 }
237 }
238
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700239 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700240 post {
241 always {
Hardik Windlassceb56312021-07-21 16:12:25 +0000242 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700243 sh returnStdout: false, script: '''
244 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700245
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700246 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700247 cd $WORKSPACE
248 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200249 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -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 ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
Girish Gowdra1cdfeb52021-10-28 15:12:45 -0700256 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 +0100257 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 -0700258 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 +0100259 """
260 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700261 }
262 }
263 step([$class: 'RobotPublisher',
264 disableArchiveOutput: false,
265 logFileName: '**/log*.html',
266 otherFiles: '',
267 outputFileName: '**/output*.xml',
268 outputPath: 'RobotLogs',
269 passThreshold: 100,
270 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200271 unstableThreshold: 0,
272 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700273 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700274 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700275 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700276 }
277}
Joey Armstrong56fdfec2024-03-01 13:43:36 -0500278
279// [EOF]