blob: c92d747c57ab1534fa52d7bf96df898c793f564d [file] [log] [blame]
Joey Armstrongbeef4cd2023-01-18 09:59:58 -05001// -*- groovy -*-
2// -----------------------------------------------------------------------
3// Copyright 2017-2023 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') {
182 environment {
183 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
184 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
185 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
186 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
187 }
188 steps {
189 sh """
190 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000191 if [ ${params.enableMultiUni} = false ]; then
192 if ( ${powerSwitch} ); then
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000193 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 +0000194 else
Hardik Windlass5f1cd3b2021-11-16 04:19:24 +0000195 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"
196 fi
197 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
198 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
199 fi
200 """
201 }
202 }
203
204 stage('Multicast Tests') {
205 environment {
206 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
207 ROBOT_FILE="Voltha_TT_MulticastTests.robot"
208 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MulticastTests"
209 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multicast-tests-input.yaml"
210 }
211 steps {
212 sh """
213 mkdir -p $ROBOT_LOGS_DIR
214 if [ ${params.enableMultiUni} = true ]; then
215 if ( ${powerSwitch} ); then
216 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"
217 else
218 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 +0000219 fi
Andrea Campanella79ced322021-11-03 17:24:26 +0000220 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000221 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000222 fi
223 """
224 }
225 }
226
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700227 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700228 post {
229 always {
Hardik Windlassceb56312021-07-21 16:12:25 +0000230 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700231 sh returnStdout: false, script: '''
232 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700233
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700234 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700235 cd $WORKSPACE
236 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200237 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700238 '''
239 script {
240 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100241 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
242 sh returnStdout: false, script: """
243 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 -0700244 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 +0100245 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 -0700246 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 +0100247 """
248 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700249 }
250 }
251 step([$class: 'RobotPublisher',
252 disableArchiveOutput: false,
253 logFileName: '**/log*.html',
254 otherFiles: '',
255 outputFileName: '**/output*.xml',
256 outputPath: 'RobotLogs',
257 passThreshold: 100,
258 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200259 unstableThreshold: 0,
260 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700261 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700262 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700263 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700264 }
265}