blob: 59edb8a47b925352a93efe7a9b79b76d22fd04c9 [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
Andy Bavieraf5883e2020-06-03 12:54:21 -070017 def VolthaEtcdPort = '2379'
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070018 if (params.withKind != null){
19 withKind = params.withKind
20 }
Andy Bavieraf5883e2020-06-03 12:54:21 -070021 if (params.VolthaEtcdPort != null){
22 VolthaEtcdPort = params.VolthaEtcdPort
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"
Suchitra Vemuria9562212020-04-10 19:32:03 -070030 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/kind-voltha"
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070031 if ( params.workFlow == "DT" ) {
32 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
33 }
Suchitra Vemuri32dea012020-07-08 16:40:06 -070034 else if ( params.workFlow == "TT" )
35 {
36 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
37 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070038 else
39 {
40 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
41 }
Kailash6f5acb62019-08-28 14:38:45 -070042 }
43 stage('Clean up') {
Suchitra Vemuri76261d02020-05-08 16:33:32 -070044 timeout(15) {
Kailash6f5acb62019-08-28 14:38:45 -070045 sh returnStdout: true, script: """
Andrea Campanellad9891e62020-07-24 16:14:22 +020046 echo "cleaning up"
Kailash6f5acb62019-08-28 14:38:45 -070047 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanellad9891e62020-07-24 16:14:22 +020048 HELM_MAJOR=\$(helm version --client --short | sed -E -e 's/^.*v([0-9]+)\\.[0-9]+\\.[0-9]+.*\$/\\1/')
49 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage');
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070050 do
51 echo "Purging chart: \${hchart}"
Andrea Campanellad9891e62020-07-24 16:14:22 +020052 if [ \$HELM_MAJOR -le 2 ]; then
53 helm delete --purge "\${hchart}"
54 else
55 helm uninstall "\${hchart}"
56 fi
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070057 done
Andrea Campanellad9891e62020-07-24 16:14:22 +020058 if [ \$HELM_MAJOR -gt 2 ]; then
59 for hchart in \$(helm list -q -n voltha | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage');
60 do
61 echo "Purging chart: \${hchart}"
62 if [ \$HELM_MAJOR -le 2 ]; then
63 helm delete --purge "\${hchart}"
64 else
65 helm uninstall -n voltha "\${hchart}"
66 fi
67 done
68 fi
Kailash6f5acb62019-08-28 14:38:45 -070069 """
70 timeout(5) {
71 waitUntil {
72 helm_deleted = sh returnStdout: true, script: """
73 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Andrea Campanellad9891e62020-07-24 16:14:22 +020074 helm list -q --all-namespaces | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage' | wc -l
Kailash6f5acb62019-08-28 14:38:45 -070075 """
76 return helm_deleted.toInteger() == 0
77 }
78 }
79 timeout(5) {
80 waitUntil {
81 kubectl_deleted = sh returnStdout: true, script: """
82 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Andrea Campanellad9891e62020-07-24 16:14:22 +020083 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet|local-path-storage' | wc -l
Kailash6f5acb62019-08-28 14:38:45 -070084 """
85 return kubectl_deleted.toInteger() == 0
86 }
87 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070088 timeout(1) {
Hung-Wei Chiu2fa15622020-04-07 16:40:35 -070089 sh returnStdout: false, script: """
90 #Remove all while true; do kubectl port-forward ...done; rules
91 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | grep "while true"| awk '{print \$1}'`;
92 do
93 cat /proc/\$port_fwd_id/cmdline
94 kill -9 \$port_fwd_id
95 done
96
97 #Remove all kubectl port-forward rules
98 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | awk '{print \$1}'`;
99 do
100 cat /proc/\$port_fwd_id/cmdline
101 kill -9 \$port_fwd_id
102 done
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700103 """
104 }
Kailash6f5acb62019-08-28 14:38:45 -0700105 }
106 }
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800107 stage('Install Voltha') {
Suchitra Vemuri76261d02020-05-08 16:33:32 -0700108 timeout(20) {
Kailash6f5acb62019-08-28 14:38:45 -0700109 sh returnStdout: true, script: """
110 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
111 cd kind-voltha/
Andy Bavier4f23d9d2020-07-02 06:14:00 -0700112 export EXTRA_HELM_FLAGS=""
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700113 if [ "${branch}" != "master" ]; then
114 cd $WORKSPACE/kind-voltha
Andy Bavier4f23d9d2020-07-02 06:14:00 -0700115 # The releases/ file also specifies EXTRA_HELM_FLAGS
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700116 source releases/${branch}
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800117 fi
Andy Bavier4f23d9d2020-07-02 06:14:00 -0700118 # Make sure that the EXTRA_HELM_FLAGS from the releases/ file appear at the end to override earlier values
119 export EXTRA_HELM_FLAGS="-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml \$EXTRA_HELM_FLAGS"
Andy Bavier7cee6f42019-11-05 16:49:47 -0700120
Andy Bavieraf5883e2020-06-03 12:54:21 -0700121 # JENKINS_NODE_COOKIE=dontKillMe ask Jenkins doesn't kill the proces after this job.
122 # we want the `while true; do kubectl port-forward` keep alive
123 export JENKINS_NODE_COOKIE=dontKillMe
124 export NUM_OF_OPENONU=${NumOfOpenOnu}
125 export NUM_OF_ONOS=${NumOfOnos}
126 export NUM_OF_ATOMIX=${NumOfAtomix}
Andy Bavier7cee6f42019-11-05 16:49:47 -0700127 # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
Andy Bavieraf5883e2020-06-03 12:54:21 -0700128 export ONOS_SSH_PORT=30115
129 export ONOS_API_PORT=30120
130 export VOLTHA_LOG_LEVEL=DEBUG
131 export WITH_SIM_ADAPTERS=n
132 export DEPLOY_K8S=no
133 export INSTALL_KUBECTL=no
134 export INSTALL_HELM=no
Matteo Scandolo1fdb2f82020-06-04 09:26:43 -0700135 export WITH_RADIUS=yes
Andy Bavieraf5883e2020-06-03 12:54:21 -0700136 export FANCY=0
137 # VOL-3162 Forwaring port 2379 does not work on ONF demo pod
138 export VOLTHA_ETCD_PORT=${VolthaEtcdPort}
139
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700140 if [[ "${workFlow}" == "DT" ]]; then
Andy Bavieraf5883e2020-06-03 12:54:21 -0700141 WITH_EAPOL=no WITH_DHCP=no WITH_IGMP=no WITH_RADIUS=no ./voltha up
Suchitra Vemuri32dea012020-07-08 16:40:06 -0700142 elif [[ "${workFlow}" == "TT" ]]; then
143 WITH_EAPOL=no WITH_DHCP=no WITH_INCREMENTAL_EVTO_UPDATE=yes WITH_IGMP=yes WITH_RADIUS=no ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700144 else
Andy Bavieraf5883e2020-06-03 12:54:21 -0700145 ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700146 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -0700147
Matteo Scandolo727c7972020-04-13 13:09:25 -0700148 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.image}{'\\n'}" | sort | uniq
149 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800150 kubectl get nodes -o wide
151 kubectl get pods -n voltha -o wide
Kailash6f5acb62019-08-28 14:38:45 -0700152 """
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800153 }
Kailash6f5acb62019-08-28 14:38:45 -0700154 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700155 if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
156 stage('OpenFlow port forward for aggregation switch') {
157 timeout(1) {
158 sh returnStdout: true, script: """
159 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
160 #This uses the default route out, porperly configured is the management
161 mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
Andrea Campanellac5f7db72020-05-08 10:58:11 +0200162 JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-onos-classic-hs --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700163 """
164 }
165 }
166 }
167 if ( params.configurePod && params.profile != "Default" ) {
Suchitra Vemuri72680092019-10-03 12:39:20 -0700168 stage('Push Tech-Profile') {
Andrea Campanellabea02762020-04-23 10:59:08 +0200169 for(int i=0; i < deployment_config.olts.size(); i++) {
170 def tech_prof_directory = "XGS-PON"
171 if (deployment_config.olts[i].oltDebVersion.contains("asgvolt64")){
172 tech_prof_directory = "GPON"
173 }
174 timeout(1) {
175 out_push_tp = sh returnStatus: true, script: """
176 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Suchitra Vemuri2d045902020-06-08 18:32:19 -0700177 etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
Suchitra Vemuri32dea012020-07-08 16:40:06 -0700178 if [[ "${workFlow}" == "TT" ]]; then
179 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
180 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
181 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
182 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65')
183 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST.json \$etcd_container:/tmp/mcast.json
184 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66')
185 else
186 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
187 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
188 fi
189
Andrea Campanellabea02762020-04-23 10:59:08 +0200190 """
191 return out_push_tp == 0
192 }
193 timeout(1) {
194 out_get_tp = sh returnStatus: true, script: """
Andrea Campanella85b0a8d2020-05-14 12:56:47 +0200195 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Suchitra Vemuri2d045902020-06-08 18:32:19 -0700196 etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
197 get_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64')
Andrea Campanellabea02762020-04-23 10:59:08 +0200198 """
199 return out_get_tp == 0
200 }
Suchitra Vemuri72680092019-10-03 12:39:20 -0700201 }
hwchiuc77c7d22019-10-18 13:58:35 -0700202 }
203 }
204 stage('Push Sadis-config') {
205 timeout(1) {
206 sadis_out = sh returnStatus: true, script: """
Suchitra Vemuri992377e2020-06-20 18:03:49 -0700207 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
208 etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
209 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
210 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/MIB_Alpha.json | ETCDCTL_API=3 etcdctl put service/voltha/omci_mibs/templates/BRCM/BVM4K00BRA0915-0083/5023_020O02414')
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700211 if [[ "${workFlow}" == "DT" ]]; then
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/voltha-system-tests/tests/data/${configFileName}-sadis-DT.json
Suchitra Vemuri32dea012020-07-08 16:40:06 -0700213 elif [[ "${workFlow}" == "TT" ]]; then
214 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-TT.json
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700215 else
Suchitra Vemuri72680092019-10-03 12:39:20 -0700216 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 -0700217 fi
218 """
219 return sadis_out == 0
You Wangb9526e62019-10-07 15:25:48 -0700220 }
hwchiuc77c7d22019-10-18 13:58:35 -0700221 }
Kailash6f5acb62019-08-28 14:38:45 -0700222 if ( params.reinstallOlt ) {
223 stage('Reinstall OLT software') {
224 for(int i=0; i < deployment_config.olts.size(); i++) {
225 sh returnStdout: true, script: """
Suchitra Vemuri66174b02020-05-14 16:44:28 -0700226 if [ "${branch}" != "master" ]; then
227 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${deployment_config.olts[i].oltDebVersion23}"
228 else
229 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${deployment_config.olts[i].oltDebVersion}"
230 fi
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700231 sleep 10
Kailash6f5acb62019-08-28 14:38:45 -0700232 """
233 timeout(5) {
234 waitUntil {
235 olt_sw_present = sh returnStdout: true, script: """
Suchitra Vemuri66174b02020-05-14 16:44:28 -0700236 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16-2.4"* ]] || [[ "${deployment_config.olts[i].oltDebVersion23}" == *"asfvolt16-2.4"* ]]; then
Andrea Campanellace9e9902020-04-07 18:29:42 +0200237 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'
238 else
239 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'
240 fi
Suchitra Vemuri66174b02020-05-14 16:44:28 -0700241 if (${deployment_config.olts[i].fortygig}); then
242 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16-2.4"* ]] || [[ "${deployment_config.olts[i].oltDebVersion23}" == *"asfvolt16-2.4"* ]]; then
243 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000 if=XLAUI" >> /broadcom/qax.soc'
244 else
245 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'
246 fi
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700247 fi
Kailash6f5acb62019-08-28 14:38:45 -0700248 """
Andrea Campanellace9e9902020-04-07 18:29:42 +0200249 return olt_sw_present.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700250 }
251 }
Kailash6f5acb62019-08-28 14:38:45 -0700252 }
253 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700254 stage('Restart OLT processes') {
Kailash6f5acb62019-08-28 14:38:45 -0700255 for(int i=0; i < deployment_config.olts.size(); i++) {
256 timeout(5) {
257 sh returnStdout: true, script: """
258 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
Andy Bavier1923ecc2020-06-18 14:06:40 -0700259 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; reboot' || true
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700260 sleep 120
Kailash6f5acb62019-08-28 14:38:45 -0700261 """
262 }
263 timeout(15) {
264 waitUntil {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700265 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'"
266 return devprocess.toInteger() > 0
267 }
268 }
269 timeout(15) {
270 waitUntil {
271 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'"
272 return openoltprocess.toInteger() > 0
Kailash6f5acb62019-08-28 14:38:45 -0700273 }
274 }
275 }
276 }
277 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700278 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700279 stage('Switch Configurations in ONOS') {
280 timeout(1) {
Andrea Campanella817dfb82020-05-21 12:00:28 +0200281 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
282 if (params.inBandManagement){
283 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
284 }
You Wang25e58612019-10-01 16:30:28 -0700285 netcfg_out = sh returnStatus: true, script: """
Andrea Campanella817dfb82020-05-21 12:00:28 +0200286 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @${netcfg}
You Wang25e58612019-10-01 16:30:28 -0700287 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 -0700288
You Wang25e58612019-10-01 16:30:28 -0700289 """
290 return netcfg_out == 0
291 }
292 timeout(1) {
293 waitUntil {
294 sr_active_out = sh returnStatus: true, script: """
You Wangeb76aeb2019-12-09 22:08:23 -0800295 ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115
Suchitra Vemuric3257262019-12-05 19:06:42 -0800296 ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts
297 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
298 sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
299 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 -0700300 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 -0700301 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 +0200302 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 -0700303 """
304 return sr_active_out == 0
305 }
306 }
Andrea Campanellabea02762020-04-23 10:59:08 +0200307 timeout(5) {
You Wang25e58612019-10-01 16:30:28 -0700308 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
Andrea Campanellabea02762020-04-23 10:59:08 +0200309 def aggPort = -1
310 for(int j=0; j < deployment_config.olts.size(); j++) {
311 if(deployment_config.olts[j].serial == deployment_config.hosts.src[j].olt){
312 aggPort = deployment_config.olts[j].aggPort
313 }
314 }
315 if(aggPort == -1){
316 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
317 }
You Wang25e58612019-10-01 16:30:28 -0700318 xconnect_out = sh returnStatus: true, script: """
Suchitra Vemuri992377e2020-06-20 18:03:49 -0700319 sleep 30
Suchitra Vemuricdc32d82020-07-17 12:24:46 -0700320 version=\$(sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700321 sleep 10
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800322 if [[ \$version == *"version=2.2"* ]]; then
Andrea Campanellabea02762020-04-23 10:59:08 +0200323 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},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800324 else
Andrea Campanellabea02762020-04-23 10:59:08 +0200325 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},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
Suchitra Vemurif82086d2020-01-16 19:55:16 -0800326 fi
You Wang25e58612019-10-01 16:30:28 -0700327 """
328 }
329 }
Kailash6f5acb62019-08-28 14:38:45 -0700330 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700331 }
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700332 if ( params.inBandManagement ) {
Suchitra Vemuriaa99e4c2020-07-15 14:33:03 -0700333 stage('Reboot OLT') {
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700334 for(int i=0; i < deployment_config.olts.size(); i++) {
Suchitra Vemuricdc32d82020-07-17 12:24:46 -0700335 timeout(10) {
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700336 sh returnStdout: true, script: """
337 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Matteo Scandolo5f6fe262020-07-21 11:50:42 -0700338 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/startup.log; reboot' || true
Suchitra Vemuricdc32d82020-07-17 12:24:46 -0700339 sleep 360
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700340 """
341 }
342 timeout(15) {
343 waitUntil {
344 devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
345 return devprocess.toInteger() > 0
346 }
347 }
348 timeout(15) {
349 waitUntil {
350 openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
351 return openoltprocess.toInteger() > 0
352 }
353 }
354 }
355 }
356 }
357
Kailash6f5acb62019-08-28 14:38:45 -0700358 currentBuild.result = 'SUCCESS'
359 } catch (err) {
360 currentBuild.result = 'FAILURE'
361 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
362 throw err
363 }
364 echo "RESULT: ${currentBuild.result}"
365 }
366}