Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [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. |
| 14 | // voltha-2.x e2e tests |
| 15 | // uses bbsim to simulate OLT/ONUs |
| 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 | ]) |
| 23 | def test_software_upgrade(name) { |
| 24 | stage('Deploy Voltha - '+ name) { |
Andrea Campanella | 9e41a60 | 2021-09-14 14:45:11 +0200 | [diff] [blame] | 25 | def extraHelmFlags = extraHelmFlags.trim() |
| 26 | extraHelmFlags = extraHelmFlags + " --set global.log_level=DEBUG,onu=1,pon=1 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 " |
Hardik Windlass | 6d9a82e | 2021-07-08 16:23:21 +0000 | [diff] [blame] | 27 | if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade") { |
| 28 | extraHelmFlags = extraHelmFlags + "--set global.image_tag=master --set onos-classic.image.tag=master " |
| 29 | } |
| 30 | if ("${name}" == "voltha-component-upgrade") { |
| 31 | extraHelmFlags = extraHelmFlags + "--set images.onos_config_loader.tag=master-onos-config-loader --set onos-classic.image.tag=master " |
| 32 | } |
Andrea Campanella | 834f27b | 2021-06-08 17:08:41 +0200 | [diff] [blame] | 33 | extraHelmFlags = extraHelmFlags + " --set onos-classic.onosSshPort=30115 --set onos-classic.onosApiPort=30120 " |
Hardik Windlass | 6d9a82e | 2021-07-08 16:23:21 +0000 | [diff] [blame] | 34 | extraHelmFlags = extraHelmFlags + " --set voltha.onos_classic.replicas=3" |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 35 | //ONOS custom image handling |
| 36 | if ( onosImg.trim() != '' ) { |
| 37 | String[] split; |
| 38 | onosImg = onosImg.trim() |
| 39 | split = onosImg.split(':') |
| 40 | extraHelmFlags = extraHelmFlags + "--set onos-classic.image.repository=" + split[0] +",onos-classic.image.tag=" + split[1] + " " |
| 41 | } |
Hardik Windlass | 6d9a82e | 2021-07-08 16:23:21 +0000 | [diff] [blame] | 42 | def localCharts = false |
| 43 | if (branch != "master") { |
| 44 | localCharts = true |
| 45 | } |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 46 | // Currently only testing with ATT workflow |
| 47 | // TODO: Support for other workflows |
Hardik Windlass | 6d9a82e | 2021-07-08 16:23:21 +0000 | [diff] [blame] | 48 | volthaDeploy([workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts]) |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 49 | // start logging |
| 50 | sh """ |
| 51 | rm -rf $WORKSPACE/${name} || true |
| 52 | mkdir -p $WORKSPACE/${name} |
| 53 | _TAG=kail-${name} kail -n infra -n voltha > $WORKSPACE/${name}/onos-voltha-combined.log & |
| 54 | """ |
| 55 | // forward ONOS and VOLTHA ports |
| 56 | sh """ |
| 57 | _TAG=onos-port-forward bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8101:8101; done &" |
| 58 | _TAG=onos-port-forward bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8181:8181; done &" |
| 59 | _TAG=port-forward-voltha-api bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n voltha svc/voltha-voltha-api 55555:55555; done &" |
| 60 | """ |
| 61 | sh """ |
| 62 | sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 log:set DEBUG org.opencord |
| 63 | """ |
| 64 | } |
| 65 | stage('Test - '+ name) { |
| 66 | sh """ |
| 67 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}" |
| 68 | mkdir -p \$ROBOT_LOGS_DIR |
| 69 | if [[ ${name} == 'onos-app-upgrade' ]]; then |
| 70 | export ONOS_APPS_UNDER_TEST+='' |
| 71 | if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then |
| 72 | ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*" |
| 73 | fi |
| 74 | if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then |
| 75 | ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*" |
| 76 | fi |
| 77 | if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then |
| 78 | ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*" |
| 79 | fi |
| 80 | if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then |
| 81 | ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*" |
| 82 | fi |
| 83 | if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then |
| 84 | ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*" |
| 85 | fi |
| 86 | if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then |
| 87 | ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*" |
| 88 | fi |
| 89 | if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then |
| 90 | ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*" |
| 91 | fi |
| 92 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch" |
| 93 | export TARGET=onos-app-upgrade-test |
| 94 | fi |
| 95 | if [[ ${name} == 'voltha-component-upgrade' ]]; then |
| 96 | export VOLTHA_COMPS_UNDER_TEST+='' |
| 97 | if [ ${adapterOpenOltImage.trim()} != '' ]; then |
| 98 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,${adapterOpenOltImage.trim()}*" |
| 99 | fi |
| 100 | if [ ${adapterOpenOnuImage.trim()} != '' ]; then |
| 101 | VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,${adapterOpenOnuImage.trim()}*" |
| 102 | fi |
| 103 | if [ ${rwCoreImage.trim()} != '' ]; then |
| 104 | VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,${rwCoreImage.trim()}*" |
| 105 | fi |
| 106 | if [ ${ofAgentImage.trim()} != '' ]; then |
| 107 | VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,${ofAgentImage.trim()}*" |
| 108 | fi |
| 109 | export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch" |
| 110 | export TARGET=voltha-comp-upgrade-test |
| 111 | fi |
| 112 | if [[ ${name} == 'onu-software-upgrade' ]]; then |
Hardik Windlass | 6d9a82e | 2021-07-08 16:23:21 +0000 | [diff] [blame] | 113 | 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" |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 114 | export TARGET=onu-upgrade-test |
| 115 | fi |
| 116 | export VOLTCONFIG=$HOME/.volt/config-minimal |
| 117 | export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal |
Andrea Campanella | 834f27b | 2021-06-08 17:08:41 +0200 | [diff] [blame] | 118 | ROBOT_MISC_ARGS+=" -v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120" |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 119 | # Run the specified tests |
| 120 | make -C $WORKSPACE/voltha-system-tests \$TARGET || true |
| 121 | """ |
| 122 | // stop logging |
| 123 | sh """ |
| 124 | P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')" |
| 125 | if [ -n "\$P_IDS" ]; then |
| 126 | echo \$P_IDS |
| 127 | for P_ID in \$P_IDS; do |
| 128 | kill -9 \$P_ID |
| 129 | done |
| 130 | fi |
| 131 | """ |
| 132 | // remove port-forwarding |
| 133 | sh """ |
| 134 | # remove orphaned port-forward from different namespaces |
Andrea Campanella | 4c8af94 | 2021-05-12 10:12:13 +0200 | [diff] [blame] | 135 | ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 136 | """ |
| 137 | // collect pod details |
| 138 | get_pods_info("$WORKSPACE/${name}") |
| 139 | helmTeardown(['infra', 'voltha']) |
| 140 | } |
| 141 | } |
| 142 | def get_pods_info(dest) { |
| 143 | // collect pod details, this is here in case of failure |
| 144 | sh """ |
| 145 | mkdir -p ${dest} || true |
| 146 | kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true |
| 147 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true |
| 148 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true |
| 149 | kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/voltha-pods-describe.txt |
| 150 | kubectl describe pods -n infra -l app=onos-classic > ${dest}/onos-pods-describe.txt |
| 151 | helm ls --all-namespaces > ${dest}/helm-charts.txt |
| 152 | """ |
| 153 | sh ''' |
| 154 | # copy the ONOS logs directly from the container to avoid the color codes |
| 155 | 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.9/data/log/karaf.log ''' + dest + '''/#.log' || true |
| 156 | ''' |
| 157 | } |
| 158 | pipeline { |
| 159 | /* no label, executor is determined by JJB */ |
| 160 | agent { |
| 161 | label "${params.buildNode}" |
| 162 | } |
| 163 | options { |
Hardik Windlass | 973230d | 2021-05-17 11:08:59 +0530 | [diff] [blame] | 164 | timeout(time: 60, unit: 'MINUTES') |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 165 | } |
| 166 | environment { |
| 167 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
| 168 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 169 | SSHPASS="karaf" |
| 170 | } |
| 171 | stages{ |
| 172 | stage('Download Code') { |
| 173 | steps { |
| 174 | getVolthaCode([ |
| 175 | branch: "${branch}", |
| 176 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 177 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 178 | ]) |
| 179 | } |
| 180 | } |
| 181 | stage('Cleanup') { |
| 182 | steps { |
| 183 | // remove port-forwarding |
| 184 | sh """ |
| 185 | # remove orphaned port-forward from different namespaces |
Andrea Campanella | 4c8af94 | 2021-05-12 10:12:13 +0200 | [diff] [blame] | 186 | ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 187 | """ |
| 188 | helmTeardown(['infra', 'voltha']) |
| 189 | } |
| 190 | } |
Hardik Windlass | 9f5bee1 | 2021-05-07 06:47:21 +0000 | [diff] [blame] | 191 | stage('Create K8s Cluster') { |
| 192 | steps { |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 193 | createKubernetesCluster([branch: "${branch}", nodes: 3]) |
Hardik Windlass | 9f5bee1 | 2021-05-07 06:47:21 +0000 | [diff] [blame] | 194 | } |
| 195 | } |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 196 | stage('Run Test') { |
| 197 | steps { |
| 198 | test_software_upgrade("onos-app-upgrade") |
| 199 | test_software_upgrade("voltha-component-upgrade") |
| 200 | test_software_upgrade("onu-software-upgrade") |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | post { |
| 205 | aborted { |
| 206 | get_pods_info("$WORKSPACE/failed") |
| 207 | } |
| 208 | failure { |
| 209 | get_pods_info("$WORKSPACE/failed") |
| 210 | } |
| 211 | always { |
| 212 | sh ''' |
| 213 | gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true |
| 214 | gzip $WORKSPACE/voltha-component-upgrade/onos-voltha-combined.log || true |
| 215 | gzip $WORKSPACE/onu-software-upgrade/onos-voltha-combined.log || true |
| 216 | ''' |
| 217 | step([$class: 'RobotPublisher', |
| 218 | disableArchiveOutput: false, |
| 219 | logFileName: 'RobotLogs/*/log*.html', |
| 220 | otherFiles: '', |
| 221 | outputFileName: 'RobotLogs/*/output*.xml', |
| 222 | outputPath: '.', |
| 223 | passThreshold: 100, |
| 224 | reportFileName: 'RobotLogs/*/report*.html', |
Hardik Windlass | 6d9a82e | 2021-07-08 16:23:21 +0000 | [diff] [blame] | 225 | unstableThreshold: 0, |
| 226 | onlyCritical: true]); |
Matteo Scandolo | f593a0f | 2021-04-14 10:16:06 -0700 | [diff] [blame] | 227 | archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt' |
| 228 | } |
| 229 | } |
| 230 | } |