blob: 27245102dcf0f917c8f401a179e4ad241ebd4632 [file] [log] [blame]
Hardik Windlass0f9621d2021-02-24 21:23:19 +05301// 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 Windlass0f9621d2021-02-24 21:23:19 +053014// voltha-2.x e2e tests
15// uses bbsim to simulate OLT/ONUs
Hardik Windlass0f9621d2021-02-24 21:23:19 +053016// NOTE we are importing the library even if it's global so that it's
17// easier to change the keywords during a replay
18library identifier: 'cord-jenkins-libraries@master',
19 retriever: modernSCM([
20 $class: 'GitSCMSource',
21 remote: 'https://gerrit.opencord.org/ci-management.git'
22])
Hardik Windlass0f9621d2021-02-24 21:23:19 +053023def test_software_upgrade(name) {
Hardik Windlass7e4e3152021-09-29 06:42:05 +000024 def infraNamespace = "infra"
25 def volthaNamespace = "voltha"
Hardik Windlass0f9621d2021-02-24 21:23:19 +053026 stage('Deploy Voltha - '+ name) {
Matteo Scandolo4b040342021-10-08 14:26:06 -070027 timeout(10) {
Hardik Windlasscb955822021-10-21 14:59:11 +000028 // start logging
29 sh """
30 rm -rf $WORKSPACE/${name} || true
31 mkdir -p $WORKSPACE/${name}
32 _TAG=kail-${name} kail -n ${infraNamespace} -n ${volthaNamespace} > $WORKSPACE/${name}/onos-voltha-startup-combined.log &
33 """
Andrea Campanella9e41a602021-09-14 14:45:11 +020034 def extraHelmFlags = extraHelmFlags.trim()
Hardik Windlasscb955822021-10-21 14:59:11 +000035 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel.toUpperCase()},onu=1,pon=1 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 "
Hardik Windlassd87caad2021-05-06 06:55:09 +000036 if ("${name}" == "onos-app-upgrade" || "${name}" == "onu-software-upgrade") {
37 extraHelmFlags = extraHelmFlags + "--set global.image_tag=master --set onos-classic.image.tag=master "
38 }
39 if ("${name}" == "voltha-component-upgrade") {
40 extraHelmFlags = extraHelmFlags + "--set images.onos_config_loader.tag=master-onos-config-loader --set onos-classic.image.tag=master "
Hardik Windlassff97f652021-03-18 15:11:13 +053041 }
Andrea Campanella834f27b2021-06-08 17:08:41 +020042 extraHelmFlags = extraHelmFlags + " --set onos-classic.onosSshPort=30115 --set onos-classic.onosApiPort=30120 "
43 extraHelmFlags = extraHelmFlags + " --set voltha.onos_classic.replicas=3"
Andrea Campanella5764e182021-03-18 14:17:59 +010044 //ONOS custom image handling
45 if ( onosImg.trim() != '' ) {
46 String[] split;
47 onosImg = onosImg.trim()
48 split = onosImg.split(':')
Andrea Campanellaea2379a2021-03-22 13:56:26 +010049 extraHelmFlags = extraHelmFlags + "--set onos-classic.image.repository=" + split[0] +",onos-classic.image.tag=" + split[1] + " "
Andrea Campanella5764e182021-03-18 14:17:59 +010050 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +053051 def localCharts = false
Hardik Windlass0f9621d2021-02-24 21:23:19 +053052 // Currently only testing with ATT workflow
53 // TODO: Support for other workflows
54 volthaDeploy([workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts])
Hardik Windlasscb955822021-10-21 14:59:11 +000055 // stop logging
Hardik Windlass0f9621d2021-02-24 21:23:19 +053056 sh """
Hardik Windlasscb955822021-10-21 14:59:11 +000057 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')"
58 if [ -n "\$P_IDS" ]; then
59 echo \$P_IDS
60 for P_ID in \$P_IDS; do
61 kill -9 \$P_ID
62 done
63 fi
64 cd $WORKSPACE/${name}/
65 gzip -k onos-voltha-startup-combined.log
66 rm onos-voltha-startup-combined.log
Hardik Windlass0f9621d2021-02-24 21:23:19 +053067 """
68 // forward ONOS and VOLTHA ports
69 sh """
Andrea Campanella1b7c0942021-09-14 11:02:58 +020070 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 " &
71 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 " &
72 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 Windlass0f9621d2021-02-24 21:23:19 +053073 """
Andrea Campanella9eeb4e72021-03-19 10:00:43 +010074 sh """
75 sshpass -e ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 log:set DEBUG org.opencord
76 """
Matteo Scandolo4b040342021-10-08 14:26:06 -070077 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +053078 }
79 stage('Test - '+ name) {
Andrea Campanella371c6512021-10-11 14:55:32 +020080 timeout(40) {
Hardik Windlass0f9621d2021-02-24 21:23:19 +053081 sh """
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053082 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}"
83 mkdir -p \$ROBOT_LOGS_DIR
84 if [[ ${name} == 'onos-app-upgrade' ]]; then
85 export ONOS_APPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +053086 if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053087 ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*"
88 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053089 if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053090 ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*"
91 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053092 if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053093 ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*"
94 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053095 if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053096 ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*"
97 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053098 if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053099 ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*"
100 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530101 if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530102 ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*"
103 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530104 if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530105 ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530106 fi
107 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch"
108 export TARGET=onos-app-upgrade-test
109 fi
110 if [[ ${name} == 'voltha-component-upgrade' ]]; then
111 export VOLTHA_COMPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530112 if [ ${adapterOpenOltImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530113 VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,${adapterOpenOltImage.trim()}*"
114 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530115 if [ ${adapterOpenOnuImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530116 VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,${adapterOpenOnuImage.trim()}*"
117 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530118 if [ ${rwCoreImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530119 VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,${rwCoreImage.trim()}*"
120 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530121 if [ ${ofAgentImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530122 VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,${ofAgentImage.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530123 fi
124 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch"
125 export TARGET=voltha-comp-upgrade-test
126 fi
Hardik Windlass834afbb2021-03-23 11:48:15 +0530127 if [[ ${name} == 'onu-software-upgrade' ]]; then
Hardik Windlass88814542021-06-22 09:43:46 +0000128 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 Windlass834afbb2021-03-23 11:48:15 +0530129 export TARGET=onu-upgrade-test
130 fi
Hardik Windlass85491a02021-10-21 17:14:37 +0000131 testLogging='False'
Hardik Windlasscb955822021-10-21 14:59:11 +0000132 if [ ${logging} = true ]; then
Hardik Windlass85491a02021-10-21 17:14:37 +0000133 testLogging='True'
Hardik Windlasscb955822021-10-21 14:59:11 +0000134 fi
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530135 export VOLTCONFIG=$HOME/.volt/config-minimal
136 export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal
Hardik Windlass85491a02021-10-21 17:14:37 +0000137 ROBOT_MISC_ARGS+=" -v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120 -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace} -v container_log_dir:$WORKSPACE/RobotLogs/${name} -v logging:\$testLogging"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530138 # Run the specified tests
139 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530140 """
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530141 // remove port-forwarding
142 sh """
143 # remove orphaned port-forward from different namespaces
Andrea Campanella4c8af942021-05-12 10:12:13 +0200144 ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530145 """
146 // collect pod details
Hardik Windlass428f5132021-03-15 12:17:47 +0530147 get_pods_info("$WORKSPACE/${name}")
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530148 helmTeardown(['infra', 'voltha'])
Matteo Scandolo4b040342021-10-08 14:26:06 -0700149 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530150 }
151}
Hardik Windlass428f5132021-03-15 12:17:47 +0530152def get_pods_info(dest) {
153 // collect pod details, this is here in case of failure
154 sh """
Hardik Windlass3db9adf2021-03-25 15:49:45 +0530155 mkdir -p ${dest} || true
Hardik Windlass428f5132021-03-15 12:17:47 +0530156 kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true
157 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true
158 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true
Andrea Campanellaea2379a2021-03-22 13:56:26 +0100159 kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/voltha-pods-describe.txt
160 kubectl describe pods -n infra -l app=onos-classic > ${dest}/onos-pods-describe.txt
Hardik Windlass428f5132021-03-15 12:17:47 +0530161 helm ls --all-namespaces > ${dest}/helm-charts.txt
162 """
Andrea Campanella5764e182021-03-18 14:17:59 +0100163 sh '''
164 # copy the ONOS logs directly from the container to avoid the color codes
Andrea Campanella9eeb4e72021-03-19 10:00:43 +0100165 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
Andrea Campanella5764e182021-03-18 14:17:59 +0100166 '''
Hardik Windlass428f5132021-03-15 12:17:47 +0530167}
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530168pipeline {
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530169 /* no label, executor is determined by JJB */
170 agent {
171 label "${params.buildNode}"
172 }
173 options {
Andrea Campanella371c6512021-10-11 14:55:32 +0200174 timeout(time: 90, unit: 'MINUTES')
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530175 }
176 environment {
177 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530178 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
Andrea Campanella9eeb4e72021-03-19 10:00:43 +0100179 SSHPASS="karaf"
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530180 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530181 stages{
182 stage('Download Code') {
183 steps {
184 getVolthaCode([
185 branch: "${branch}",
186 volthaSystemTestsChange: "${volthaSystemTestsChange}",
187 volthaHelmChartsChange: "${volthaHelmChartsChange}",
188 ])
189 }
190 }
Hardik Windlass834afbb2021-03-23 11:48:15 +0530191 stage('Cleanup') {
192 steps {
193 // remove port-forwarding
194 sh """
195 # remove orphaned port-forward from different namespaces
Andrea Campanella4c8af942021-05-12 10:12:13 +0200196 ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 || true
Hardik Windlass834afbb2021-03-23 11:48:15 +0530197 """
198 helmTeardown(['infra', 'voltha'])
199 }
200 }
Hardik Windlass9f5bee12021-05-07 06:47:21 +0000201 stage('Create K8s Cluster') {
202 steps {
203 createKubernetesCluster([nodes: 3])
204 }
205 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530206 stage('Run Test') {
207 steps {
208 test_software_upgrade("onos-app-upgrade")
209 test_software_upgrade("voltha-component-upgrade")
Hardik Windlass834afbb2021-03-23 11:48:15 +0530210 test_software_upgrade("onu-software-upgrade")
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530211 }
212 }
213 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530214 post {
Hardik Windlass428f5132021-03-15 12:17:47 +0530215 aborted {
216 get_pods_info("$WORKSPACE/failed")
217 }
218 failure {
219 get_pods_info("$WORKSPACE/failed")
220 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530221 always {
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530222 step([$class: 'RobotPublisher',
223 disableArchiveOutput: false,
224 logFileName: 'RobotLogs/*/log*.html',
225 otherFiles: '',
226 outputFileName: 'RobotLogs/*/output*.xml',
227 outputPath: '.',
228 passThreshold: 100,
229 reportFileName: 'RobotLogs/*/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200230 unstableThreshold: 0,
231 onlyCritical: true]);
Hardik Windlass428f5132021-03-15 12:17:47 +0530232 archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt'
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530233 }
234 }
235}