blob: 8a7d0ee48a052111209898fdb66b562b7867984c [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 Windlassa67cdbe2021-03-05 15:29:03 +053026 // TODO: ONOS custom image handling
27 // if [ '${onosImg.trim()}' != '' ] && [ '\$GERRIT_PROJECT' != 'voltha-onos' ]; then
28 // IFS=: read -r onosRepo onosTag <<< '${onosImg.trim()}'
29 // extraHelmFlags = extraHelmFlags + "--set onos-classic.images.onos.repository=\$onosRepo,onos-classic.images.onos.tag=\$onosTag "
30 // fi
Hardik Windlass0f9621d2021-02-24 21:23:19 +053031 def localCharts = false
Hardik Windlass0f9621d2021-02-24 21:23:19 +053032 // Currently only testing with ATT workflow
33 // TODO: Support for other workflows
34 volthaDeploy([workflow: "att", extraHelmFlags: extraHelmFlags, localCharts: localCharts])
35 // start logging
36 sh """
37 mkdir -p $WORKSPACE/${name}
38 _TAG=kail-${name} kail -n infra -n voltha > $WORKSPACE/${name}/onos-voltha-combined.log &
39 """
40 // forward ONOS and VOLTHA ports
41 sh """
42 _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8101:8101&
43 _TAG=onos-port-forward kubectl port-forward --address 0.0.0.0 -n infra svc/voltha-infra-onos-classic-hs 8181:8181&
44 _TAG=voltha-port-forward kubectl port-forward --address 0.0.0.0 -n voltha svc/voltha-voltha-api 55555:55555&
45 """
46 }
47 stage('Test - '+ name) {
48 sh """
Hardik Windlass25c8ddb2021-03-05 20:26:16 +053049 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name}"
50 mkdir -p \$ROBOT_LOGS_DIR
51 if [[ ${name} == 'onos-app-upgrade' ]]; then
52 export ONOS_APPS_UNDER_TEST+=''
53 if [[ ${aaaVer.trim()} != '' && ${aaaOarUrl.trim()} != '' ]]; then
54 ONOS_APPS_UNDER_TEST+="org.opencord.aaa,${aaaVer.trim()},${aaaOarUrl.trim()}"
55 fi
56 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onos_apps_under_test:\$ONOS_APPS_UNDER_TEST -e PowerSwitch"
57 export TARGET=onos-app-upgrade-test
58 fi
59 if [[ ${name} == 'voltha-component-upgrade' ]]; then
60 export VOLTHA_COMPS_UNDER_TEST+=''
61 if [[ ${adapterOpenOltImage.trim()} != '' ]]; then
62 VOLTHA_COMPS_UNDER_TEST+="adapter-open-olt,adapter-open-olt,${adapterOpenOltImage.trim()}"
63 fi
64 export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch"
65 export TARGET=voltha-comp-upgrade-test
66 fi
67 export VOLTCONFIG=$HOME/.volt/config-minimal
68 export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal
69 # Run the specified tests
70 make -C $WORKSPACE/voltha-system-tests \$TARGET || true
Hardik Windlass0f9621d2021-02-24 21:23:19 +053071 """
72 // stop logging
73 sh """
74 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')"
75 if [ -n "\$P_IDS" ]; then
76 echo \$P_IDS
77 for P_ID in \$P_IDS; do
78 kill -9 \$P_ID
79 done
80 fi
81 """
82 // remove port-forwarding
83 sh """
84 # remove orphaned port-forward from different namespaces
85 ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9
86 """
87 // collect pod details
88 sh """
89 kubectl get pods --all-namespaces -o wide > \$WORKSPACE/${name}/pods.txt || true
90 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee \$WORKSPACE/${name}/pod-images.txt || true
91 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee \$WORKSPACE/${name}/pod-imagesId.txt || true
92 """
93 helmTeardown(['infra', 'voltha'])
94 }
95}
Hardik Windlass0f9621d2021-02-24 21:23:19 +053096pipeline {
Hardik Windlass0f9621d2021-02-24 21:23:19 +053097 /* no label, executor is determined by JJB */
98 agent {
99 label "${params.buildNode}"
100 }
101 options {
102 timeout(time: 30, unit: 'MINUTES')
103 }
104 environment {
105 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 +0530106 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530107 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530108 stages{
109 stage('Download Code') {
110 steps {
111 getVolthaCode([
112 branch: "${branch}",
113 volthaSystemTestsChange: "${volthaSystemTestsChange}",
114 volthaHelmChartsChange: "${volthaHelmChartsChange}",
115 ])
116 }
117 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530118 stage('Run Test') {
119 steps {
120 test_software_upgrade("onos-app-upgrade")
121 test_software_upgrade("voltha-component-upgrade")
122 }
123 }
124 }
Hardik Windlass0f9621d2021-02-24 21:23:19 +0530125 post {
126 always {
127 sh '''
128 gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true
129 gzip $WORKSPACE/voltha-component-upgrade/onos-voltha-combined.log || true
130 '''
131 step([$class: 'RobotPublisher',
132 disableArchiveOutput: false,
133 logFileName: 'RobotLogs/*/log*.html',
134 otherFiles: '',
135 outputFileName: 'RobotLogs/*/output*.xml',
136 outputPath: '.',
137 passThreshold: 100,
138 reportFileName: 'RobotLogs/*/report*.html',
139 unstableThreshold: 0]);
140 archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz'
141 }
142 }
143}