Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | // ----------------------------------------------------------------------- |
| 3 | // Copyright 2021-2024 Open Networking Foundation Contributors |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 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. |
Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 16 | // ----------------------------------------------------------------------- |
| 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 Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 25 | // easier to change the keywords during a replay |
Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 26 | // ----------------------------------------------------------------------- |
| 27 | |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 28 | library identifier: 'cord-jenkins-libraries@master', |
| 29 | retriever: modernSCM([ |
| 30 | $class: 'GitSCMSource', |
| 31 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 32 | ]) |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 33 | |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 34 | // ----------------------------------------------------------------------- |
| 35 | // Intent: |
| 36 | // ----------------------------------------------------------------------- |
| 37 | String 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 | // ----------------------------------------------------------------------- |
| 49 | String 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 Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 65 | // 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 Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 69 | // ----------------------------------------------------------------------- |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 70 | // git ls repo: gerrit (source of truth) VS github (mirror) |
| 71 | // Branch deletions are not mirrored out to github. |
| 72 | // Always perform checkouts/queries using the gerrit server as added |
| 73 | // insulation to guard against repository deltas. |
| 74 | // ----------------------------------------------------------------------- |
| 75 | // [TODO] Revisit logic: |
| 76 | // o Refactor logic into a standalone shell script. |
| 77 | // o Redundancy can be removed and a script will be testable. |
| 78 | // ----------------------------------------------------------------------- |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 79 | def get_voltha_comp_versions(component, base_deploy_tag) { |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 80 | def comp_test_tag = sh( |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 81 | // 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//'", |
| 82 | script: "git ls-remote --refs --tags https://gerrit.opencord.org/${component} | cut --delimiter='/' --fields=3 | tr '-' '~' | sort --version-sort | tail --lines=1 | sed 's/v//'", |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 83 | returnStdout: true |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 84 | ).trim() |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 85 | def comp_deploy_tag = sh( |
Joey Armstrong | 5c135fe | 2024-03-25 16:45:55 -0400 | [diff] [blame] | 86 | // 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//'", |
| 87 | script: "git ls-remote --refs --tags https://gerrit.opencord.org/${component} | cut --delimiter='/' --fields=3 | tr '-' '~' | sort --version-sort | tail --lines=2 | head -n 1 | sed 's/v//'", |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 88 | returnStdout: true |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 89 | ).trim() |
| 90 | def comp_deploy_major = comp_deploy_tag.substring(0, comp_deploy_tag.indexOf('.')) |
| 91 | def comp_test_major = comp_test_tag.substring(0, comp_test_tag.indexOf('.')) |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 92 | if ("${comp_deploy_major.trim()}" != "${comp_test_major.trim()}") { |
| 93 | comp_deploy_tag = comp_test_tag |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 94 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 95 | if ("${comp_test_tag.trim()}" == "${base_deploy_tag.trim()}") { |
| 96 | comp_deploy_tag = comp_test_tag |
| 97 | comp_test_tag = "master" |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 98 | } |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 99 | println "${component}: deploy_tag: ${comp_deploy_tag}, test_tag: ${comp_test_tag}" |
| 100 | return [comp_deploy_tag, comp_test_tag] |
| 101 | } |
| 102 | |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 103 | // ----------------------------------------------------------------------- |
| 104 | // ----------------------------------------------------------------------- |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 105 | def test_software_upgrade(name) { |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 106 | def infraNamespace = "infra" |
| 107 | def volthaNamespace = "voltha" |
| 108 | def openolt_adapter_deploy_tag = '' |
| 109 | def openolt_adapter_test_tag = '' |
| 110 | def openonu_adapter_deploy_tag = '' |
| 111 | def openonu_adapter_test_tag = '' |
| 112 | def rw_core_deploy_tag = '' |
| 113 | def rw_core_test_tag = '' |
| 114 | def ofagent_deploy_tag = '' |
| 115 | def ofagent_test_tag = '' |
| 116 | def logsDir = "$WORKSPACE/${name}" |
| 117 | stage('Deploy Voltha - ' + name) { |
| 118 | timeout(10) { |
| 119 | // start logging |
| 120 | sh """ |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 121 | rm -rf ${logsDir} || true |
| 122 | mkdir -p ${logsDir} |
| 123 | _TAG=kail-${name} kail -n ${infraNamespace} -n ${volthaNamespace} > ${logsDir}/onos-voltha-startup-combined.log & |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 124 | """ |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 125 | def extraHelmFlags = extraHelmFlags.trim() |
| 126 | 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") { |
| 127 | extraHelmFlags = " --set global.log_level=${logLevel.toUpperCase()},onu=1,pon=1 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " + extraHelmFlags |
| 128 | } |
| 129 | if ("${name}" == "onu-software-upgrade" || "${name}" == "onu-software-upgrade-omci-extended-msg") { |
| 130 | extraHelmFlags = " --set global.extended_omci_support.enabled=true " + extraHelmFlags |
| 131 | } |
| 132 | if ("${name}" == "onu-software-upgrade-omci-extended-msg") { |
| 133 | extraHelmFlags = " --set omccVersion=180 " + extraHelmFlags |
| 134 | } |
| 135 | if ("${name}" == "onu-image-dwl-simultaneously") { |
| 136 | extraHelmFlags = " --set global.log_level=${logLevel.toUpperCase()},onu=2,pon=2 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " + extraHelmFlags |
| 137 | } |
| 138 | if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade" || "${name}" == "onu-software-upgrade-omci-extended-msg" || "${name}" == "onu-image-dwl-simultaneously") { |
| 139 | extraHelmFlags = " --set global.image_tag=master --set onos-classic.image.tag=master " + extraHelmFlags |
| 140 | } |
| 141 | if ("${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") { |
| 142 | extraHelmFlags = " --set images.onos_config_loader.tag=master-onos-config-loader --set onos-classic.image.tag=master " + extraHelmFlags |
| 143 | } |
| 144 | extraHelmFlags += " --set onos-classic.onosSshPort=30115 --set onos-classic.onosApiPort=30120 " |
| 145 | extraHelmFlags += " --set voltha.onos_classic.replicas=3" |
| 146 | //ONOS custom image handling |
| 147 | if ( onosImg.trim() != '' ) { |
| 148 | String[] split; |
| 149 | onosImg = onosImg.trim() |
| 150 | split = onosImg.split(':') |
| 151 | extraHelmFlags += " --set onos-classic.image.repository=" + split[0] +",onos-classic.image.tag=" + split[1] + " " |
| 152 | } |
| 153 | Integer olts = 1 |
| 154 | if ("${name}" == 'onu-image-dwl-simultaneously') { |
| 155 | olts = 2 |
| 156 | } |
| 157 | if ("${name}" == 'voltha-component-upgrade' || "${name}" == 'voltha-component-rolling-upgrade') { |
| 158 | // fetch voltha components versions/tags |
| 159 | (openolt_adapter_deploy_tag, openolt_adapter_test_tag) = get_voltha_comp_versions('voltha-openolt-adapter', openoltAdapterDeployBaseTag.trim()) |
| 160 | extraHelmFlags += " --set voltha-adapter-openolt.images.adapter_open_olt.tag=${openolt_adapter_deploy_tag} " |
| 161 | (openonu_adapter_deploy_tag, openonu_adapter_test_tag) = get_voltha_comp_versions('voltha-openonu-adapter-go', openonuAdapterDeployBaseTag.trim()) |
| 162 | extraHelmFlags += " --set voltha-adapter-openonu.images.adapter_open_onu_go.tag=${openonu_adapter_deploy_tag} " |
| 163 | (rw_core_deploy_tag, rw_core_test_tag) = get_voltha_comp_versions('voltha-go', rwCoreDeployBaseTag.trim()) |
| 164 | extraHelmFlags += " --set voltha.images.rw_core.tag=${rw_core_deploy_tag} " |
| 165 | (ofagent_deploy_tag, ofagent_test_tag) = get_voltha_comp_versions('ofagent-go', ofagentDeployBaseTag.trim()) |
| 166 | extraHelmFlags += " --set voltha.images.ofagent.tag=${ofagent_deploy_tag} " |
| 167 | } |
| 168 | def localCharts = false |
| 169 | // Currently only testing with ATT workflow |
| 170 | // TODO: Support for other workflows |
| 171 | volthaDeploy([bbsimReplica: olts.toInteger(), workflow: 'att', extraHelmFlags: extraHelmFlags, localCharts: localCharts]) |
| 172 | // stop logging |
| 173 | sh """ |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 174 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')" |
| 175 | if [ -n "\$P_IDS" ]; then |
| 176 | echo \$P_IDS |
| 177 | for P_ID in \$P_IDS; do |
| 178 | kill -9 \$P_ID |
| 179 | done |
| 180 | fi |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 181 | cd ${logsDir} |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 182 | gzip -k onos-voltha-startup-combined.log |
| 183 | rm onos-voltha-startup-combined.log |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 184 | """ |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 185 | // forward ONOS and VOLTHA ports |
| 186 | sh(''' |
Andrea Campanella | 1b7c094 | 2021-09-14 11:02:58 +0200 | [diff] [blame] | 187 | 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 " & |
| 188 | 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 Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 189 | ''') |
| 190 | sh(''' |
Andrea Campanella | 9eeb4e7 | 2021-03-19 10:00:43 +0100 | [diff] [blame] | 191 | sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 log:set DEBUG org.opencord |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 192 | ''') |
| 193 | } |
Matteo Scandolo | 4b04034 | 2021-10-08 14:26:06 -0700 | [diff] [blame] | 194 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 195 | |
| 196 | stage('Test - ' + name) { |
| 197 | timeout(75) { |
| 198 | sh """ |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 199 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}" |
| 200 | mkdir -p \$ROBOT_LOGS_DIR |
| 201 | if [[ ${name} == 'onos-app-upgrade' ]]; then |
| 202 | export ONOS_APPS_UNDER_TEST+='' |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 203 | if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 204 | ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*" |
| 205 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 206 | if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 207 | ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*" |
| 208 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 209 | if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 210 | ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*" |
| 211 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 212 | if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 213 | ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*" |
| 214 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 215 | if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 216 | ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*" |
| 217 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 218 | if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 219 | ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*" |
| 220 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 221 | if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 222 | ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*" |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 223 | fi |
| 224 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch" |
| 225 | export TARGET=onos-app-upgrade-test |
| 226 | fi |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 227 | if [ ${name} == 'voltha-component-upgrade' ] || [ ${name} == 'voltha-component-rolling-upgrade' ]; then |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 228 | export VOLTHA_COMPS_UNDER_TEST+='' |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 229 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,voltha/voltha-openolt-adapter:${openolt_adapter_test_tag}*" |
| 230 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,voltha/voltha-openonu-adapter-go:${openonu_adapter_test_tag}*" |
| 231 | VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,voltha/voltha-rw-core:${rw_core_test_tag}*" |
| 232 | VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,voltha/voltha-ofagent-go:${ofagent_test_tag}*" |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 233 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch" |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 234 | fi |
| 235 | if [[ ${name} == 'voltha-component-upgrade' ]]; then |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 236 | export TARGET=voltha-comp-upgrade-test |
| 237 | fi |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 238 | if [[ ${name} == 'voltha-component-rolling-upgrade' ]]; then |
| 239 | export TARGET=voltha-comp-rolling-upgrade-test |
| 240 | fi |
TorstenThieme | 2853e62 | 2022-07-06 09:53:30 +0000 | [diff] [blame] | 241 | if [ ${name} == 'onu-software-upgrade' ] || [ ${name} == 'onu-software-upgrade-omci-extended-msg' ]; then |
Hardik Windlass | 8881454 | 2021-06-22 09:43:46 +0000 | [diff] [blame] | 242 | 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 Windlass | 834afbb | 2021-03-23 11:48:15 +0530 | [diff] [blame] | 243 | export TARGET=onu-upgrade-test |
| 244 | fi |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 245 | if [[ ${name} == 'onu-image-dwl-simultaneously' ]]; then |
| 246 | 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" |
| 247 | export TARGET=onu-upgrade-test-multiolt-kind-att |
| 248 | fi |
Hardik Windlass | 85491a0 | 2021-10-21 17:14:37 +0000 | [diff] [blame] | 249 | testLogging='False' |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 250 | if [ ${logging} = true ]; then |
Hardik Windlass | 85491a0 | 2021-10-21 17:14:37 +0000 | [diff] [blame] | 251 | testLogging='True' |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 252 | fi |
Jan Klare | ce1bc81 | 2023-09-28 13:15:52 +0200 | [diff] [blame] | 253 | export VOLTCONFIG=$HOME/.volt/config |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 254 | export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 255 | 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 Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 256 | # Run the specified tests |
| 257 | make -C $WORKSPACE/voltha-system-tests \$TARGET || true |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 258 | """ |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 259 | // remove port-forwarding |
| 260 | sh """ |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 261 | # remove orphaned port-forward from different namespaces |
Andrea Campanella | 4c8af94 | 2021-05-12 10:12:13 +0200 | [diff] [blame] | 262 | ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 263 | """ |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 264 | // collect pod details |
| 265 | get_pods_info("$WORKSPACE/${name}") |
| 266 | sh """ |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 267 | set +e |
| 268 | # collect logs collected in the Robot Framework StartLogging keyword |
| 269 | cd ${logsDir} |
| 270 | gzip *-combined.log || true |
| 271 | rm *-combined.log || true |
| 272 | """ |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 273 | helmTeardown(['infra', 'voltha']) |
| 274 | } |
Matteo Scandolo | 4b04034 | 2021-10-08 14:26:06 -0700 | [diff] [blame] | 275 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 276 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 277 | |
| 278 | // ----------------------------------------------------------------------- |
| 279 | // ----------------------------------------------------------------------- |
| 280 | void get_pods_info(dest) { |
| 281 | // collect pod details, this is here in case of failure |
| 282 | sh """ |
Hardik Windlass | 3db9adf | 2021-03-25 15:49:45 +0530 | [diff] [blame] | 283 | mkdir -p ${dest} || true |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 284 | kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true |
| 285 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true |
| 286 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true |
Andrea Campanella | ea2379a | 2021-03-22 13:56:26 +0100 | [diff] [blame] | 287 | kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/voltha-pods-describe.txt |
| 288 | kubectl describe pods -n infra -l app=onos-classic > ${dest}/onos-pods-describe.txt |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 289 | helm ls --all-namespaces > ${dest}/helm-charts.txt |
| 290 | """ |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 291 | sh ''' |
Andrea Campanella | 5764e18 | 2021-03-18 14:17:59 +0100 | [diff] [blame] | 292 | # copy the ONOS logs directly from the container to avoid the color codes |
Andrea Campanella | 188e50d | 2022-01-14 11:30:05 +0100 | [diff] [blame] | 293 | 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 Campanella | 5764e18 | 2021-03-18 14:17:59 +0100 | [diff] [blame] | 294 | ''' |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 295 | return |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 296 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 297 | |
| 298 | // ----------------------------------------------------------------------- |
| 299 | // ----------------------------------------------------------------------- |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 300 | pipeline { |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 301 | /* no label, executor is determined by JJB */ |
| 302 | agent { |
| 303 | label "${params.buildNode}" |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 304 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 305 | |
| 306 | options { |
| 307 | timeout(time: 220, unit: 'MINUTES') |
Hardik Windlass | 834afbb | 2021-03-23 11:48:15 +0530 | [diff] [blame] | 308 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 309 | |
| 310 | environment { |
| 311 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
| 312 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 313 | SSHPASS="karaf" |
Hardik Windlass | 9f5bee1 | 2021-05-07 06:47:21 +0000 | [diff] [blame] | 314 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 315 | |
| 316 | stages { |
| 317 | stage('Download Code') { |
| 318 | steps { |
| 319 | getVolthaCode([ |
| 320 | branch: "${branch}", |
| 321 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 322 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 323 | ]) |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | // ----------------------------------------------------------------------- |
| 328 | // ----------------------------------------------------------------------- |
| 329 | stage('Install Tools') |
| 330 | { |
| 331 | steps |
| 332 | { |
| 333 | script |
| 334 | { |
| 335 | String iam = getIam('Install Kind') |
| 336 | println("${iam}: ENTER") |
| 337 | installKind("$branch") // needed early by stage(Cleanup) |
| 338 | println("${iam}: LEAVE") |
| 339 | } // script |
| 340 | } // steps |
| 341 | } // stage |
| 342 | |
| 343 | // ----------------------------------------------------------------------- |
| 344 | // ----------------------------------------------------------------------- |
| 345 | stage('Cleanup') { |
| 346 | steps { |
| 347 | // remove port-forwarding |
| 348 | sh(label : 'Remove port forwarding', |
| 349 | script : """ |
| 350 | if [[ \$(pgrep --count 'port-forw') -gt 0 ]]; then |
| 351 | pkill --uid "\$(id -u)" --echo --full 'port-forw' |
| 352 | fi |
| 353 | """) |
| 354 | helmTeardown(['infra', 'voltha']) |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | // ----------------------------------------------------------------------- |
| 359 | // ----------------------------------------------------------------------- |
| 360 | stage('Create K8s Cluster') { |
| 361 | steps { |
| 362 | createKubernetesCluster([nodes: 3]) |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | // ----------------------------------------------------------------------- |
| 367 | // ----------------------------------------------------------------------- |
| 368 | stage('Run Test') { |
| 369 | steps { |
| 370 | test_software_upgrade('onos-app-upgrade') |
| 371 | test_software_upgrade('voltha-component-upgrade') |
| 372 | test_software_upgrade('voltha-component-rolling-upgrade') |
| 373 | test_software_upgrade('onu-software-upgrade') |
| 374 | test_software_upgrade('onu-software-upgrade-omci-extended-msg') |
| 375 | test_software_upgrade('onu-image-dwl-simultaneously') |
| 376 | } |
| 377 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 378 | } |
Joey Armstrong | c63186b | 2023-08-30 12:39:40 -0400 | [diff] [blame] | 379 | |
| 380 | // ----------------------------------------------------------------------- |
| 381 | // ----------------------------------------------------------------------- |
| 382 | post { |
| 383 | aborted { |
| 384 | get_pods_info("$WORKSPACE/failed") |
| 385 | } |
| 386 | failure { |
| 387 | get_pods_info("$WORKSPACE/failed") |
| 388 | } |
| 389 | always { |
| 390 | step([$class: 'RobotPublisher', |
| 391 | disableArchiveOutput: false, |
| 392 | logFileName: 'RobotLogs/*/log*.html', |
| 393 | otherFiles: '', |
| 394 | outputFileName: 'RobotLogs/*/output*.xml', |
| 395 | outputPath: '.', |
| 396 | passThreshold: 100, |
| 397 | reportFileName: 'RobotLogs/*/report*.html', |
| 398 | unstableThreshold: 0, |
| 399 | onlyCritical: true]) |
| 400 | archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt' |
| 401 | } // always |
| 402 | } // post |
| 403 | } // pipeline |
Joey Armstrong | 56fdfec | 2024-03-01 13:43:36 -0500 | [diff] [blame] | 404 | |
| 405 | // [EOF] |