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