blob: 369808a9e1458177d8e8d2d7ed96277d3b0b65a5 [file] [log] [blame]
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -07001// Copyright 2017-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Matteo Scandolo0d0f2902021-07-15 16:16:33 -070015library identifier: 'cord-jenkins-libraries@master',
16 retriever: modernSCM([
17 $class: 'GitSCMSource',
18 remote: 'https://gerrit.opencord.org/ci-management.git'
19])
20
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070021node {
22 // Need this so that deployment_config has global scope when it's read later
23 deployment_config = null
24}
25
Hardik Windlass806505d2021-10-27 08:15:48 +000026def infraNamespace = "infra"
27def volthaNamespace = "voltha"
28
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070029pipeline {
30 /* no label, executor is determined by JJB */
31 agent {
32 label "${params.buildNode}"
33 }
34 options {
Hardik Windlassd0f01662021-09-03 08:07:15 +000035 timeout(time: "${timeout}", unit: 'MINUTES')
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070036 }
37
38 environment {
39 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
40 VOLTCONFIG="$HOME/.volt/config-minimal"
41 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
42 }
43
44 stages {
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070045 stage('Clone voltha-system-tests') {
46 steps {
Matteo Scandolo67842812021-07-13 16:52:13 -070047 step([$class: 'WsCleanup'])
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070048 checkout([
49 $class: 'GitSCM',
50 userRemoteConfigs: [[
51 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000052 refspec: "${volthaSystemTestsChange}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070053 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000054 branches: [[ name: "${branch}", ]],
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070055 extensions: [
56 [$class: 'WipeWorkspace'],
57 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
58 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
59 ],
60 ])
Suchitra Vemuria38e5412021-02-23 15:28:28 -080061 script {
62 sh(script:"""
63 if [ '${volthaSystemTestsChange}' != '' ] ; then
64 cd $WORKSPACE/voltha-system-tests;
65 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
66 fi
67 """)
68 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070069 }
70 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070071 stage ('Initialize') {
72 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000073 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070074 script {
75 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
76 }
Hardik Windlass9658cd22021-10-25 11:13:25 +000077 installVoltctl("${branch}")
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070078 sh returnStdout: false, script: """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070079 mkdir -p $WORKSPACE/bin
Hardik Windlass9658cd22021-10-25 11:13:25 +000080 # download kail
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070081 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
Matteo Scandolo3fbb0652020-07-22 08:50:02 -070082
Andrea Campanella9b234332020-04-24 12:22:18 +020083 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
84 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
85 # We should change this. In the meantime here is a workaround.
Suchitra Vemuri13421432020-06-05 17:34:33 -070086 if [ "${params.branch}" == "master" ]; then
87 set +e
Andrea Campanella9b234332020-04-24 12:22:18 +020088
Andrea Campanella9b234332020-04-24 12:22:18 +020089
90 # Remove noise from voltha-core logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -070091 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
92 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Andrea Campanella9b234332020-04-24 12:22:18 +020093 # Remove noise from openolt logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -070094 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
95 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
96 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Suchitra Vemuri13421432020-06-05 17:34:33 -070097 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070098 """
99 }
100 }
101
102 stage('Functional Tests') {
103 environment {
Suchitra Vemurie4a5bcc2020-03-16 12:43:03 -0700104 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700105 ROBOT_FILE="Voltha_DT_PODTests.robot"
Andrea Campanellad924ce22020-04-20 16:40:41 +0200106 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700107 }
108 steps {
109 sh """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700110 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700111 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100112 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanityDt -i functionalDt -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 Vemuri627786a2020-06-18 16:52:05 -0700113 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100114 export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanityDt -i functionalDt -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 Vemuri627786a2020-06-18 16:52:05 -0700115 fi
Hardik Windlass806505d2021-10-27 08:15:48 +0000116 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700117 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700118 """
119 }
120 }
Andrea Campanellad924ce22020-04-20 16:40:41 +0200121
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200122 stage('Failure/Recovery Tests') {
123 environment {
124 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
125 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
126 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
127 }
128 steps {
129 sh """
130 mkdir -p $ROBOT_LOGS_DIR
131 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100132 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalDt -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}"
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200133 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100134 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalDt -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}"
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200135 fi
Hardik Windlass806505d2021-10-27 08:15:48 +0000136 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700137 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200138 """
139 }
140 }
141
Andy Bavier5ad87c92020-05-11 16:31:35 -0700142 stage('Dataplane Tests') {
143 environment {
Andy Bavier1541da82020-05-15 09:41:38 -0700144 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Andy Bavier5ad87c92020-05-11 16:31:35 -0700145 ROBOT_FILE="Voltha_DT_PODTests.robot"
146 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
147 }
148 steps {
149 sh """
150 mkdir -p $ROBOT_LOGS_DIR
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100151 export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplaneDt -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 Windlass806505d2021-10-27 08:15:48 +0000152 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700153 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andy Bavier5ad87c92020-05-11 16:31:35 -0700154 """
155 }
156 }
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700157 stage('HA Tests') {
158 environment {
159 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
160 ROBOT_FILE="Voltha_ONOSHATests.robot"
161 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
162 }
163 steps {
Matteo Scandolo67842812021-07-13 16:52:13 -0700164 sh """
165 mkdir -p $ROBOT_LOGS_DIR
166 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Hardik Windlass806505d2021-10-27 08:15:48 +0000167 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Matteo Scandolo67842812021-07-13 16:52:13 -0700168 make -C $WORKSPACE/voltha-system-tests voltha-test || true
169 """
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700170 }
171 }
Andy Bavier5ad87c92020-05-11 16:31:35 -0700172
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800173 stage('Multiple OLT Tests') {
174 environment {
175 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
176 ROBOT_FILE="Voltha_DT_MultiOLT_Tests.robot"
177 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/MultipleOLTScenarios"
178 }
179 steps {
180 sh """
181 mkdir -p $ROBOT_LOGS_DIR
182 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100183 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalDt -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}"
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800184 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100185 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalDt -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}"
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800186 fi
Hardik Windlass806505d2021-10-27 08:15:48 +0000187 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800188 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
189 """
190 }
191 }
192
193
Andrea Campanellad924ce22020-04-20 16:40:41 +0200194 stage('Error Scenario Tests') {
195 environment {
196 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
197 ROBOT_FILE="Voltha_ErrorScenarios.robot"
198 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
199 }
200 steps {
201 sh """
202 mkdir -p $ROBOT_LOGS_DIR
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100203 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Hardik Windlass806505d2021-10-27 08:15:48 +0000204 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700205 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Andrea Campanellad924ce22020-04-20 16:40:41 +0200206 """
207 }
Andrea Campanella71666372020-04-21 10:56:17 +0200208 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700209 }
210 post {
211 always {
212 sh returnStdout: false, script: '''
213 set +e
Matteo Scandolo97b12572020-04-13 12:44:46 -0700214 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
215 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700216 kubectl get nodes -o wide
217 kubectl get pods -n voltha -o wide
Suchitra Vemuri179643b2020-11-02 10:06:20 -0800218 kubectl get pods -o wide
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700219
Andrea Campanellaa20a9332021-03-09 09:18:42 +0100220 # store information on running charts
221 helm ls > $WORKSPACE/helm-list.txt || true
222
223 # store information on the running pods
Andrea Campanellae0c839f2021-03-16 17:53:40 +0100224 kubectl get pods --all-namespaces -o wide > $WORKSPACE/pods.txt || true
Andrea Campanellaa20a9332021-03-09 09:18:42 +0100225 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $WORKSPACE/pod-images.txt || true
226 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee $WORKSPACE/pod-imagesId.txt || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700227 '''
228 script {
229 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100230 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
231 sh returnStdout: false, script: """
232 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
233 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
234 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
235 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
236 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/startup.log $WORKSPACE/startup-${olt.sship}.log || true
237 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
238 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt_process_watchdog.log $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true
239 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
240 """
241 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700242 }
243 }
244 step([$class: 'RobotPublisher',
245 disableArchiveOutput: false,
246 logFileName: '**/log*.html',
247 otherFiles: '',
248 outputFileName: '**/output*.xml',
249 outputPath: 'RobotLogs',
250 passThreshold: 100,
251 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200252 unstableThreshold: 0,
253 onlyCritical: true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700254 ]);
Matteo Scandolo67842812021-07-13 16:52:13 -0700255 archiveArtifacts artifacts: '**/*.log,**/*.tgz,*.txt'
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700256 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700257 }
258}