blob: e169d1b2d6a7affc68131e07adb92bc1690ea0b1 [file] [log] [blame]
Joey Armstrong56fdfec2024-03-01 13:43:36 -05001#!/usr/bin/env groovy
2// -----------------------------------------------------------------------
3// Copyright 2021-2024 Open Networking Foundation Contributors
Hardik Windlass0f9621d2021-02-24 21:23:19 +05304//
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 Armstrong56fdfec2024-03-01 13:43:36 -050016// -----------------------------------------------------------------------
17// SPDX-FileCopyrightText: 2021-2024 Open Networking Foundation Contributors
18// SPDX-License-Identifier: Apache-2.0
19// -----------------------------------------------------------------------
20// Entropy: 0fcb5ffa-d1a4-11ee-be5e-9f44b7181764
21// -----------------------------------------------------------------------
22// Intent: voltha-2.x e2e tests, uses bbsim to simulate OLT/ONUs
23// -----------------------------------------------------------------------
24// NOTE: we are importing the library even if it's global so that it's
Hardik Windlass0f9621d2021-02-24 21:23:19 +053025// easier to change the keywords during a replay
Joey Armstrong56fdfec2024-03-01 13:43:36 -050026// -----------------------------------------------------------------------
27
Hardik Windlass0f9621d2021-02-24 21:23:19 +053028library identifier: 'cord-jenkins-libraries@master',
29 retriever: modernSCM([
30 $class: 'GitSCMSource',
31 remote: 'https://gerrit.opencord.org/ci-management.git'
32])
Hardik Windlass317ad022022-02-21 11:18:18 +000033
Joey Armstrongc63186b2023-08-30 12:39:40 -040034// -----------------------------------------------------------------------
35// Intent:
36// -----------------------------------------------------------------------
37String branchName() {
38 String name = 'master'
39
40 // [TODO] Sanity check the target branch
41 // if (name != jenkins.branch) { fatal }
42 return(name)
43}
44
45// -----------------------------------------------------------------------
46// Intent: Due to lack of a reliable stack trace, construct a literal.
47// Jenkins will re-write the call stack for serialization.
48// -----------------------------------------------------------------------
49String getIam(String func) {
50 String branchName = branchName()
51 String src = [
52 'ci-management',
53 'jjb',
54 'pipeline',
55 'voltha',
56 branchName,
57 'software-upgrades.groovy'
58 ].join('/')
59
60 String name = [src, func].join('::')
61 return(name)
62}
63
64// -----------------------------------------------------------------------
Hardik Windlass317ad022022-02-21 11:18:18 +000065// fetches the versions/tags of the voltha component
66// returns the deployment version which is one less than the latest available tag of the repo, first voltha stack gets deployed using this;
67// returns the test version which is the latest tag of the repo, the component upgrade gets tested on this.
68// Note: if there is a major version change between deployment and test tags, then deployment tag will be same as test tag, i.e. both as latest.
Joey Armstrongc63186b2023-08-30 12:39:40 -040069// -----------------------------------------------------------------------
Hardik Windlass8e264492022-03-25 16:15:45 +000070def get_voltha_comp_versions(component, base_deploy_tag) {
Joey Armstrongc63186b2023-08-30 12:39:40 -040071 def comp_test_tag = sh(
72 script: "git ls-remote --refs --tags https://github.com/opencord/${component} | cut --delimiter='/' --fields=3 | tr '-' '~' | sort --version-sort | tail --lines=1 | sed 's/v//'",
73 returnStdout: true
Hardik Windlass317ad022022-02-21 11:18:18 +000074 ).trim()
Joey Armstrongc63186b2023-08-30 12:39:40 -040075 def comp_deploy_tag = sh(
76 script: "git ls-remote --refs --tags https://github.com/opencord/${component} | cut --delimiter='/' --fields=3 | tr '-' '~' | sort --version-sort | tail --lines=2 | head -n 1 | sed 's/v//'",
77 returnStdout: true
Hardik Windlass317ad022022-02-21 11:18:18 +000078 ).trim()
79 def comp_deploy_major = comp_deploy_tag.substring(0, comp_deploy_tag.indexOf('.'))
80 def comp_test_major = comp_test_tag.substring(0, comp_test_tag.indexOf('.'))
Joey Armstrongc63186b2023-08-30 12:39:40 -040081 if ("${comp_deploy_major.trim()}" != "${comp_test_major.trim()}") {
82 comp_deploy_tag = comp_test_tag
Hardik Windlass317ad022022-02-21 11:18:18 +000083 }
Joey Armstrongc63186b2023-08-30 12:39:40 -040084 if ("${comp_test_tag.trim()}" == "${base_deploy_tag.trim()}") {
85 comp_deploy_tag = comp_test_tag
86 comp_test_tag = "master"
Hardik Windlass8e264492022-03-25 16:15:45 +000087 }
Hardik Windlass317ad022022-02-21 11:18:18 +000088 println "${component}: deploy_tag: ${comp_deploy_tag}, test_tag: ${comp_test_tag}"
89 return [comp_deploy_tag, comp_test_tag]
90}
91
Joey Armstrongc63186b2023-08-30 12:39:40 -040092// -----------------------------------------------------------------------
93// -----------------------------------------------------------------------
Hardik Windlass0f9621d2021-02-24 21:23:19 +053094def test_software_upgrade(name) {
Joey Armstrongc63186b2023-08-30 12:39:40 -040095 def infraNamespace = "infra"
96 def volthaNamespace = "voltha"
97 def openolt_adapter_deploy_tag = ''
98 def openolt_adapter_test_tag = ''
99 def openonu_adapter_deploy_tag = ''
100 def openonu_adapter_test_tag = ''
101 def rw_core_deploy_tag = ''
102 def rw_core_test_tag = ''
103 def ofagent_deploy_tag = ''
104 def ofagent_test_tag = ''
105 def logsDir = "$WORKSPACE/${name}"
106 stage('Deploy Voltha - ' + name) {
107 timeout(10) {
108 // start logging
109 sh """
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000110 rm -rf ${logsDir} || true
111 mkdir -p ${logsDir}
112 _TAG=kail-${name} kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log &
Hardik Windlasscb955822021-10-21 14:59:11 +0000113 """
Joey Armstrongc63186b2023-08-30 12:39:40 -0400114 def extraHelmFlags = extraHelmFlags.trim()
115 if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade" || "${name}" == "onu-software-upgrade-omci-extended-msg" || "${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") {
116 extraHelmFlags = " --set global.log_level=${logLevel.toUpperCase()},onu=1,pon=1 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " + extraHelmFlags
117 }
118 if ("${name}" == "onu-software-upgrade" || "${name}" == "onu-software-upgrade-omci-extended-msg") {
119 extraHelmFlags = " --set global.extended_omci_support.enabled=true " + extraHelmFlags
120 }
121 if ("${name}" == "onu-software-upgrade-omci-extended-msg") {
122 extraHelmFlags = " --set omccVersion=180 " + extraHelmFlags
123 }
124 if ("${name}" == "onu-image-dwl-simultaneously") {
125 extraHelmFlags = " --set global.log_level=${logLevel.toUpperCase()},onu=2,pon=2 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " + extraHelmFlags
126 }
127 if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade" || "${name}" == "onu-software-upgrade-omci-extended-msg" || "${name}" == "onu-image-dwl-simultaneously") {
128 extraHelmFlags = " --set global.image_tag=master --set onos-classic.image.tag=master " + extraHelmFlags
129 }
130 if ("${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") {
131 extraHelmFlags = " --set images.onos_config_loader.tag=master-onos-config-loader --set onos-classic.image.tag=master " + extraHelmFlags
132 }
133 extraHelmFlags += " --set onos-classic.onosSshPort=30115 --set onos-classic.onosApiPort=30120 "
134 extraHelmFlags += " --set voltha.onos_classic.replicas=3"
135 //ONOS custom image handling
136 if ( onosImg.trim() != '' ) {
137 String[] split;
138 onosImg = onosImg.trim()
139 split = onosImg.split(':')
140 extraHelmFlags += " --set onos-classic.image.repository=" + split[0] +",onos-classic.image.tag=" + split[1] + " "
141 }
142 Integer olts = 1
143 if ("${name}" == 'onu-image-dwl-simultaneously') {
144 olts = 2
145 }
146 if ("${name}" == 'voltha-component-upgrade' || "${name}" == 'voltha-component-rolling-upgrade') {
147 // fetch voltha components versions/tags
148 (openolt_adapter_deploy_tag, openolt_adapter_test_tag) = get_voltha_comp_versions('voltha-openolt-adapter', openoltAdapterDeployBaseTag.trim())
149 extraHelmFlags += " --set voltha-adapter-openolt.images.adapter_open_olt.tag=${openolt_adapter_deploy_tag} "
150 (openonu_adapter_deploy_tag, openonu_adapter_test_tag) = get_voltha_comp_versions('voltha-openonu-adapter-go', openonuAdapterDeployBaseTag.trim())
151 extraHelmFlags += " --set voltha-adapter-openonu.images.adapter_open_onu_go.tag=${openonu_adapter_deploy_tag} "
152 (rw_core_deploy_tag, rw_core_test_tag) = get_voltha_comp_versions('voltha-go', rwCoreDeployBaseTag.trim())
153 extraHelmFlags += " --set voltha.images.rw_core.tag=${rw_core_deploy_tag} "
154 (ofagent_deploy_tag, ofagent_test_tag) = get_voltha_comp_versions('ofagent-go', ofagentDeployBaseTag.trim())
155 extraHelmFlags += " --set voltha.images.ofagent.tag=${ofagent_deploy_tag} "
156 }
157 def localCharts = false
158 // Currently only testing with ATT workflow
159 // TODO: Support for other workflows
160 volthaDeploy([bbsimReplica: olts.toInteger(), workflow: 'att', extraHelmFlags: extraHelmFlags, localCharts: localCharts])
161 // stop logging
162 sh """
Hardik Windlasscb955822021-10-21 14:59:11 +0000163 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')"
164 if [ -n "\$P_IDS" ]; then
165 echo \$P_IDS
166 for P_ID in \$P_IDS; do
167 kill -9 \$P_ID
168 done
169 fi
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000170 cd ${logsDir}
Hardik Windlasscb955822021-10-21 14:59:11 +0000171 gzip -k onos-voltha-startup-combined.log
172 rm onos-voltha-startup-combined.log
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530173 """
Joey Armstrongc63186b2023-08-30 12:39:40 -0400174 // forward ONOS and VOLTHA ports
175 sh('''
Andrea Campanella1b7c0942021-09-14 11:02:58 +0200176 JENKINS_NODE_COOKIE="dontKillMe" _TAG=onos-port-forward /bin/bash -c "while true; do kubectl -n infra port-forward --address 0.0.0.0 service/voltha-infra-onos-classic-hs 8101:8101; done 2>&1 " &
177 JENKINS_NODE_COOKIE="dontKillMe" _TAG=onos-port-forward /bin/bash -c "while true; do kubectl -n infra port-forward --address 0.0.0.0 service/voltha-infra-onos-classic-hs 8181:8181; done 2>&1 " &
Joey Armstrongc63186b2023-08-30 12:39:40 -0400178 ''')
179 sh('''
Andrea Campanella9eeb4e72021-03-19 10:00:43 +0100180 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 log:set DEBUG org.opencord
Joey Armstrongc63186b2023-08-30 12:39:40 -0400181 ''')
182 }
Matteo Scandolo4b040342021-10-08 14:26:06 -0700183 }
Joey Armstrongc63186b2023-08-30 12:39:40 -0400184
185 stage('Test - ' + name) {
186 timeout(75) {
187 sh """
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530188 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}"
189 mkdir -p \$ROBOT_LOGS_DIR
190 if [[ ${name} == 'onos-app-upgrade' ]]; then
191 export ONOS_APPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530192 if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530193 ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*"
194 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530195 if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530196 ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*"
197 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530198 if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530199 ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*"
200 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530201 if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530202 ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*"
203 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530204 if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530205 ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*"
206 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530207 if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530208 ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*"
209 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530210 if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530211 ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530212 fi
213 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch"
214 export TARGET=onos-app-upgrade-test
215 fi
Hardik Windlass1bb96a32022-01-19 10:10:08 +0000216 if [ ${name} == 'voltha-component-upgrade' ] || [ ${name} == 'voltha-component-rolling-upgrade' ]; then
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530217 export VOLTHA_COMPS_UNDER_TEST+=''
Hardik Windlass317ad022022-02-21 11:18:18 +0000218 VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,voltha/voltha-openolt-adapter:${openolt_adapter_test_tag}*"
219 VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,voltha/voltha-openonu-adapter-go:${openonu_adapter_test_tag}*"
220 VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,voltha/voltha-rw-core:${rw_core_test_tag}*"
221 VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,voltha/voltha-ofagent-go:${ofagent_test_tag}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530222 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch"
Hardik Windlass1bb96a32022-01-19 10:10:08 +0000223 fi
224 if [[ ${name} == 'voltha-component-upgrade' ]]; then
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530225 export TARGET=voltha-comp-upgrade-test
226 fi
Hardik Windlass1bb96a32022-01-19 10:10:08 +0000227 if [[ ${name} == 'voltha-component-rolling-upgrade' ]]; then
228 export TARGET=voltha-comp-rolling-upgrade-test
229 fi
TorstenThieme2853e622022-07-06 09:53:30 +0000230 if [ ${name} == 'onu-software-upgrade' ] || [ ${name} == 'onu-software-upgrade-omci-extended-msg' ]; then
Hardik Windlass88814542021-06-22 09:43:46 +0000231 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v image_version:${onuImageVersion.trim()} -v image_url:${onuImageUrl.trim()} -v image_vendor:${onuImageVendor.trim()} -v image_activate_on_success:${onuImageActivateOnSuccess.trim()} -v image_commit_on_success:${onuImageCommitOnSuccess.trim()} -v image_crc:${onuImageCrc.trim()} -e PowerSwitch"
Hardik Windlass834afbb2021-03-23 11:48:15 +0530232 export TARGET=onu-upgrade-test
233 fi
TorstenThiemecf20f4b2021-11-12 13:38:26 +0000234 if [[ ${name} == 'onu-image-dwl-simultaneously' ]]; then
235 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v image_version:${onuImageVersion.trim()} -v image_url:${onuImageUrl.trim()} -v image_vendor:${onuImageVendor.trim()} -v image_activate_on_success:${onuImageActivateOnSuccess.trim()} -v image_commit_on_success:${onuImageCommitOnSuccess.trim()} -v image_crc:${onuImageCrc.trim()} -e PowerSwitch"
236 export TARGET=onu-upgrade-test-multiolt-kind-att
237 fi
Hardik Windlass85491a02021-10-21 17:14:37 +0000238 testLogging='False'
Hardik Windlasscb955822021-10-21 14:59:11 +0000239 if [ ${logging} = true ]; then
Hardik Windlass85491a02021-10-21 17:14:37 +0000240 testLogging='True'
Hardik Windlasscb955822021-10-21 14:59:11 +0000241 fi
Jan Klarece1bc812023-09-28 13:15:52 +0200242 export VOLTCONFIG=$HOME/.volt/config
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530243 export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000244 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 Windlass25c8ddb2021-03-05 20:26:16 +0530245 # Run the specified tests
246 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530247 """
Joey Armstrongc63186b2023-08-30 12:39:40 -0400248 // remove port-forwarding
249 sh """
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530250 # remove orphaned port-forward from different namespaces
Andrea Campanella4c8af942021-05-12 10:12:13 +0200251 ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530252 """
Joey Armstrongc63186b2023-08-30 12:39:40 -0400253 // collect pod details
254 get_pods_info("$WORKSPACE/${name}")
255 sh """
Hardik Windlassdad8e5c2021-11-11 05:19:47 +0000256 set +e
257 # collect logs collected in the Robot Framework StartLogging keyword
258 cd ${logsDir}
259 gzip *-combined.log || true
260 rm *-combined.log || true
261 """
Joey Armstrongc63186b2023-08-30 12:39:40 -0400262 helmTeardown(['infra', 'voltha'])
263 }
Matteo Scandolo4b040342021-10-08 14:26:06 -0700264 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530265}
Joey Armstrongc63186b2023-08-30 12:39:40 -0400266
267// -----------------------------------------------------------------------
268// -----------------------------------------------------------------------
269void get_pods_info(dest) {
270 // collect pod details, this is here in case of failure
271 sh """
Hardik Windlass3db9adf2021-03-25 15:49:45 +0530272 mkdir -p ${dest} || true
Hardik Windlass428f5132021-03-15 12:17:47 +0530273 kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true
274 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true
275 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true
Andrea Campanellaea2379a2021-03-22 13:56:26 +0100276 kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/voltha-pods-describe.txt
277 kubectl describe pods -n infra -l app=onos-classic > ${dest}/onos-pods-describe.txt
Hardik Windlass428f5132021-03-15 12:17:47 +0530278 helm ls --all-namespaces > ${dest}/helm-charts.txt
279 """
Joey Armstrongc63186b2023-08-30 12:39:40 -0400280 sh '''
Andrea Campanella5764e182021-03-18 14:17:59 +0100281 # copy the ONOS logs directly from the container to avoid the color codes
Andrea Campanella188e50d2022-01-14 11:30:05 +0100282 printf '%s\\n' $(kubectl get pods -n infra -l app=onos-classic -o=jsonpath="{.items[*]['metadata.name']}") | xargs --no-run-if-empty -I# bash -c 'kubectl -n infra cp #:apache-karaf-4.2.14/data/log/karaf.log ''' + dest + '''/#.log' || true
Andrea Campanella5764e182021-03-18 14:17:59 +0100283 '''
Joey Armstrongc63186b2023-08-30 12:39:40 -0400284 return
Hardik Windlass428f5132021-03-15 12:17:47 +0530285}
Joey Armstrongc63186b2023-08-30 12:39:40 -0400286
287// -----------------------------------------------------------------------
288// -----------------------------------------------------------------------
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530289pipeline {
Joey Armstrongc63186b2023-08-30 12:39:40 -0400290 /* no label, executor is determined by JJB */
291 agent {
292 label "${params.buildNode}"
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530293 }
Joey Armstrongc63186b2023-08-30 12:39:40 -0400294
295 options {
296 timeout(time: 220, unit: 'MINUTES')
Hardik Windlass834afbb2021-03-23 11:48:15 +0530297 }
Joey Armstrongc63186b2023-08-30 12:39:40 -0400298
299 environment {
300 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
301 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
302 SSHPASS="karaf"
Hardik Windlass9f5bee12021-05-07 06:47:21 +0000303 }
Joey Armstrongc63186b2023-08-30 12:39:40 -0400304
305 stages {
306 stage('Download Code') {
307 steps {
308 getVolthaCode([
309 branch: "${branch}",
310 volthaSystemTestsChange: "${volthaSystemTestsChange}",
311 volthaHelmChartsChange: "${volthaHelmChartsChange}",
312 ])
313 }
314 }
315
316 // -----------------------------------------------------------------------
317 // -----------------------------------------------------------------------
318 stage('Install Tools')
319 {
320 steps
321 {
322 script
323 {
324 String iam = getIam('Install Kind')
325 println("${iam}: ENTER")
326 installKind("$branch") // needed early by stage(Cleanup)
327 println("${iam}: LEAVE")
328 } // script
329 } // steps
330 } // stage
331
332 // -----------------------------------------------------------------------
333 // -----------------------------------------------------------------------
334 stage('Cleanup') {
335 steps {
336 // remove port-forwarding
337 sh(label : 'Remove port forwarding',
338 script : """
339if [[ \$(pgrep --count 'port-forw') -gt 0 ]]; then
340 pkill --uid "\$(id -u)" --echo --full 'port-forw'
341fi
342""")
343 helmTeardown(['infra', 'voltha'])
344 }
345 }
346
347 // -----------------------------------------------------------------------
348 // -----------------------------------------------------------------------
349 stage('Create K8s Cluster') {
350 steps {
351 createKubernetesCluster([nodes: 3])
352 }
353 }
354
355 // -----------------------------------------------------------------------
356 // -----------------------------------------------------------------------
357 stage('Run Test') {
358 steps {
359 test_software_upgrade('onos-app-upgrade')
360 test_software_upgrade('voltha-component-upgrade')
361 test_software_upgrade('voltha-component-rolling-upgrade')
362 test_software_upgrade('onu-software-upgrade')
363 test_software_upgrade('onu-software-upgrade-omci-extended-msg')
364 test_software_upgrade('onu-image-dwl-simultaneously')
365 }
366 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530367 }
Joey Armstrongc63186b2023-08-30 12:39:40 -0400368
369 // -----------------------------------------------------------------------
370 // -----------------------------------------------------------------------
371 post {
372 aborted {
373 get_pods_info("$WORKSPACE/failed")
374 }
375 failure {
376 get_pods_info("$WORKSPACE/failed")
377 }
378 always {
379 step([$class: 'RobotPublisher',
380 disableArchiveOutput: false,
381 logFileName: 'RobotLogs/*/log*.html',
382 otherFiles: '',
383 outputFileName: 'RobotLogs/*/output*.xml',
384 outputPath: '.',
385 passThreshold: 100,
386 reportFileName: 'RobotLogs/*/report*.html',
387 unstableThreshold: 0,
388 onlyCritical: true])
389 archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt'
390 } // always
391 } // post
392} // pipeline
Joey Armstrong56fdfec2024-03-01 13:43:36 -0500393
394// [EOF]