blob: 1eacba97eb06b17cb65537ebe25628b100251d56 [file] [log] [blame]
Joey Armstrong7adbfb02023-01-24 17:02:37 -05001// -*- groovy -*-
2// -----------------------------------------------------------------------
3// Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
4//
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.
16// -----------------------------------------------------------------------
17
18library identifier: 'cord-jenkins-libraries@master',
19 retriever: modernSCM([
20 $class: 'GitSCMSource',
21 remote: 'https://gerrit.opencord.org/ci-management.git'
22])
23
24node {
25 // Need this so that deployment_config has global scope when it's read later
26 deployment_config = null
27}
28
29def infraNamespace = "infra"
30def volthaNamespace = "voltha"
31
32pipeline {
33 /* no label, executor is determined by JJB */
34 agent {
35 label "${params.buildNode}"
36 }
37 options {
38 timeout(time: "${timeout}", unit: 'MINUTES')
39 }
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 {
48 stage('Clone voltha-system-tests') {
49 steps {
50 step([$class: 'WsCleanup'])
51 checkout([
52 $class: 'GitSCM',
53 userRemoteConfigs: [[
54 url: "https://gerrit.opencord.org/voltha-system-tests",
55 refspec: "${volthaSystemTestsChange}"
56 ]],
57 branches: [[ name: "${branch}", ]],
58 extensions: [
59 [$class: 'WipeWorkspace'],
60 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
61 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
62 ],
63 ])
64 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 }
72 }
73 }
74 // 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 {
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
109 installVoltctl("${branch}")
110
111 sh returnStdout: false, script: """
112 mkdir -p "$WORKSPACE/bin"
113
114 # install kail
115 make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
116
117 # 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 """
144 mkdir -p $ROBOT_LOGS_DIR
145 if ( ${powerSwitch} ); then
146 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}"
147 if ( ${powerCycleOlt} ); then
148 ROBOT_MISC_ARGS+=" -v power_cycle_olt:True"
149 fi
150 else
151 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}"
152 fi
153 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
154 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
155 """
156 }
157 }
158
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
168 if [ ${params.enableMultiUni} = false ]; then
169 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
174 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
175 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
176 fi
177 """
178 }
179 }
180
181 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
191 if [ ${params.enableMultiUni} = false ]; then
192 if ( ${powerSwitch} ); then
193 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"
194 else
195 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"
219 fi
220 ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
221 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
222 fi
223 """
224 }
225 }
226
227 }
228 post {
229 always {
230 getPodsInfo("$WORKSPACE/pods")
231 sh returnStdout: false, script: '''
232 set +e
233
234 # collect logs collected in the Robot Framework StartLogging keyword
235 cd $WORKSPACE
236 gzip *-combined.log || true
237 rm *-combined.log || true
238 '''
239 script {
240 deployment_config.olts.each { olt ->
241 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
244 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
245 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
246 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
247 """
248 }
249 }
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',
259 unstableThreshold: 0,
260 onlyCritical: true
261 ]);
262 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
263 }
264 }
265}