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 | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 23 | def test_software_upgrade(name) { |
| 24 | stage('Deploy Voltha - '+ name) { |
| 25 | def extraHelmFlags = "${extraHelmFlags} --set global.log_level=DEBUG,onu=1,pon=1 " |
Hardik Windlass | a67cdbe | 2021-03-05 15:29:03 +0530 | [diff] [blame] | 26 | // TODO: ONOS custom image handling |
| 27 | // if [ '${onosImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-onos' ]; then |
| 28 | // IFS=: read -r onosRepo onosTag <<< '${onosImg.trim()}' |
| 29 | // extraHelmFlags = extraHelmFlags + "--set onos-classic.images.onos.repository=\$onosRepo,onos-classic.images.onos.tag=\$onosTag " |
| 30 | // fi |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 31 | def localCharts = false |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 32 | // Currently only testing with ATT workflow |
| 33 | // TODO: Support for other workflows |
| 34 | volthaDeploy([workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts]) |
| 35 | // start logging |
| 36 | sh """ |
| 37 | mkdir -p $WORKSPACE/${name} |
| 38 | _TAG=kail-${name} kail -n infra -n voltha > $WORKSPACE/${name}/onos-voltha-combined.log & |
| 39 | """ |
| 40 | // forward ONOS and VOLTHA ports |
| 41 | sh """ |
| 42 | _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8101:8101& |
| 43 | _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8181:8181& |
| 44 | _TAG=voltha-port-forward kubectl port-forward --address 0.0.0.0 -n voltha svc/voltha-voltha-api 55555:55555& |
| 45 | """ |
| 46 | } |
| 47 | stage('Test - '+ name) { |
| 48 | sh """ |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 49 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}" |
| 50 | mkdir -p \$ROBOT_LOGS_DIR |
| 51 | if [[ ${name} == 'onos-app-upgrade' ]]; then |
| 52 | export ONOS_APPS_UNDER_TEST+='' |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 53 | if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 54 | ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*" |
| 55 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 56 | if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 57 | ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*" |
| 58 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 59 | if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 60 | ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*" |
| 61 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 62 | if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 63 | ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*" |
| 64 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 65 | if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 66 | ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*" |
| 67 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 68 | if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 69 | ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*" |
| 70 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 71 | if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 72 | ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*" |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 73 | fi |
| 74 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch" |
| 75 | export TARGET=onos-app-upgrade-test |
| 76 | fi |
| 77 | if [[ ${name} == 'voltha-component-upgrade' ]]; then |
| 78 | export VOLTHA_COMPS_UNDER_TEST+='' |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 79 | if [ ${adapterOpenOltImage.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 80 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,${adapterOpenOltImage.trim()}*" |
| 81 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 82 | if [ ${adapterOpenOnuImage.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 83 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,${adapterOpenOnuImage.trim()}*" |
| 84 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 85 | if [ ${rwCoreImage.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 86 | VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,${rwCoreImage.trim()}*" |
| 87 | fi |
Hardik Windlass | b360f6e | 2021-03-09 17:46:21 +0530 | [diff] [blame] | 88 | if [ ${ofAgentImage.trim()} != '' ]; then |
Hardik Windlass | 98506e7 | 2021-03-09 14:29:17 +0530 | [diff] [blame] | 89 | VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,${ofAgentImage.trim()}*" |
Hardik Windlass | 25c8ddb | 2021-03-05 20:26:16 +0530 | [diff] [blame] | 90 | fi |
| 91 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch" |
| 92 | export TARGET=voltha-comp-upgrade-test |
| 93 | fi |
| 94 | export VOLTCONFIG=$HOME/.volt/config-minimal |
| 95 | export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal |
| 96 | # Run the specified tests |
| 97 | make -C $WORKSPACE/voltha-system-tests \$TARGET || true |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 98 | """ |
| 99 | // stop logging |
| 100 | sh """ |
| 101 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')" |
| 102 | if [ -n "\$P_IDS" ]; then |
| 103 | echo \$P_IDS |
| 104 | for P_ID in \$P_IDS; do |
| 105 | kill -9 \$P_ID |
| 106 | done |
| 107 | fi |
| 108 | """ |
| 109 | // remove port-forwarding |
| 110 | sh """ |
| 111 | # remove orphaned port-forward from different namespaces |
| 112 | ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 |
| 113 | """ |
| 114 | // collect pod details |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 115 | get_pods_info("$WORKSPACE/${name}") |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 116 | helmTeardown(['infra', 'voltha']) |
| 117 | } |
| 118 | } |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 119 | def get_pods_info(dest) { |
| 120 | // collect pod details, this is here in case of failure |
| 121 | sh """ |
| 122 | mkdir -p ${dest} |
| 123 | kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true |
| 124 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true |
| 125 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true |
| 126 | kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/pods-describe.txt |
| 127 | helm ls --all-namespaces > ${dest}/helm-charts.txt |
| 128 | """ |
| 129 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 130 | pipeline { |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 131 | /* no label, executor is determined by JJB */ |
| 132 | agent { |
| 133 | label "${params.buildNode}" |
| 134 | } |
| 135 | options { |
| 136 | timeout(time: 30, unit: 'MINUTES') |
| 137 | } |
| 138 | environment { |
| 139 | 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] | 140 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 141 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 142 | stages{ |
| 143 | stage('Download Code') { |
| 144 | steps { |
| 145 | getVolthaCode([ |
| 146 | branch: "${branch}", |
| 147 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 148 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 149 | ]) |
| 150 | } |
| 151 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 152 | stage('Run Test') { |
| 153 | steps { |
| 154 | test_software_upgrade("onos-app-upgrade") |
| 155 | test_software_upgrade("voltha-component-upgrade") |
| 156 | } |
| 157 | } |
| 158 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 159 | post { |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 160 | aborted { |
| 161 | get_pods_info("$WORKSPACE/failed") |
| 162 | } |
| 163 | failure { |
| 164 | get_pods_info("$WORKSPACE/failed") |
| 165 | } |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 166 | always { |
| 167 | sh ''' |
| 168 | gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true |
| 169 | gzip $WORKSPACE/voltha-component-upgrade/onos-voltha-combined.log || true |
| 170 | ''' |
| 171 | step([$class: 'RobotPublisher', |
| 172 | disableArchiveOutput: false, |
| 173 | logFileName: 'RobotLogs/*/log*.html', |
| 174 | otherFiles: '', |
| 175 | outputFileName: 'RobotLogs/*/output*.xml', |
| 176 | outputPath: '.', |
| 177 | passThreshold: 100, |
| 178 | reportFileName: 'RobotLogs/*/report*.html', |
| 179 | unstableThreshold: 0]); |
Hardik Windlass | 428f513 | 2021-03-15 12:17:47 +0530 | [diff] [blame] | 180 | archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt' |
Hardik Windlass | 0f9621d | 2021-02-24 21:23:19 +0530 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | } |