blob: 4850e20321dc1c8f8a24a76b805053fae838e11f [file] [log] [blame]
Joey Armstrong8c6f6482023-01-12 12:31:44 -05001// Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors
Matteo Scandolo42f6e572021-01-25 15:11:34 -08002//
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
Hardik Windlassec9341b2021-06-07 11:58:29 +000015// voltha-2.x e2e tests for openonu-go
Matteo Scandolo42f6e572021-01-25 15:11:34 -080016// uses bbsim to simulate OLT/ONUs
17
Joey Armstronge5aae1c2023-07-24 14:11:20 -040018// [TODO] Update syntax below to the latest supported
Matteo Scandoloa156b572021-02-04 11:52:18 -080019library identifier: 'cord-jenkins-libraries@master',
20 retriever: modernSCM([
21 $class: 'GitSCMSource',
22 remote: 'https://gerrit.opencord.org/ci-management.git'
23])
24
Joey Armstronge5aae1c2023-07-24 14:11:20 -040025//------------------//
26//---] GLOBAL [---//
27//------------------//
Joey Armstrongb65ada32023-08-03 12:50:20 -040028String clusterName = 'kind-ci' // was def
Joey Armstrongf076c312023-08-01 17:17:10 -040029
30// -----------------------------------------------------------------------
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040031// Intent:
Joey Armstrongf076c312023-08-01 17:17:10 -040032// -----------------------------------------------------------------------
Joey Armstrongb65ada32023-08-03 12:50:20 -040033String branchName() {
Joey Armstrongf076c312023-08-01 17:17:10 -040034 String name = 'master'
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040035
36 // [TODO] Sanity check the target branch
37 // if (name != jenkins.branch) { fatal }
Joey Armstrongf076c312023-08-01 17:17:10 -040038 return(name)
39}
Hardik Windlassec9341b2021-06-07 11:58:29 +000040
Joey Armstronge5aae1c2023-07-24 14:11:20 -040041// -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -040042// Intent: Due to lack of a reliable stack trace, construct a literal.
43// Jenkins will re-write the call stack for serialization.
44// -----------------------------------------------------------------------
Joey Armstrong97a8b882023-08-02 16:08:52 -040045String getIam(String func) {
Joey Armstrongb65ada32023-08-03 12:50:20 -040046 String branchName = branchName()
Joey Armstrong06a68372023-07-24 16:37:16 -040047 String src = [
48 'ci-management',
49 'jjb',
50 'pipeline',
51 'voltha',
Joey Armstrongb65ada32023-08-03 12:50:20 -040052 branchName,
Joey Armstrong06a68372023-07-24 16:37:16 -040053 'bbsim-tests.groovy'
54 ].join('/')
55
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040056 String name = [src, func].join('::')
57 return(name)
Joey Armstrong06a68372023-07-24 16:37:16 -040058}
59
60// -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -040061// Intent: Determine if working on a release branch.
62// Note: Conditional is legacy, should also check for *-dev or *-pre
63// -----------------------------------------------------------------------
64Boolean isReleaseBranch(String name)
65{
66 // List modifiers = ['-dev', '-pre', 'voltha-x.y.z-pre']
Joey Armstrongb65ada32023-08-03 12:50:20 -040067 // if branchName in modifiers
68 return(name != 'master') // OR branchName.contains('-')
Joey Armstronge5aae1c2023-07-24 14:11:20 -040069}
70
71// -----------------------------------------------------------------------
72// Intent:
73// -----------------------------------------------------------------------
Joey Armstrongb65ada32023-08-03 12:50:20 -040074void execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags='')
Joey Armstrong2d5a7c12023-04-13 09:37:42 -040075{
Joey Armstrongb65ada32023-08-03 12:50:20 -040076 String infraNamespace = 'default'
77 String volthaNamespace = 'voltha'
78 String logsDir = "$WORKSPACE/${testTarget}"
Joey Armstrong293e16b2022-11-26 20:16:33 -050079
80 stage('IAM')
81 {
Joey Armstrong84adc542023-04-11 14:47:34 -040082 script
83 {
Joey Armstrong97a8b882023-08-02 16:08:52 -040084 // Announce ourselves for log usability
Joey Armstrongf404b642023-08-04 14:39:13 -040085 String iam = getIam('execute_test')
Joey Armstrong97a8b882023-08-02 16:08:52 -040086 println("${iam}: ENTER")
87 println("${iam}: LEAVE")
Joey Armstrong84adc542023-04-11 14:47:34 -040088 }
Joey Armstrong293e16b2022-11-26 20:16:33 -050089 }
Joey Armstrongb65ada32023-08-03 12:50:20 -040090
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040091 // -----------------------------------------------------------------------
Joey Armstrong268442d2023-08-22 17:16:10 -040092 // Intent: Cleanup stale port-forwarding
Joey Armstrong0e0a42b2023-08-02 21:04:21 -040093 // -----------------------------------------------------------------------
Joey Armstrongf076c312023-08-01 17:17:10 -040094 stage('Cleanup')
95 {
Joey Armstrong84adc542023-04-11 14:47:34 -040096 if (teardown) {
97 timeout(15) {
98 script {
Joey Armstrongb65ada32023-08-03 12:50:20 -040099 helmTeardown(['default', infraNamespace, volthaNamespace])
Joey Armstrong84adc542023-04-11 14:47:34 -0400100 }
101 timeout(1) {
102 sh returnStdout: false, script: '''
Hardik Windlassec9341b2021-06-07 11:58:29 +0000103 # remove orphaned port-forward from different namespaces
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400104 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9
Hardik Windlassec9341b2021-06-07 11:58:29 +0000105 '''
Joey Armstrong84adc542023-04-11 14:47:34 -0400106 }
107 }
108 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000109 }
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500110
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400111 // -----------------------------------------------------------------------
112 // -----------------------------------------------------------------------
Joey Armstrong06a68372023-07-24 16:37:16 -0400113 stage('Deploy common infrastructure')
114 {
Joey Armstrong84adc542023-04-11 14:47:34 -0400115 sh '''
Hardik Windlasse1660492022-03-14 15:12:46 +0000116 helm repo add onf https://charts.opencord.org
117 helm repo update
118 if [ ${withMonitoring} = true ] ; then
119 helm install nem-monitoring onf/nem-monitoring \
120 --set prometheus.alertmanager.enabled=false,prometheus.pushgateway.enabled=false \
121 --set kpi_exporter.enabled=false,dashboards.xos=false,dashboards.onos=false,dashboards.aaa=false,dashboards.voltha=false
122 fi
123 '''
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500124 }
125
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400126 stage('Deploy Voltha')
127 {
Joey Armstrong97a8b882023-08-02 16:08:52 -0400128 if (teardown)
129 {
130 timeout(10)
131 {
132 script
133 {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000134 sh """
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700135 mkdir -p ${logsDir}
136 _TAG=kail-startup kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
Hardik Windlassec9341b2021-06-07 11:58:29 +0000137 """
138
Joey Armstrong54dec092023-08-03 18:21:38 -0400139 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
140 Boolean localCharts = false
Joey Armstrongf404b642023-08-04 14:39:13 -0400141
Joey Armstrong54dec092023-08-03 18:21:38 -0400142 if (volthaHelmChartsChange != ''
143 || gerritProject == 'voltha-helm-charts'
144 || isReleaseBranch(branch) // branch != 'master'
145 ) {
146 localCharts = true
147 }
Joey Armstrongf404b642023-08-04 14:39:13 -0400148
Joey Armstrong8a960ee2023-08-03 15:00:00 -0400149 String branchName = branchName()
150 Boolean is_release = isReleaseBranch(branch)
151 println([
152 " ** localCharts=${localCharts}",
153 "branchName=${branchName}",
154 "branch=${branch}",
155 "branch=isReleaseBranch=${is_release}",
156 ].join(', '))
Hardik Windlassec9341b2021-06-07 11:58:29 +0000157
Joey Armstrong8a960ee2023-08-03 15:00:00 -0400158 // -----------------------------------------------------------------------
159 // Rewrite localHelmFlags using array join, moving code around and
Joey Armstrongf404b642023-08-04 14:39:13 -0400160 // refactoring into standalone functions
Joey Armstrong8a960ee2023-08-03 15:00:00 -0400161 // -----------------------------------------------------------------------
162 // hudson.remoting.ProxyException: groovy.lang.MissingMethodException:
163 // No signature of method: java.lang.String.positive() is applicable for argument types: () values: []
164 // -----------------------------------------------------------------------
165 // NOTE temporary workaround expose ONOS node ports
166 // -----------------------------------------------------------------------
167 String localHelmFlags = [
168 extraHelmFlags.trim(),
169 "--set global.log_level=${logLevel.toUpperCase()}",
170 '--set onos-classic.onosSshPort=30115',
171 '--set onos-classic.onosApiPort=30120',
172 '--set onos-classic.onosOfPort=31653',
173 '--set onos-classic.individualOpenFlowNodePorts=true',
174 testSpecificHelmFlags
175 ].join(' ')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800176
Joey Armstrong28e86ee2023-08-03 15:22:29 -0400177 println("** localHelmFlags = ${localHelmFlags}")
178
Joey Armstrong8a960ee2023-08-03 15:00:00 -0400179 if (gerritProject != '') {
180 localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
181 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000182
Joey Armstrong8a960ee2023-08-03 15:00:00 -0400183 println('volthaDeploy: ENTER')
184 volthaDeploy([
185 infraNamespace: infraNamespace,
186 volthaNamespace: volthaNamespace,
187 workflow: workflow.toLowerCase(),
188 withMacLearning: enableMacLearning.toBoolean(),
189 extraHelmFlags: localHelmFlags,
190 localCharts: localCharts,
191 bbsimReplica: olts.toInteger(),
192 dockerRegistry: registry,
Joey Armstrong54dec092023-08-03 18:21:38 -0400193 ])
Joey Armstrong8a960ee2023-08-03 15:00:00 -0400194 println('volthaDeploy: LEAVE')
Joey Armstrongb65ada32023-08-03 12:50:20 -0400195 } // script
Matteo Scandolofcfc60d2021-02-24 09:06:48 -0800196
Joey Armstrong97a8b882023-08-02 16:08:52 -0400197 // -----------------------------------------------------------------------
198 // Intent: Replacing P_IDS with pgrep/pkill is a step forward.
199 // Why not simply use a pid file, capture _TAG=kail-startup above
200 // Grep runs the risk of terminating stray commands (??-good <=> bad-??)
Joey Armstrongb65ada32023-08-03 12:50:20 -0400201 // -----------------------------------------------------------------------
202 script {
203 println('Try out pgrep/pkill commands')
Joey Armstrongf404b642023-08-04 14:39:13 -0400204 sh('''pgrep --list-full kail-startup || true''')
Joey Armstrongb65ada32023-08-03 12:50:20 -0400205 }
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400206
Joey Armstrong97a8b882023-08-02 16:08:52 -0400207 // -----------------------------------------------------------------------
Joey Armstrong38a87832023-08-23 17:02:50 -0400208 // stop logging
Joey Armstrong97a8b882023-08-02 16:08:52 -0400209 // -----------------------------------------------------------------------
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700210 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000211 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
212 if [ -n "\$P_IDS" ]; then
213 echo \$P_IDS
214 for P_ID in \$P_IDS; do
215 kill -9 \$P_ID
216 done
217 fi
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700218 cd ${logsDir}
Hardik Windlassec9341b2021-06-07 11:58:29 +0000219 gzip -k onos-voltha-startup-combined.log
220 rm onos-voltha-startup-combined.log
Matteo Scandolod17de3a2021-04-09 15:47:52 -0700221 """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000222 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400223
224 sh """
Hardik Windlassec9341b2021-06-07 11:58:29 +0000225 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
226 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-etcd" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd 2379:2379; done"&
227 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-kafka" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
228 bbsimDmiPortFwd=50075
229 for i in {0..${olts.toInteger() - 1}}; do
230 JENKINS_NODE_COOKIE="dontKillMe" _TAG="bbsim\${i}" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/bbsim\${i} \${bbsimDmiPortFwd}:50075; done"&
231 ((bbsimDmiPortFwd++))
232 done
Hardik Windlass3bb089a2022-03-22 17:56:03 +0000233 if [ ${withMonitoring} = true ] ; then
234 JENKINS_NODE_COOKIE="dontKillMe" _TAG="nem-monitoring-prometheus-server" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n default svc/nem-monitoring-prometheus-server 31301:80; done"&
235 fi
Hardik Windlassec9341b2021-06-07 11:58:29 +0000236 ps aux | grep port-forward
237 """
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500238
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400239 // setting ONOS log level
240 script
Joey Armstrongf404b642023-08-04 14:39:13 -0400241 {
Joey Armstrongb65ada32023-08-03 12:50:20 -0400242 println('** setOnosLogLevels: ENTER')
243 setOnosLogLevels([
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400244 onosNamespace: infraNamespace,
245 apps: [
246 'org.opencord.dhcpl2relay',
247 'org.opencord.olt',
248 'org.opencord.aaa',
249 'org.opencord.maclearner',
250 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
251 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
252 ],
253 logLevel: logLevel
254 ])
Joey Armstrongb65ada32023-08-03 12:50:20 -0400255 println('** setOnosLogLevels: LEAVE')
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400256 } // script
257 } // if (teardown)
258 } // stage('Deploy Voltha')
259
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400260 // -----------------------------------------------------------------------
261 // -----------------------------------------------------------------------
Joey Armstrongfd896522023-08-04 13:30:48 -0400262 stage("Run test ${testTarget} on workflow ${workflow}")
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400263 {
264 sh """
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400265 echo -e '** Monitor memory consumption: ENTER'
266
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000267 if [ ${withMonitoring} = true ] ; then
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400268 cat <<EOM
269
270** -----------------------------------------------------------------------
271** Monitoring memory usage with mem_consumption.py
272** -----------------------------------------------------------------------
273EOM
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500274 mkdir -p "$WORKSPACE/voltha-pods-mem-consumption-${workflow}"
275 cd "$WORKSPACE/voltha-system-tests"
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400276
277 echo '** Installing python virtualenv'
278 make venv-activate-patched
279
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400280 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000281 # Collect initial memory consumption
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400282 python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace}
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000283 fi
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400284
285 echo -e '** Monitor memory consumption: LEAVE\n'
Hardik Windlasse1660492022-03-14 15:12:46 +0000286 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400287
288 sh """
Joey Armstrong54dec092023-08-03 18:21:38 -0400289 echo -e "\n** make testTarget=[${testTarget}]"
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700290 mkdir -p ${logsDir}
Hardik Windlassd62442d2021-11-30 10:51:20 +0000291 export ROBOT_MISC_ARGS="-d ${logsDir} ${params.extraRobotArgs} "
Matteo Scandolo9c230bb2021-10-22 12:48:39 -0700292 ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120 -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace} -v container_log_dir:${logsDir} -v logging:${testLogging}"
Hardik Windlass72947302021-06-14 10:36:57 +0000293 export KVSTOREPREFIX=voltha/voltha_voltha
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800294
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400295 make -C "$WORKSPACE/voltha-system-tests" ${testTarget}
Hardik Windlass72947302021-06-14 10:36:57 +0000296 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400297
298 getPodsInfo("${logsDir}")
299
300 sh """
Joey Armstrong54dec092023-08-03 18:21:38 -0400301 echo -e '\n** Gather robot Framework logs: ENTER'
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400302 # set +e
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000303 # collect logs collected in the Robot Framework StartLogging keyword
304 cd ${logsDir}
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400305 gzip *-combined.log
306 rm -f *-combined.log
Joey Armstrong54dec092023-08-03 18:21:38 -0400307
308 echo -e '** Gather robot Framework logs: LEAVE\n'
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000309 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400310
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400311 // -----------------------------------------------------------------------
312 // -----------------------------------------------------------------------
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000313 sh """
Joey Armstrong54dec092023-08-03 18:21:38 -0400314 echo -e '** Monitor pod-mem-consumption: ENTER'
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000315 if [ ${withMonitoring} = true ] ; then
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400316 cat <<EOM
317
318** -----------------------------------------------------------------------
319** Monitoring pod-memory-consumption using mem_consumption.py
320** -----------------------------------------------------------------------
321EOM
Joey Armstrong8c6f6482023-01-12 12:31:44 -0500322 cd "$WORKSPACE/voltha-system-tests"
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400323
324 echo '** Installing python virtualenv'
325 make venv-activate-patched
326
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400327 set +u && source .venv/bin/activate && set -u
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000328 # Collect memory consumption of voltha pods once all the tests are complete
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400329 python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption-${workflow} -a 0.0.0.0:31301 -n ${volthaNamespace}
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000330 fi
Joey Armstrong54dec092023-08-03 18:21:38 -0400331 echo -e '** Monitor pod-mem-consumption: LEAVE\n'
Hardik Windlass8cd517c2022-03-22 04:01:40 +0000332 """
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400333 } // stage
Joey Armstrongb65ada32023-08-03 12:50:20 -0400334
335 return
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400336} // execute_test()
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800337
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400338// -----------------------------------------------------------------------
339// -----------------------------------------------------------------------
Joey Armstrongb65ada32023-08-03 12:50:20 -0400340def collectArtifacts(exitStatus) {
Joey Armstrongcd419122023-08-07 14:56:39 -0400341 String iam = getIam('execute_test')
342
Joey Armstrong97a8b882023-08-02 16:08:52 -0400343 echo '''
344
345** -----------------------------------------------------------------------
346** collectArtifacts
347** -----------------------------------------------------------------------
348'''
Joey Armstrongcd419122023-08-07 14:56:39 -0400349 println("${iam}: ENTER (exitStatus=${exitStatus})")
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400350
Joey Armstrongcd419122023-08-07 14:56:39 -0400351 getPodsInfo("$WORKSPACE/${exitStatus}")
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400352
Joey Armstrongcd419122023-08-07 14:56:39 -0400353 sh """
Joey Armstrong0eb8bd82023-07-10 13:26:25 -0400354 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
Hardik Windlassec9341b2021-06-07 11:58:29 +0000355 """
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400356
Joey Armstrongcd419122023-08-07 14:56:39 -0400357 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html,**/voltha-pods-mem-consumption-att/*,**/voltha-pods-mem-consumption-dt/*,**/voltha-pods-mem-consumption-tt/*'
Joey Armstrong66fcb4e2023-08-11 12:09:24 -0400358
Joey Armstrongcd419122023-08-07 14:56:39 -0400359 sh(returnStdout:true, script: '''
Hardik Windlassec9341b2021-06-07 11:58:29 +0000360 sync
Joey Armstrongcd419122023-08-07 14:56:39 -0400361 echo '** Running: pgrep --list-full kail-startup (ENTER)'
362 pgrep --list-full 'kail-startup' || true
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400363 [[ $(pgrep --count kail) -gt 0 ]] && pkill --echo kail
Joey Armstrongcd419122023-08-07 14:56:39 -0400364 echo '** Running: pgrep --list-full kail-startup (LEAVE)'
Joey Armstrongf404b642023-08-04 14:39:13 -0400365 ''')
Joey Armstrong97a8b882023-08-02 16:08:52 -0400366
Joey Armstrongcd419122023-08-07 14:56:39 -0400367 println("${iam}: ENTER RobotPublisher")
368 step([$class: 'RobotPublisher',
369 disableArchiveOutput: false,
370 logFileName: '**/*/log*.html',
371 otherFiles: '',
372 outputFileName: '**/*/output*.xml',
373 outputPath: '.',
374 passThreshold: 100,
375 reportFileName: '**/*/report*.html',
376 unstableThreshold: 0,
377 onlyCritical: true]);
378 println("${iam}: LEAVE RobotPublisher")
379
380 println("${iam}: LEAVE (exitStatus=${exitStatus})")
381 return
Hardik Windlassec9341b2021-06-07 11:58:29 +0000382}
383
Joey Armstrongb65ada32023-08-03 12:50:20 -0400384// -----------------------------------------------------------------------
385// Intent: main
386// -----------------------------------------------------------------------
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800387pipeline {
388
389 /* no label, executor is determined by JJB */
390 agent {
391 label "${params.buildNode}"
392 }
393 options {
Hardik Windlassec9341b2021-06-07 11:58:29 +0000394 timeout(time: "${timeout}", unit: 'MINUTES')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800395 }
396 environment {
Joey Armstrongf404b642023-08-04 14:39:13 -0400397 KUBECONFIG = "$HOME/.kube/kind-${clusterName}"
398 VOLTCONFIG = "$HOME/.volt/config"
399 PATH = "$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
400 DIAGS_PROFILE = 'VOLTHA_PROFILE'
401 SSHPASS = 'karaf'
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800402 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000403 stages {
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800404 stage('Download Code') {
405 steps {
406 getVolthaCode([
407 branch: "${branch}",
408 gerritProject: "${gerritProject}",
409 gerritRefspec: "${gerritRefspec}",
410 volthaSystemTestsChange: "${volthaSystemTestsChange}",
411 volthaHelmChartsChange: "${volthaHelmChartsChange}",
412 ])
413 }
414 }
Joey Armstrong84adc542023-04-11 14:47:34 -0400415
416 stage('Build patch v1.1')
417 {
418 // build the patch only if gerritProject is specified
419 when
420 {
421 expression
422 {
423 return !gerritProject.isEmpty()
424 }
Hardik Windlassec9341b2021-06-07 11:58:29 +0000425 }
Joey Armstrong06a68372023-07-24 16:37:16 -0400426
Joey Armstrong97a8b882023-08-02 16:08:52 -0400427 steps
428 {
429 // NOTE that the correct patch has already been checked out
430 // during the getVolthaCode step
431 buildVolthaComponent("${gerritProject}")
Joey Armstrong06a68372023-07-24 16:37:16 -0400432 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800433 }
Joey Armstronged161f72023-04-11 13:16:59 -0400434
Joey Armstrong97a8b882023-08-02 16:08:52 -0400435 // -----------------------------------------------------------------------
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400436 // -----------------------------------------------------------------------
Joey Armstrongf404b642023-08-04 14:39:13 -0400437 stage('Install Kail')
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400438 {
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400439 steps
440 {
441 script
442 {
443 String cmd = [
444 'make',
Joey Armstrong9f184d32023-08-03 11:34:48 -0400445 '--no-print-directory',
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400446 '-C', "$WORKSPACE/voltha-system-tests",
447 "KAIL_PATH=\"$WORKSPACE/bin\"",
448 'kail',
449 ].join(' ')
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400450
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400451 println(" ** Running: ${cmd}:\n")
452 sh("${cmd}")
453 } // script
454 } // steps
455 } // stage
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400456
457 // -----------------------------------------------------------------------
Joey Armstrong97a8b882023-08-02 16:08:52 -0400458 // -----------------------------------------------------------------------
Joey Armstrongf404b642023-08-04 14:39:13 -0400459 stage('Install Kind')
Joey Armstrong97a8b882023-08-02 16:08:52 -0400460 {
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400461 steps
462 {
463 script
464 {
Joey Armstrong0e0a42b2023-08-02 21:04:21 -0400465
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400466 String cmd = [
467 'make',
Joey Armstrong9f184d32023-08-03 11:34:48 -0400468 '--no-print-directory',
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400469 '-C', "$WORKSPACE/voltha-system-tests",
470 "KIND_PATH=\"$WORKSPACE/bin\"",
471 'install-command-kind',
472 ].join(' ')
Joey Armstrongf404b642023-08-04 14:39:13 -0400473
Joey Armstrong2b2010d2023-08-02 21:47:20 -0400474 println(" ** Running: ${cmd}:\n")
475 sh("${cmd}")
476 } // script
477 } // steps
478 } // stage
Joey Armstrong97a8b882023-08-02 16:08:52 -0400479
480 // -----------------------------------------------------------------------
481 // -----------------------------------------------------------------------
Joey Armstronge5aae1c2023-07-24 14:11:20 -0400482 stage('Create K8s Cluster')
483 {
Joey Armstrongf076c312023-08-01 17:17:10 -0400484 steps
485 {
486 script
Joey Armstrong84adc542023-04-11 14:47:34 -0400487 {
Joey Armstrong97a8b882023-08-02 16:08:52 -0400488 def clusterExists = sh(
Joey Armstrongf076c312023-08-01 17:17:10 -0400489 returnStdout: true,
490 script: """kind get clusters | grep "${clusterName}" | wc -l""")
Joey Armstrongbf492922023-04-13 17:05:09 -0400491
Joey Armstrongb65ada32023-08-03 12:50:20 -0400492 if (clusterExists.trim() == '0')
Joey Armstrongf076c312023-08-01 17:17:10 -0400493 {
494 createKubernetesCluster([nodes: 3, name: clusterName])
495 }
496 } // script
497 } // steps
498 } // stage('Create K8s Cluster')
Joey Armstrong84adc542023-04-11 14:47:34 -0400499
Joey Armstrong268442d2023-08-22 17:16:10 -0400500 // -----------------------------------------------------------------------
501 // -----------------------------------------------------------------------
502 stage('Replace voltctl')
503 {
504 // if the project is voltctl, override the downloaded one with the built one
505 when {
506 expression {
507 return gerritProject == 'voltctl'
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400508 }
Joey Armstrong268442d2023-08-22 17:16:10 -0400509 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400510
Joey Armstrong268442d2023-08-22 17:16:10 -0400511 // Hmmmm(?) where did the voltctl download happen ?
512 // Likely Makefile but would be helpful to document here.
513 steps
514 {
515 println("${iam} Running: installVoltctl($branch)")
516 installVoltctl("$branch")
517 } // steps
518 } // stage
Joey Armstrong97a8b882023-08-02 16:08:52 -0400519
Joey Armstrong268442d2023-08-22 17:16:10 -0400520 // -----------------------------------------------------------------------
521 // -----------------------------------------------------------------------
Joey Armstrong38a87832023-08-23 17:02:50 -0400522 stage('voltctl [DEBUG]') {
523 steps {
524 script {
525 String iam = getIam('execute_test')
Joey Armstrong268442d2023-08-22 17:16:10 -0400526
Joey Armstrong38a87832023-08-23 17:02:50 -0400527 println("${iam} Display umask")
528 sh('umask')
529
530 println("${iam} Checking voltctl config permissions")
531 sh('/bin/ls -ld ~/.volt ~/.volt/* || true')
532 } // script
Joey Armstrong268442d2023-08-22 17:16:10 -0400533 } // steps
534 } // stage
535
536 // -----------------------------------------------------------------------
537 // -----------------------------------------------------------------------
538 stage('Load image in kind nodes')
539 {
540 when {
541 expression {
542 return !gerritProject.isEmpty()
543 }
544 }
545 steps {
546 loadToKind()
547 } // steps
548 } // stage
Joey Armstrong97a8b882023-08-02 16:08:52 -0400549
Joey Armstrongf404b642023-08-04 14:39:13 -0400550 // -----------------------------------------------------------------------
551 // -----------------------------------------------------------------------
552 stage('Parse and execute tests')
553 {
554 steps {
555 script {
556 def tests = readYaml text: testTargets
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400557
Joey Armstrongf404b642023-08-04 14:39:13 -0400558 tests.eachWithIndex { test, idx ->
559 println "** readYaml test suite[$idx]) test=[${test}]"
560 // def test = tests[i]
561 String target = test['target']
562 String workflow = test['workflow']
563 String flags = test['flags']
564 Boolean teardown = test['teardown'].toBoolean()
565 Boolean logging = test['logging'].toBoolean()
566 String testLogging = (logging) ? 'True' : 'False'
567
Joey Armstrong268442d2023-08-22 17:16:10 -0400568 print("""
569
570** -----------------------------------------------------------------------
571** Executing test ${target} on workflow ${workflow} with logging ${testLogging} and extra flags ${flags}"
572** -----------------------------------------------------------------------
573
574""")
575
Joey Armstrong54dec092023-08-03 18:21:38 -0400576 println "Executing test ${target}: ENTER"
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400577 execute_test(target, workflow, testLogging, teardown, flags)
Joey Armstrong54dec092023-08-03 18:21:38 -0400578 println "Executing test ${target}: LEAVE"
Joey Armstrongb65ada32023-08-03 12:50:20 -0400579 } // for
Joey Armstrongf404b642023-08-04 14:39:13 -0400580
Joey Armstrongcd419122023-08-07 14:56:39 -0400581 String iam = getIam('Parse and execute tests')
Joey Armstrongf404b642023-08-04 14:39:13 -0400582 println("** ${iam} ran to completion")
Joey Armstrongb65ada32023-08-03 12:50:20 -0400583 } // script
584 } // steps
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400585 } // stage
586 } // stages
Joey Armstrong84adc542023-04-11 14:47:34 -0400587
588 post
589 {
590 aborted { collectArtifacts('aborted') }
591 failure { collectArtifacts('failed') }
Joey Armstrongbf492922023-04-13 17:05:09 -0400592 always { collectArtifacts('always') }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800593 }
Joey Armstrong2d5a7c12023-04-13 09:37:42 -0400594} // pipeline
Joey Armstronged161f72023-04-11 13:16:59 -0400595
596// EOF