blob: 05e0902fbb191189c93f3febdde2dea168e79587 [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
26pipeline {
27 /* no label, executor is determined by JJB */
28 agent {
29 label "${params.buildNode}"
30 }
31 options {
Hardik Windlassd0f01662021-09-03 08:07:15 +000032 timeout(time: "${timeout}", unit: 'MINUTES')
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070033 }
34
35 environment {
36 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
37 VOLTCONFIG="$HOME/.volt/config-minimal"
38 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
39 }
40
41 stages {
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070042 stage('Clone voltha-system-tests') {
43 steps {
Matteo Scandolo67842812021-07-13 16:52:13 -070044 step([$class: 'WsCleanup'])
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070045 checkout([
46 $class: 'GitSCM',
47 userRemoteConfigs: [[
48 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000049 refspec: "${volthaSystemTestsChange}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070050 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000051 branches: [[ name: "${branch}", ]],
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070052 extensions: [
53 [$class: 'WipeWorkspace'],
54 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
55 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
56 ],
57 ])
Suchitra Vemuria38e5412021-02-23 15:28:28 -080058 script {
59 sh(script:"""
60 if [ '${volthaSystemTestsChange}' != '' ] ; then
61 cd $WORKSPACE/voltha-system-tests;
62 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
63 fi
64 """)
65 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070066 }
67 }
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070068 stage ('Initialize') {
69 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000070 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070071 script {
72 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
73 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070074 sh returnStdout: false, script: """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070075 mkdir -p $WORKSPACE/bin
76 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
77 cd $WORKSPACE
Hardik Windlass6f854a12021-07-12 13:20:21 +000078 if [ "${params.branch}" == "voltha-2.8" ]; then
Hardik Windlasse2175102021-07-23 08:34:32 +000079 VOLTCTL_VERSION=1.6.11
Suchitra Vemuri13421432020-06-05 17:34:33 -070080 else
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070081 VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
Suchitra Vemuri13421432020-06-05 17:34:33 -070082 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070083
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070084 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
85 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
86 if [ \$HOSTARCH == "x86_64" ]; then
87 HOSTARCH="amd64"
88 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -070089 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH}
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -070090 chmod 755 $WORKSPACE/bin/voltctl
91 voltctl version --clientonly
Andrea Campanella9b234332020-04-24 12:22:18 +020092
Matteo Scandolo3fbb0652020-07-22 08:50:02 -070093
Andrea Campanella9b234332020-04-24 12:22:18 +020094 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
95 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
96 # We should change this. In the meantime here is a workaround.
Suchitra Vemuri13421432020-06-05 17:34:33 -070097 if [ "${params.branch}" == "master" ]; then
98 set +e
Andrea Campanella9b234332020-04-24 12:22:18 +020099
Andrea Campanella9b234332020-04-24 12:22:18 +0200100
101 # Remove noise from voltha-core logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700102 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
103 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Andrea Campanella9b234332020-04-24 12:22:18 +0200104 # Remove noise from openolt logs
Suchitra Vemuria2a7f2c2020-06-08 14:05:06 -0700105 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
106 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
107 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
Suchitra Vemuri13421432020-06-05 17:34:33 -0700108 fi
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700109 """
110 }
111 }
112
113 stage('Functional Tests') {
114 environment {
Suchitra Vemurie4a5bcc2020-03-16 12:43:03 -0700115 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700116 ROBOT_FILE="Voltha_DT_PODTests.robot"
Andrea Campanellad924ce22020-04-20 16:40:41 +0200117 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700118 }
119 steps {
120 sh """
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700121 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri627786a2020-06-18 16:52:05 -0700122 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100123 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 -0700124 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100125 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 -0700126 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700127 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700128 """
129 }
130 }
Andrea Campanellad924ce22020-04-20 16:40:41 +0200131
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200132 stage('Failure/Recovery Tests') {
133 environment {
134 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
135 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
136 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
137 }
138 steps {
139 sh """
140 mkdir -p $ROBOT_LOGS_DIR
141 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100142 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 +0200143 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100144 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 +0200145 fi
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700146 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andrea Campanellaf47a1982020-04-21 11:53:31 +0200147 """
148 }
149 }
150
Andy Bavier5ad87c92020-05-11 16:31:35 -0700151 stage('Dataplane Tests') {
152 environment {
Andy Bavier1541da82020-05-15 09:41:38 -0700153 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Andy Bavier5ad87c92020-05-11 16:31:35 -0700154 ROBOT_FILE="Voltha_DT_PODTests.robot"
155 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
156 }
157 steps {
158 sh """
159 mkdir -p $ROBOT_LOGS_DIR
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100160 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}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700161 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Andy Bavier5ad87c92020-05-11 16:31:35 -0700162 """
163 }
164 }
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700165 stage('HA Tests') {
166 environment {
167 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
168 ROBOT_FILE="Voltha_ONOSHATests.robot"
169 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
170 }
171 steps {
Matteo Scandolo67842812021-07-13 16:52:13 -0700172 sh """
173 mkdir -p $ROBOT_LOGS_DIR
174 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}"
175 make -C $WORKSPACE/voltha-system-tests voltha-test || true
176 """
Suchitra Vemuri5e8e7892020-09-14 16:04:12 -0700177 }
178 }
Andy Bavier5ad87c92020-05-11 16:31:35 -0700179
Suchitra Vemuri0a9c8c62020-12-07 18:24:31 -0800180 stage('Multiple OLT Tests') {
181 environment {
182 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
183 ROBOT_FILE="Voltha_DT_MultiOLT_Tests.robot"
184 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/MultipleOLTScenarios"
185 }
186 steps {
187 sh """
188 mkdir -p $ROBOT_LOGS_DIR
189 if ( ${powerSwitch} ); then
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100190 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 -0800191 else
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100192 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 -0800193 fi
194 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
195 """
196 }
197 }
198
199
Andrea Campanellad924ce22020-04-20 16:40:41 +0200200 stage('Error Scenario Tests') {
201 environment {
202 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
203 ROBOT_FILE="Voltha_ErrorScenarios.robot"
204 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
205 }
206 steps {
207 sh """
208 mkdir -p $ROBOT_LOGS_DIR
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100209 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}"
Matteo Scandolo3dce2a12020-09-15 14:21:14 -0700210 make -C $WORKSPACE/voltha-system-tests voltha-test || true
Andrea Campanellad924ce22020-04-20 16:40:41 +0200211 """
212 }
Andrea Campanella71666372020-04-21 10:56:17 +0200213 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700214 }
215 post {
216 always {
217 sh returnStdout: false, script: '''
218 set +e
Matteo Scandolo97b12572020-04-13 12:44:46 -0700219 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
220 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700221 kubectl get nodes -o wide
222 kubectl get pods -n voltha -o wide
Suchitra Vemuri179643b2020-11-02 10:06:20 -0800223 kubectl get pods -o wide
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700224
Andrea Campanellaa20a9332021-03-09 09:18:42 +0100225 # store information on running charts
226 helm ls > $WORKSPACE/helm-list.txt || true
227
228 # store information on the running pods
Andrea Campanellae0c839f2021-03-16 17:53:40 +0100229 kubectl get pods --all-namespaces -o wide > $WORKSPACE/pods.txt || true
Andrea Campanellaa20a9332021-03-09 09:18:42 +0100230 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $WORKSPACE/pod-images.txt || true
231 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 -0700232 '''
233 script {
234 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100235 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
236 sh returnStdout: false, script: """
237 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
238 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
239 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
240 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
241 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
242 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
243 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
244 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
245 """
246 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700247 }
248 }
249 step([$class: 'RobotPublisher',
250 disableArchiveOutput: false,
251 logFileName: '**/log*.html',
252 otherFiles: '',
253 outputFileName: '**/output*.xml',
254 outputPath: 'RobotLogs',
255 passThreshold: 100,
256 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200257 unstableThreshold: 0,
258 onlyCritical: true
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700259 ]);
Matteo Scandolo67842812021-07-13 16:52:13 -0700260 archiveArtifacts artifacts: '**/*.log,**/*.tgz,*.txt'
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700261 }
Suchitra Vemuri8d180ab2020-03-12 17:38:24 -0700262 }
263}