blob: 2a4d1cb7d7728876d10351fce8668b0458337d71 [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) {
25 def extraHelmFlags = "${extraHelmFlags} --set global.log_level=DEBUG,onu=1,pon=1 "
Hardik Windlassff97f652021-03-18 15:11:13 +053026 if ("${name}" == "onos-app-upgrade") {
27 extraHelmFlags = extraHelmFlags + "--set global.image_tag=master "
28 }
Hardik Windlassa67cdbe2021-03-05 15:29:03 +053029 // TODO: ONOS custom image handling
30 // if [ '${onosImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-onos' ]; then
31 // IFS=: read -r onosRepo onosTag <<< '${onosImg.trim()}'
32 // extraHelmFlags = extraHelmFlags + "--set onos-classic.images.onos.repository=\$onosRepo,onos-classic.images.onos.tag=\$onosTag "
33 // fi
Hardik Windlass0f9621d2021-02-24 21:23:19 +053034 def localCharts = false
Hardik Windlass0f9621d2021-02-24 21:23:19 +053035 // Currently only testing with ATT workflow
36 // TODO: Support for other workflows
37 volthaDeploy([workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts])
38 // start logging
39 sh """
40 mkdir -p $WORKSPACE/${name}
41 _TAG=kail-${name} kail -n infra -n voltha > $WORKSPACE/${name}/onos-voltha-combined.log &
42 """
43 // forward ONOS and VOLTHA ports
44 sh """
45 _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8101:8101&
46 _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8181:8181&
47 _TAG=voltha-port-forward kubectl port-forward --address 0.0.0.0 -n voltha svc/voltha-voltha-api 55555:55555&
48 """
49 }
50 stage('Test - '+ name) {
51 sh """
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053052 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}"
53 mkdir -p \$ROBOT_LOGS_DIR
54 if [[ ${name} == 'onos-app-upgrade' ]]; then
55 export ONOS_APPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +053056 if [ ${aaaVer.trim()} != '' ] && [ ${aaaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053057 ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}*"
58 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053059 if [ ${oltVer.trim()} != '' ] && [ ${oltOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053060 ONOS_APPS_UNDER_TEST+="org.opencord.olt,${oltVer.trim()},${oltOarUrl.trim()}*"
61 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053062 if [ ${dhcpl2relayVer.trim()} != '' ] && [ ${dhcpl2relayOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053063 ONOS_APPS_UNDER_TEST+="org.opencord.dhcpl2relay,${dhcpl2relayVer.trim()},${dhcpl2relayOarUrl.trim()}*"
64 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053065 if [ ${igmpproxyVer.trim()} != '' ] && [ ${igmpproxyOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053066 ONOS_APPS_UNDER_TEST+="org.opencord.igmpproxy,${igmpproxyVer.trim()},${igmpproxyOarUrl.trim()}*"
67 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053068 if [ ${sadisVer.trim()} != '' ] && [ ${sadisOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053069 ONOS_APPS_UNDER_TEST+="org.opencord.sadis,${sadisVer.trim()},${sadisOarUrl.trim()}*"
70 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053071 if [ ${mcastVer.trim()} != '' ] && [ ${mcastOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053072 ONOS_APPS_UNDER_TEST+="org.opencord.mcast,${mcastVer.trim()},${mcastOarUrl.trim()}*"
73 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053074 if [ ${kafkaVer.trim()} != '' ] && [ ${kafkaOarUrl.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053075 ONOS_APPS_UNDER_TEST+="org.opencord.kafka,${kafkaVer.trim()},${kafkaOarUrl.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053076 fi
77 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch"
78 export TARGET=onos-app-upgrade-test
79 fi
80 if [[ ${name} == 'voltha-component-upgrade' ]]; then
81 export VOLTHA_COMPS_UNDER_TEST+=''
Hardik Windlassb360f6e2021-03-09 17:46:21 +053082 if [ ${adapterOpenOltImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053083 VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,${adapterOpenOltImage.trim()}*"
84 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053085 if [ ${adapterOpenOnuImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053086 VOLTHA_COMPS_UNDER_TEST+="adapter-open-onu,adapter-open-onu,${adapterOpenOnuImage.trim()}*"
87 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053088 if [ ${rwCoreImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053089 VOLTHA_COMPS_UNDER_TEST+="rw-core,voltha,${rwCoreImage.trim()}*"
90 fi
Hardik Windlassb360f6e2021-03-09 17:46:21 +053091 if [ ${ofAgentImage.trim()} != '' ]; then
Hardik Windlass98506e72021-03-09 14:29:17 +053092 VOLTHA_COMPS_UNDER_TEST+="ofagent,ofagent,${ofAgentImage.trim()}*"
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053093 fi
94 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch"
95 export TARGET=voltha-comp-upgrade-test
96 fi
97 export VOLTCONFIG=$HOME/.volt/config-minimal
98 export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal
99 # Run the specified tests
100 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530101 """
102 // stop logging
103 sh """
104 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')"
105 if [ -n "\$P_IDS" ]; then
106 echo \$P_IDS
107 for P_ID in \$P_IDS; do
108 kill -9 \$P_ID
109 done
110 fi
111 """
112 // remove port-forwarding
113 sh """
114 # remove orphaned port-forward from different namespaces
115 ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9
116 """
117 // collect pod details
Hardik Windlass428f5132021-03-15 12:17:47 +0530118 get_pods_info("$WORKSPACE/${name}")
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530119 helmTeardown(['infra', 'voltha'])
120 }
121}
Hardik Windlass428f5132021-03-15 12:17:47 +0530122def get_pods_info(dest) {
123 // collect pod details, this is here in case of failure
124 sh """
125 mkdir -p ${dest}
126 kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true
127 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true
128 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true
129 kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/pods-describe.txt
130 helm ls --all-namespaces > ${dest}/helm-charts.txt
131 """
132}
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530133pipeline {
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530134 /* no label, executor is determined by JJB */
135 agent {
136 label "${params.buildNode}"
137 }
138 options {
139 timeout(time: 30, unit: 'MINUTES')
140 }
141 environment {
142 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 +0530143 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530144 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530145 stages{
146 stage('Download Code') {
147 steps {
148 getVolthaCode([
149 branch: "${branch}",
150 volthaSystemTestsChange: "${volthaSystemTestsChange}",
151 volthaHelmChartsChange: "${volthaHelmChartsChange}",
152 ])
153 }
154 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530155 stage('Run Test') {
156 steps {
157 test_software_upgrade("onos-app-upgrade")
158 test_software_upgrade("voltha-component-upgrade")
159 }
160 }
161 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530162 post {
Hardik Windlass428f5132021-03-15 12:17:47 +0530163 aborted {
164 get_pods_info("$WORKSPACE/failed")
165 }
166 failure {
167 get_pods_info("$WORKSPACE/failed")
168 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530169 always {
170 sh '''
171 gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true
172 gzip $WORKSPACE/voltha-component-upgrade/onos-voltha-combined.log || true
173 '''
174 step([$class: 'RobotPublisher',
175 disableArchiveOutput: false,
176 logFileName: 'RobotLogs/*/log*.html',
177 otherFiles: '',
178 outputFileName: 'RobotLogs/*/output*.xml',
179 outputPath: '.',
180 passThreshold: 100,
181 reportFileName: 'RobotLogs/*/report*.html',
182 unstableThreshold: 0]);
Hardik Windlass428f5132021-03-15 12:17:47 +0530183 archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt'
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530184 }
185 }
186}