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