Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 1 | // Copyright 2021-present Open Networking Foundation |
| 2 | // |
| 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. |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 14 | // voltha-2.x e2e tests |
| 15 | // uses bbsim to simulate OLT/ONUs |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 16 | // NOTE we are importing the library even if it's global so that it's |
| 17 | // easier to change the keywords during a replay |
| 18 | library identifier: 'cord-jenkins-libraries@master', |
| 19 | retriever: modernSCM([ |
| 20 | $class: 'GitSCMSource', |
| 21 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 22 | ]) |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 23 | |
| 24 | // fetches the versions/tags of the voltha component |
| 25 | // returns the deployment version which is one less than the latest available tag of the repo, first voltha stack gets deployed using this; |
| 26 | // returns the test version which is the latest tag of the repo, the component upgrade gets tested on this. |
| 27 | // 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. |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 28 | def get_voltha_comp_versions(component, base_deploy_tag) { |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 29 | def comp_test_tag = sh ( |
| 30 | 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//'", |
| 31 | returnStdout: true |
| 32 | ).trim() |
| 33 | def comp_deploy_tag = sh ( |
| 34 | 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//'", |
| 35 | returnStdout: true |
| 36 | ).trim() |
| 37 | def comp_deploy_major = comp_deploy_tag.substring(0, comp_deploy_tag.indexOf('.')) |
| 38 | def comp_test_major = comp_test_tag.substring(0, comp_test_tag.indexOf('.')) |
| 39 | if ( "${comp_deploy_major.trim()}" != "${comp_test_major.trim()}") { |
| 40 | comp_deploy_tag = comp_test_tag |
| 41 | } |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 42 | if ( "${comp_test_tag.trim()}" == "${base_deploy_tag.trim()}") { |
| 43 | comp_deploy_tag = comp_test_tag |
| 44 | comp_test_tag = "master" |
| 45 | } |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 46 | println "${component}: deploy_tag: ${comp_deploy_tag}, test_tag: ${comp_test_tag}" |
| 47 | return [comp_deploy_tag, comp_test_tag] |
| 48 | } |
| 49 | |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 50 | def test_software_upgrade(name) { |
Hardik Windlass | 7e4e315 | 2021-09-29 06:42:05 +0000 | [diff] [blame] | 51 | def infraNamespace = "infra" |
| 52 | def volthaNamespace = "voltha" |
Hardik Windlass | 555a086 | 2022-02-23 13:17:54 +0530 | [diff] [blame] | 53 | def openolt_adapter_deploy_tag = "" |
| 54 | def openolt_adapter_test_tag = "" |
| 55 | def openonu_adapter_deploy_tag = "" |
| 56 | def openonu_adapter_test_tag = "" |
| 57 | def rw_core_deploy_tag = "" |
| 58 | def rw_core_test_tag = "" |
| 59 | def ofagent_deploy_tag = "" |
| 60 | def ofagent_test_tag = "" |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 61 | def logsDir = "$WORKSPACE/${name}" |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 62 | stage('Deploy Voltha - '+ name) { |
Matteo Scandolo | 4b04034 | 2021-10-08 14:26:06 -0700 | [diff] [blame] | 63 | timeout(10) { |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 64 | // start logging |
| 65 | sh """ |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 66 | rm -rf ${logsDir} || true |
| 67 | mkdir -p ${logsDir} |
| 68 | _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] | 69 | """ |
Andrea Campanella | 9e41a60 | 2021-09-14 14:45:11 +0200 | [diff] [blame] | 70 | def extraHelmFlags = extraHelmFlags.trim() |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 71 | if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade" || "${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") { |
Andrea Campanella | 0442dd0 | 2021-12-30 15:44:34 +0100 | [diff] [blame] | 72 | extraHelmFlags = " --set global.log_level=${logLevel.toUpperCase()},onu=1,pon=1 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " + extraHelmFlags |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 73 | } |
| 74 | if ("${name}" == "onu-image-dwl-simultaneously") { |
Andrea Campanella | 0442dd0 | 2021-12-30 15:44:34 +0100 | [diff] [blame] | 75 | extraHelmFlags = " --set global.log_level=${logLevel.toUpperCase()},onu=2,pon=2 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " + extraHelmFlags |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 76 | } |
| 77 | if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade" || "${name}" == "onu-image-dwl-simultaneously") { |
Andrea Campanella | 0442dd0 | 2021-12-30 15:44:34 +0100 | [diff] [blame] | 78 | extraHelmFlags = " --set global.image_tag=master --set onos-classic.image.tag=master " + extraHelmFlags |
Hardik Windlass | d87caad | 2021-05-06 06:55:09 +0000 | [diff] [blame] | 79 | } |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 80 | if ("${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") { |
Andrea Campanella | 0442dd0 | 2021-12-30 15:44:34 +0100 | [diff] [blame] | 81 | extraHelmFlags = " --set images.onos_config_loader.tag=master-onos-config-loader --set onos-classic.image.tag=master " + extraHelmFlags |
Hardik Windlass | ff97f65 | 2021-03-18 15:11:13 +0530 | [diff] [blame] | 82 | } |
Andrea Campanella | 834f27b | 2021-06-08 17:08:41 +0200 | [diff] [blame] | 83 | extraHelmFlags = extraHelmFlags + " --set onos-classic.onosSshPort=30115 --set onos-classic.onosApiPort=30120 " |
| 84 | extraHelmFlags = extraHelmFlags + " --set voltha.onos_classic.replicas=3" |
Andrea Campanella | 5764e18 | 2021-03-18 14:17:59 +0100 | [diff] [blame] | 85 | //ONOS custom image handling |
| 86 | if ( onosImg.trim() != '' ) { |
| 87 | String[] split; |
| 88 | onosImg = onosImg.trim() |
| 89 | split = onosImg.split(':') |
Andrea Campanella | 0442dd0 | 2021-12-30 15:44:34 +0100 | [diff] [blame] | 90 | extraHelmFlags = extraHelmFlags + " --set onos-classic.image.repository=" + split[0] +",onos-classic.image.tag=" + split[1] + " " |
Andrea Campanella | 5764e18 | 2021-03-18 14:17:59 +0100 | [diff] [blame] | 91 | } |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 92 | def olts = 1 |
| 93 | if ("${name}" == "onu-image-dwl-simultaneously") { |
| 94 | olts = 2 |
| 95 | } |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 96 | if ("${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") { |
| 97 | // fetch voltha components versions/tags |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 98 | (openolt_adapter_deploy_tag, openolt_adapter_test_tag) = get_voltha_comp_versions("voltha-openolt-adapter", openoltAdapterDeployBaseTag.trim()) |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 99 | extraHelmFlags = extraHelmFlags + " --set voltha-adapter-openolt.images.adapter_open_olt.tag=${openolt_adapter_deploy_tag} " |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 100 | (openonu_adapter_deploy_tag, openonu_adapter_test_tag) = get_voltha_comp_versions("voltha-openonu-adapter-go", openonuAdapterDeployBaseTag.trim()) |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 101 | extraHelmFlags = extraHelmFlags + " --set voltha-adapter-openonu.images.adapter_open_onu_go.tag=${openonu_adapter_deploy_tag} " |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 102 | (rw_core_deploy_tag, rw_core_test_tag) = get_voltha_comp_versions("voltha-go", rwCoreDeployBaseTag.trim()) |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 103 | extraHelmFlags = extraHelmFlags + " --set voltha.images.rw_core.tag=${rw_core_deploy_tag} " |
Hardik Windlass | 8e26449 | 2022-03-25 16:15:45 +0000 | [diff] [blame] | 104 | (ofagent_deploy_tag, ofagent_test_tag) = get_voltha_comp_versions("ofagent-go", ofagentDeployBaseTag.trim()) |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 105 | extraHelmFlags = extraHelmFlags + " --set voltha.images.ofagent.tag=${ofagent_deploy_tag} " |
| 106 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 107 | def localCharts = false |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 108 | // Currently only testing with ATT workflow |
| 109 | // TODO: Support for other workflows |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 110 | volthaDeploy([bbsimReplica: olts.toInteger(), workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts]) |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 111 | // stop logging |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 112 | sh """ |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 113 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')" |
| 114 | if [ -n "\$P_IDS" ]; then |
| 115 | echo \$P_IDS |
| 116 | for P_ID in \$P_IDS; do |
| 117 | kill -9 \$P_ID |
| 118 | done |
| 119 | fi |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 120 | cd ${logsDir} |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 121 | gzip -k onos-voltha-startup-combined.log |
| 122 | rm onos-voltha-startup-combined.log |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 123 | """ |
| 124 | // forward ONOS and VOLTHA ports |
| 125 | sh """ |
Andrea Campanella | 1b7c094 | 2021-09-14 11:02:58 +0200 | [diff] [blame] | 126 | 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 " & |
| 127 | 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 " & |
| 128 | JENKINS_NODE_COOKIE="dontKillMe" _TAG=port-forward-voltha-api /bin/bash -c "while true; do kubectl -n voltha port-forward --address 0.0.0.0 service/voltha-voltha-api 55555:55555; done 2>&1 " & |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 129 | """ |
Andrea Campanella | 9eeb4e7 | 2021-03-19 10:00:43 +0100 | [diff] [blame] | 130 | sh """ |
| 131 | sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 log:set DEBUG org.opencord |
| 132 | """ |
Matteo Scandolo | 4b04034 | 2021-10-08 14:26:06 -0700 | [diff] [blame] | 133 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 134 | } |
| 135 | stage('Test - '+ name) { |
Hardik Windlass | c87dbce | 2022-01-28 10:13:20 +0000 | [diff] [blame] | 136 | timeout(75) { |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 137 | sh """ |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 138 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}" |
| 139 | mkdir -p \$ROBOT_LOGS_DIR |
| 140 | if [[ ${name} == 'onos-app-upgrade' ]]; then |
| 141 | export ONOS_APPS_UNDER_TEST+='' |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 142 | if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 143 | ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*" |
| 144 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 145 | if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 146 | ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*" |
| 147 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 148 | if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 149 | ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*" |
| 150 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 151 | if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 152 | ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*" |
| 153 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 154 | if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 155 | ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*" |
| 156 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 157 | if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 158 | ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*" |
| 159 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 160 | if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 161 | ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*" |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 162 | fi |
| 163 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch" |
| 164 | export TARGET=onos-app-upgrade-test |
| 165 | fi |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 166 | if [ ${name} == 'voltha-component-upgrade' ] || [ ${name} == 'voltha-component-rolling-upgrade' ]; then |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 167 | export VOLTHA_COMPS_UNDER_TEST+='' |
Hardik Windlass | 317ad02 | 2022-02-21 11:18:18 +0000 | [diff] [blame] | 168 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,voltha/voltha-openolt-adapter:${openolt_adapter_test_tag}*" |
| 169 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,voltha/voltha-openonu-adapter-go:${openonu_adapter_test_tag}*" |
| 170 | VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,voltha/voltha-rw-core:${rw_core_test_tag}*" |
| 171 | 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] | 172 | 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] | 173 | fi |
| 174 | if [[ ${name} == 'voltha-component-upgrade' ]]; then |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 175 | export TARGET=voltha-comp-upgrade-test |
| 176 | fi |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 177 | if [[ ${name} == 'voltha-component-rolling-upgrade' ]]; then |
| 178 | export TARGET=voltha-comp-rolling-upgrade-test |
| 179 | fi |
Hardik Windlass | 834afbb | 2021-03-23 11:48:15 +0530 | [diff] [blame] | 180 | if [[ ${name} == 'onu-software-upgrade' ]]; then |
Hardik Windlass | 8881454 | 2021-06-22 09:43:46 +0000 | [diff] [blame] | 181 | 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] | 182 | export TARGET=onu-upgrade-test |
| 183 | fi |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 184 | if [[ ${name} == 'onu-image-dwl-simultaneously' ]]; then |
| 185 | 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" |
| 186 | export TARGET=onu-upgrade-test-multiolt-kind-att |
| 187 | fi |
Hardik Windlass | 85491a0 | 2021-10-21 17:14:37 +0000 | [diff] [blame] | 188 | testLogging='False' |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 189 | if [ ${logging} = true ]; then |
Hardik Windlass | 85491a0 | 2021-10-21 17:14:37 +0000 | [diff] [blame] | 190 | testLogging='True' |
Hardik Windlass | cb95582 | 2021-10-21 14:59:11 +0000 | [diff] [blame] | 191 | fi |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 192 | export VOLTCONFIG=$HOME/.volt/config-minimal |
| 193 | export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 194 | 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] | 195 | # Run the specified tests |
| 196 | make -C $WORKSPACE/voltha-system-tests \$TARGET || true |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 197 | """ |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 198 | // remove port-forwarding |
| 199 | sh """ |
| 200 | # remove orphaned port-forward from different namespaces |
Andrea Campanella | 4c8af94 | 2021-05-12 10:12:13 +0200 | [diff] [blame] | 201 | 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] | 202 | """ |
| 203 | // collect pod details |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 204 | get_pods_info("$WORKSPACE/${name}") |
Hardik Windlass | dad8e5c | 2021-11-11 05:19:47 +0000 | [diff] [blame] | 205 | sh """ |
| 206 | set +e |
| 207 | # collect logs collected in the Robot Framework StartLogging keyword |
| 208 | cd ${logsDir} |
| 209 | gzip *-combined.log || true |
| 210 | rm *-combined.log || true |
| 211 | """ |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 212 | helmTeardown(['infra', 'voltha']) |
Matteo Scandolo | 4b04034 | 2021-10-08 14:26:06 -0700 | [diff] [blame] | 213 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 214 | } |
| 215 | } |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 216 | def get_pods_info(dest) { |
| 217 | // collect pod details, this is here in case of failure |
| 218 | sh """ |
Hardik Windlass | 3db9adf | 2021-03-25 15:49:45 +0530 | [diff] [blame] | 219 | mkdir -p ${dest} || true |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 220 | kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true |
| 221 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true |
| 222 | 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] | 223 | kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/voltha-pods-describe.txt |
| 224 | 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] | 225 | helm ls --all-namespaces > ${dest}/helm-charts.txt |
| 226 | """ |
Andrea Campanella | 5764e18 | 2021-03-18 14:17:59 +0100 | [diff] [blame] | 227 | sh ''' |
| 228 | # 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] | 229 | 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] | 230 | ''' |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 231 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 232 | pipeline { |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 233 | /* no label, executor is determined by JJB */ |
| 234 | agent { |
| 235 | label "${params.buildNode}" |
| 236 | } |
| 237 | options { |
Hardik Windlass | c87dbce | 2022-01-28 10:13:20 +0000 | [diff] [blame] | 238 | timeout(time: 150, unit: 'MINUTES') |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 239 | } |
| 240 | environment { |
| 241 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 242 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
Andrea Campanella | 9eeb4e7 | 2021-03-19 10:00:43 +0100 | [diff] [blame] | 243 | SSHPASS="karaf" |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 244 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 245 | stages{ |
| 246 | stage('Download Code') { |
| 247 | steps { |
| 248 | getVolthaCode([ |
| 249 | branch: "${branch}", |
| 250 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 251 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 252 | ]) |
| 253 | } |
| 254 | } |
Hardik Windlass | 834afbb | 2021-03-23 11:48:15 +0530 | [diff] [blame] | 255 | stage('Cleanup') { |
| 256 | steps { |
| 257 | // remove port-forwarding |
| 258 | sh """ |
| 259 | # remove orphaned port-forward from different namespaces |
Andrea Campanella | 4c8af94 | 2021-05-12 10:12:13 +0200 | [diff] [blame] | 260 | ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true |
Hardik Windlass | 834afbb | 2021-03-23 11:48:15 +0530 | [diff] [blame] | 261 | """ |
| 262 | helmTeardown(['infra', 'voltha']) |
| 263 | } |
| 264 | } |
Hardik Windlass | 9f5bee1 | 2021-05-07 06:47:21 +0000 | [diff] [blame] | 265 | stage('Create K8s Cluster') { |
| 266 | steps { |
| 267 | createKubernetesCluster([nodes: 3]) |
| 268 | } |
| 269 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 270 | stage('Run Test') { |
| 271 | steps { |
| 272 | test_software_upgrade("onos-app-upgrade") |
| 273 | test_software_upgrade("voltha-component-upgrade") |
Hardik Windlass | 1bb96a3 | 2022-01-19 10:10:08 +0000 | [diff] [blame] | 274 | test_software_upgrade("voltha-component-rolling-upgrade") |
Hardik Windlass | 834afbb | 2021-03-23 11:48:15 +0530 | [diff] [blame] | 275 | test_software_upgrade("onu-software-upgrade") |
TorstenThieme | cf20f4b | 2021-11-12 13:38:26 +0000 | [diff] [blame] | 276 | test_software_upgrade("onu-image-dwl-simultaneously") |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 280 | post { |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 281 | aborted { |
| 282 | get_pods_info("$WORKSPACE/failed") |
| 283 | } |
| 284 | failure { |
| 285 | get_pods_info("$WORKSPACE/failed") |
| 286 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 287 | always { |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 288 | step([$class: 'RobotPublisher', |
| 289 | disableArchiveOutput: false, |
| 290 | logFileName: 'RobotLogs/*/log*.html', |
| 291 | otherFiles: '', |
| 292 | outputFileName: 'RobotLogs/*/output*.xml', |
| 293 | outputPath: '.', |
| 294 | passThreshold: 100, |
| 295 | reportFileName: 'RobotLogs/*/report*.html', |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 296 | unstableThreshold: 0, |
| 297 | onlyCritical: true]); |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 298 | archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt' |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 299 | } |
| 300 | } |
| 301 | } |