blob: 40b61fa12b0bb134ecb23c1ac5356e1a23ca2fe5 [file] [log] [blame]
Joey Armstrong16bd8e82023-01-12 15:20:06 -05001#!/usr/bin/env groovy
2// -----------------------------------------------------------------------
3// Copyright 2021-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 Armstrong16bd8e82023-01-12 15:20:06 -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 Windlass806505d2021-10-27 08:15:48 +000029def volthaNamespace = "voltha"
30def infraNamespace = "infra"
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"
43 VOLTCONFIG="$HOME/.volt/config-minimal"
44 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 }
99 stage ('Initialize') {
100 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +0000101 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700102 script {
103 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
104 }
Hardik Windlass9658cd22021-10-25 11:13:25 +0000105 installVoltctl("${branch}")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700106 sh returnStdout: false, script: """
Joey Armstrong16bd8e82023-01-12 15:20:06 -0500107 mkdir -p "$WORKSPACE/bin"
108
109 # install kail
110 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200111
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700112 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
113 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
114 # We should change this. In the meantime here is a workaround.
115 if [ "${params.branch}" == "master" ]; then
116 set +e
117
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700118 # Remove noise from voltha-core logs
119 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
120 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
121 # Remove noise from openolt logs
122 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
123 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
124 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
125 fi
126 """
127 }
128 }
129
130 stage('Functional Tests') {
131 environment {
132 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
133 ROBOT_FILE="Voltha_TT_PODTests.robot"
134 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
135 }
136 steps {
137 sh """
Joey Armstrong16bd8e82023-01-12 15:20:06 -0500138 mkdir -p "$ROBOT_LOGS_DIR"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700139 if ( ${powerSwitch} ); then
Hardik Windlass44461ee2021-05-26 07:19:53 +0000140 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}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700141 else
Hardik Windlass44461ee2021-05-26 07:19:53 +0000142 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 -0700143 fi
Hardik Windlass806505d2021-10-27 08:15:48 +0000144 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700145 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700146 """
147 }
148 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530149
150 stage('Failure/Recovery Tests') {
151 environment {
152 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
153 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
154 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
155 }
156 steps {
157 sh """
158 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000159 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000160 if ( ${powerSwitch} ); then
161 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}"
162 else
163 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}"
164 fi
Hardik Windlass806505d2021-10-27 08:15:48 +0000165 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass6598b032021-07-02 10:12:01 +0000166 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530167 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530168 """
169 }
170 }
171
Hardik Windlass6a233e82021-05-27 04:08:50 +0000172 stage('Multi-Tcont Tests') {
173 environment {
174 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
175 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
176 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
177 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
178 }
179 steps {
180 sh """
181 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000182 if [ ${params.enableMultiUni} = false ]; then
183 if ( ${powerSwitch} ); then
184 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} -V $ROBOT_TEST_INPUT_FILE"
185 else
186 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} -V $ROBOT_TEST_INPUT_FILE"
Hardik Windlass6598b032021-07-02 10:12:01 +0000187 fi
Hardik Windlass806505d2021-10-27 08:15:48 +0000188 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000189 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000190 fi
191 """
192 }
193 }
194
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700195 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700196 post {
197 always {
Hardik Windlassceb56312021-07-21 16:12:25 +0000198 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700199 sh returnStdout: false, script: '''
200 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700201
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700202 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700203 cd $WORKSPACE
204 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200205 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700206 '''
207 script {
208 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100209 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
210 sh returnStdout: false, script: """
211 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
212 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 -0700213 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
214 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 +0100215 """
216 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700217 }
218 }
219 step([$class: 'RobotPublisher',
220 disableArchiveOutput: false,
221 logFileName: '**/log*.html',
222 otherFiles: '',
223 outputFileName: '**/output*.xml',
224 outputPath: 'RobotLogs',
225 passThreshold: 100,
226 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200227 unstableThreshold: 0,
228 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700229 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700230 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700231 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700232 }
233}