blob: 8cb4a8a0b33b413b57bec1cbcc515575a7edebec [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) {
24 stage('Deploy Voltha - '+ name) {
Andrea Campanella5764e182021-03-18 14:17:59 +010025 def extraHelmFlags = "${extraHelmFlags} --set global.log_level=DEBUG,onu=1,pon=1 --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 "
Hardik Windlassff97f652021-03-18 15:11:13 +053026 if ("${name}" == "onos-app-upgrade") {
27 extraHelmFlags = extraHelmFlags + "--set global.image_tag=master "
28 }
Andrea Campanella5764e182021-03-18 14:17:59 +010029 extraHelmFlags = extraHelmFlags + """ --set voltha.services.controller[0].service=voltha-infra-onos-classic-0.voltha-infra-onos-classic-hs.infra.svc \
30 --set voltha.services.controller[0].port=6653 \
31 --set voltha.services.controller[0].address=voltha-infra-onos-classic-0.voltha-infra-onos-classic-hs.infra.svc:6653 \
32 --set voltha.services.controller[1].service=voltha-infra-onos-classic-1.voltha-infra-onos-classic-hs.infra.svc \
33 --set voltha.services.controller[1].port=6653 \
34 --set voltha.services.controller[1].address=voltha-infra-onos-classic-1.voltha-infra-onos-classic-hs.infra.svc:6653 \
35 --set voltha.services.controller[2].service=voltha-infra-onos-classic-2.voltha-infra-onos-classic-hs.infra.svc \
36 --set voltha.services.controller[2].port=6653 \
37 --set voltha.services.controller[2].address=voltha-infra-onos-classic-2.voltha-infra-onos-classic-hs.infra.svc:6653 """
38 //ONOS custom image handling
39 if ( onosImg.trim() != '' ) {
40 String[] split;
41 onosImg = onosImg.trim()
42 split = onosImg.split(':')
43 extraHelmFlags = extraHelmFlags + "--set onos-classic.images.onos.repository=" + split[0] +",onos-classic.images.onos.tag=" + split[1] + " "
44 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +053045 def localCharts = false
Hardik Windlass0f9621d2021-02-24 21:23:19 +053046 // Currently only testing with ATT workflow
47 // TODO: Support for other workflows
48 volthaDeploy([workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts])
49 // start logging
50 sh """
51 mkdir -p $WORKSPACE/${name}
52 _TAG=kail-${name} kail -n infra -n voltha > $WORKSPACE/${name}/onos-voltha-combined.log &
53 """
54 // forward ONOS and VOLTHA ports
55 sh """
56 _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8101:8101&
57 _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8181:8181&
58 _TAG=voltha-port-forward kubectl port-forward --address 0.0.0.0 -n voltha svc/voltha-voltha-api 55555:55555&
59 """
60 }
61 stage('Test - '+ name) {
62 sh """
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053063 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}"
64 mkdir -p \$ROBOT_LOGS_DIR
65 if [[ ${name} == 'onos-app-upgrade' ]]; then
66 export ONOS_APPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +053067 if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053068 ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*"
69 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053070 if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053071 ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*"
72 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053073 if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053074 ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*"
75 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053076 if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053077 ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*"
78 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053079 if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053080 ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*"
81 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053082 if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053083 ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*"
84 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053085 if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053086 ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053087 fi
88 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch"
89 export TARGET=onos-app-upgrade-test
90 fi
91 if [[ ${name} == 'voltha-component-upgrade' ]]; then
92 export VOLTHA_COMPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +053093 if [ ${adapterOpenOltImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053094 VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,${adapterOpenOltImage.trim()}*"
95 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053096 if [ ${adapterOpenOnuImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053097 VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,${adapterOpenOnuImage.trim()}*"
98 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053099 if [ ${rwCoreImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530100 VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,${rwCoreImage.trim()}*"
101 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +0530102 if [ ${ofAgentImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +0530103 VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,${ofAgentImage.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +0530104 fi
105 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch"
106 export TARGET=voltha-comp-upgrade-test
107 fi
108 export VOLTCONFIG=$HOME/.volt/config-minimal
109 export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal
110 # Run the specified tests
111 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530112 """
113 // stop logging
114 sh """
115 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')"
116 if [ -n "\$P_IDS" ]; then
117 echo \$P_IDS
118 for P_ID in \$P_IDS; do
119 kill -9 \$P_ID
120 done
121 fi
122 """
123 // remove port-forwarding
124 sh """
125 # remove orphaned port-forward from different namespaces
126 ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9
127 """
128 // collect pod details
Hardik Windlass428f5132021-03-15 12:17:47 +0530129 get_pods_info("$WORKSPACE/${name}")
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530130 helmTeardown(['infra', 'voltha'])
131 }
132}
Hardik Windlass428f5132021-03-15 12:17:47 +0530133def get_pods_info(dest) {
134 // collect pod details, this is here in case of failure
135 sh """
136 mkdir -p ${dest}
137 kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true
138 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true
139 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true
140 kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/pods-describe.txt
141 helm ls --all-namespaces > ${dest}/helm-charts.txt
142 """
Andrea Campanella5764e182021-03-18 14:17:59 +0100143 sh '''
144 # copy the ONOS logs directly from the container to avoid the color codes
145 printf '%s\n' $(kubectl get pods -l app=onos-classic -o=jsonpath="{.items[*]['metadata.name']}") | xargs --no-run-if-empty -I# bash -c "kubectl cp #:${karafHome}/data/log/karaf.log ${dest}/#.log" || true
146 '''
Hardik Windlass428f5132021-03-15 12:17:47 +0530147}
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530148pipeline {
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530149 /* no label, executor is determined by JJB */
150 agent {
151 label "${params.buildNode}"
152 }
153 options {
154 timeout(time: 30, unit: 'MINUTES')
155 }
156 environment {
157 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 +0530158 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530159 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530160 stages{
161 stage('Download Code') {
162 steps {
163 getVolthaCode([
164 branch: "${branch}",
165 volthaSystemTestsChange: "${volthaSystemTestsChange}",
166 volthaHelmChartsChange: "${volthaHelmChartsChange}",
167 ])
168 }
169 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530170 stage('Run Test') {
171 steps {
172 test_software_upgrade("onos-app-upgrade")
173 test_software_upgrade("voltha-component-upgrade")
174 }
175 }
176 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530177 post {
Hardik Windlass428f5132021-03-15 12:17:47 +0530178 aborted {
179 get_pods_info("$WORKSPACE/failed")
180 }
181 failure {
182 get_pods_info("$WORKSPACE/failed")
183 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530184 always {
185 sh '''
186 gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true
187 gzip $WORKSPACE/voltha-component-upgrade/onos-voltha-combined.log || true
188 '''
189 step([$class: 'RobotPublisher',
190 disableArchiveOutput: false,
191 logFileName: 'RobotLogs/*/log*.html',
192 otherFiles: '',
193 outputFileName: 'RobotLogs/*/output*.xml',
194 outputPath: '.',
195 passThreshold: 100,
196 reportFileName: 'RobotLogs/*/report*.html',
197 unstableThreshold: 0]);
Hardik Windlass428f5132021-03-15 12:17:47 +0530198 archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt'
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530199 }
200 }
201}