blob: ccc0831ce835b46f0d00f29027c420bbcc68e3f4 [file] [log] [blame]
Kailash6f5acb62019-08-28 14:38:45 -07001// Copyright 2017-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
15node ("${TestNodeName}") {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070016 def withKind = false
17 if (params.withKind != null){
18 withKind = params.withKind
19 }
Andrea Campanella28bfb382020-04-09 11:14:14 +020020 def tech_prof_directory = "XGS_PON"
21 if (params.oltDebVersion.contains("asgvolt64")){
22 tech_prof_directory = "GPON"
23 }
Kailash6f5acb62019-08-28 14:38:45 -070024 timeout (100) {
25 try {
26 stage ("Parse deployment configuration file") {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070027 sh returnStdout: true, script: "rm -rf ${configBaseDir} voltha-system-tests kind-voltha"
Suchitra Vemurie514b8c2019-09-23 19:37:18 -070028 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070029 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests"
Andrea Campanellaf60f8832020-04-06 17:42:28 +020030 if (params.branch == "voltha-2.3") {
Suchitra Vemuri82bbd292020-04-08 21:09:39 -070031 sh returnStdout: true, script: "git clone -b 3.0.3 https://github.com/ciena/kind-voltha.git"
Andrea Campanellaf60f8832020-04-06 17:42:28 +020032 } else {
Suchitra Vemurie5536a82020-04-09 12:24:58 -070033 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/kind-voltha"
Andrea Campanellaf60f8832020-04-06 17:42:28 +020034 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070035 if ( params.workFlow == "DT" ) {
36 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
37 }
38 else
39 {
40 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
41 }
Kailash6f5acb62019-08-28 14:38:45 -070042 }
43 stage('Clean up') {
You Wang25e58612019-10-01 16:30:28 -070044 timeout(10) {
Kailash6f5acb62019-08-28 14:38:45 -070045 sh returnStdout: true, script: """
46 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070047 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
48 do
49 echo "Purging chart: \${hchart}"
50 helm delete --purge "\${hchart}"
51 done
Kailash6f5acb62019-08-28 14:38:45 -070052 """
53 timeout(5) {
54 waitUntil {
55 helm_deleted = sh returnStdout: true, script: """
56 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
57 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
58 """
59 return helm_deleted.toInteger() == 0
60 }
61 }
62 timeout(5) {
63 waitUntil {
64 kubectl_deleted = sh returnStdout: true, script: """
65 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
66 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
67 """
68 return kubectl_deleted.toInteger() == 0
69 }
70 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070071 timeout(1) {
Hung-Wei Chiu2fa15622020-04-07 16:40:35 -070072 sh returnStdout: false, script: """
73 #Remove all while true; do kubectl port-forward ...done; rules
74 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | grep "while true"| awk '{print \$1}'`;
75 do
76 cat /proc/\$port_fwd_id/cmdline
77 kill -9 \$port_fwd_id
78 done
79
80 #Remove all kubectl port-forward rules
81 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | awk '{print \$1}'`;
82 do
83 cat /proc/\$port_fwd_id/cmdline
84 kill -9 \$port_fwd_id
85 done
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070086 """
87 }
Kailash6f5acb62019-08-28 14:38:45 -070088 }
89 }
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080090 stage('Install Voltha') {
Kailash6f5acb62019-08-28 14:38:45 -070091 timeout(10) {
92 sh returnStdout: true, script: """
93 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
94 cd kind-voltha/
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070095 if [ "${branch}" != "master" ]; then
96 cd $WORKSPACE/kind-voltha
97 source releases/${branch}
Suchitra Vemurib9483862019-11-05 21:37:29 -080098 else
Andy Bavier7cee6f42019-11-05 16:49:47 -070099 export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml'
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800100 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -0700101
102 # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
hwchiu0a39d512020-04-04 05:00:29 +0000103 # JENKINS_NODE_COOKIE=dontKillMe ask Jenkins doesn't kill the proces after this job. we want the `while true; do kubectl port-forward` keep alive
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700104 if [[ "${workFlow}" == "DT" ]]; then
hwchiu0a39d512020-04-04 05:00:29 +0000105 JENKINS_NODE_COOKIE=dontKillMe ONOS_SSH_PORT=30115 ONOS_API_PORT=30120 VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no WITH_EAPOL=no WITH_DHCP=no WITH_IGMP=no WITH_RADIUS=no FANCY=0 ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700106 else
hwchiu0a39d512020-04-04 05:00:29 +0000107 JENKINS_NODE_COOKIE=dontKillMe ONOS_SSH_PORT=30115 ONOS_API_PORT=30120 VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_RADIUS=y WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no FANCY=0 ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700108 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -0700109
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800110 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
111 kubectl get nodes -o wide
112 kubectl get pods -n voltha -o wide
Kailash6f5acb62019-08-28 14:38:45 -0700113 """
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800114 }
Kailash6f5acb62019-08-28 14:38:45 -0700115 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700116 if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
117 stage('OpenFlow port forward for aggregation switch') {
118 timeout(1) {
119 sh returnStdout: true, script: """
120 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
121 #This uses the default route out, porperly configured is the management
122 mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
123 JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-openflow --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
124 """
125 }
126 }
127 }
128 if ( params.configurePod && params.profile != "Default" ) {
Suchitra Vemuri72680092019-10-03 12:39:20 -0700129 stage('Push Tech-Profile') {
130 timeout(1) {
131 out_push_tp = sh returnStatus: true, script: """
132 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
133 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
hwchiuc77c7d22019-10-18 13:58:35 -0700134 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
Andrea Campanella28bfb382020-04-09 11:14:14 +0200135 put_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
Suchitra Vemuri72680092019-10-03 12:39:20 -0700136 """
137 return out_push_tp == 0
138 }
139 timeout(1) {
140 out_get_tp = sh returnStatus: true, script: """
141 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Andrea Campanella28bfb382020-04-09 11:14:14 +0200142 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64')
Suchitra Vemuri72680092019-10-03 12:39:20 -0700143 """
144 return out_get_tp == 0
145 }
hwchiuc77c7d22019-10-18 13:58:35 -0700146 }
147 }
148 stage('Push Sadis-config') {
149 timeout(1) {
150 sadis_out = sh returnStatus: true, script: """
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700151 if [[ "${workFlow}" == "DT" ]]; then
152 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis-DT.json
153 else
Suchitra Vemuri72680092019-10-03 12:39:20 -0700154 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis.json
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700155 fi
156 """
157 return sadis_out == 0
You Wangb9526e62019-10-07 15:25:48 -0700158 }
hwchiuc77c7d22019-10-18 13:58:35 -0700159 }
Kailash6f5acb62019-08-28 14:38:45 -0700160 if ( params.reinstallOlt ) {
161 stage('Reinstall OLT software') {
162 for(int i=0; i < deployment_config.olts.size(); i++) {
163 sh returnStdout: true, script: """
Kailash6f5acb62019-08-28 14:38:45 -0700164 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700165 sleep 10
Kailash6f5acb62019-08-28 14:38:45 -0700166 """
167 timeout(5) {
168 waitUntil {
169 olt_sw_present = sh returnStdout: true, script: """
Andrea Campanellace9e9902020-04-07 18:29:42 +0200170 if [[ "${oltDebVersion}" == *"asfvolt16"* ]]; then
171 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
172 else
173 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asgvolt64 | wc -l'
174 fi
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700175 if ( ${deployment_config.olts[i].fortygig} ); then
176 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
177 fi
Kailash6f5acb62019-08-28 14:38:45 -0700178 """
Andrea Campanellace9e9902020-04-07 18:29:42 +0200179 return olt_sw_present.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700180 }
181 }
Kailash6f5acb62019-08-28 14:38:45 -0700182 }
183 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700184 stage('Restart OLT processes') {
Kailash6f5acb62019-08-28 14:38:45 -0700185 for(int i=0; i < deployment_config.olts.size(); i++) {
186 timeout(5) {
187 sh returnStdout: true, script: """
188 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700189 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true
190 sleep 120
Kailash6f5acb62019-08-28 14:38:45 -0700191 """
192 }
193 timeout(15) {
194 waitUntil {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700195 devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
196 return devprocess.toInteger() > 0
197 }
198 }
199 timeout(15) {
200 waitUntil {
201 openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep openolt | wc -l'"
202 return openoltprocess.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700203 }
204 }
205 }
206 }
207 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700208 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700209 stage('Switch Configurations in ONOS') {
210 timeout(1) {
211 netcfg_out = sh returnStatus: true, script: """
212 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json
213 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700214
You Wang25e58612019-10-01 16:30:28 -0700215 """
216 return netcfg_out == 0
217 }
218 timeout(1) {
219 waitUntil {
220 sr_active_out = sh returnStatus: true, script: """
You Wangeb76aeb2019-12-09 22:08:23 -0800221 ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115
Suchitra Vemuric3257262019-12-05 19:06:42 -0800222 ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts
223 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
224 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
225 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt"
You Wang25e58612019-10-01 16:30:28 -0700226 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700227 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.flow.impl.FlowRuleManager purgeOnDisconnection false"
Andrea Campanella086bcbb2020-04-01 09:56:23 +0200228 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.meter.impl.MeterManager purgeOnDisconnection false"
You Wang25e58612019-10-01 16:30:28 -0700229 """
230 return sr_active_out == 0
231 }
232 }
233 timeout(1) {
234 // FIXME support multiple OLTs
235 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
236 xconnect_out = sh returnStatus: true, script: """
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800237 version=\$(sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700238 sleep 10
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800239 if [[ \$version == *"version=2.2"* ]]; then
240 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "endpoints": [${deployment_config.fabric_switches[0].bngPort},${deployment_config.fabric_switches[0].oltPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
241 else
242 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "ports": [${deployment_config.fabric_switches[0].bngPort},${deployment_config.fabric_switches[0].oltPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
243 fi
You Wang25e58612019-10-01 16:30:28 -0700244 """
245 }
246 }
Kailash6f5acb62019-08-28 14:38:45 -0700247 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700248 }
Kailash6f5acb62019-08-28 14:38:45 -0700249 currentBuild.result = 'SUCCESS'
250 } catch (err) {
251 currentBuild.result = 'FAILURE'
252 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
253 throw err
254 }
255 echo "RESULT: ${currentBuild.result}"
256 }
257}