blob: 40a7d4ef1d68667aee16a26d256d8958306e92ad [file] [log] [blame]
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -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}") {
Andrea Campanella80dcae02020-01-28 11:23:26 +010016 def withKind = false
17 if (params.withKind != null){
18 withKind = params.withKind
19 }
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -070020 timeout (100) {
21 try {
22 stage ("Parse deployment configuration file") {
23 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha"
24 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/helm-repo-tools"
25 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
26 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/voltha-system-tests"
Suchitra Vemuric6f160e2020-03-18 13:05:13 -070027 if ( params.released ) {
28 sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git -b v2.2"
29 }
30 else {
31 sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git"
32 }
Suchitra Vemuri2c6d0812020-03-16 12:41:52 -070033 if ( params.workFlow == "DT" ) {
34 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
35 }
36 else
37 {
38 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
39 }
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -070040 }
41 stage('Clean up') {
42 timeout(10) {
43 sh returnStdout: true, script: """
44 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
45 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
46 do
47 echo "Purging chart: \${hchart}"
48 helm delete --purge "\${hchart}"
49 done
50 """
51 timeout(5) {
52 waitUntil {
53 helm_deleted = sh returnStdout: true, script: """
54 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
55 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
56 """
57 return helm_deleted.toInteger() == 0
58 }
59 }
60 timeout(5) {
61 waitUntil {
62 kubectl_deleted = sh returnStdout: true, script: """
63 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
64 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
65 """
66 return kubectl_deleted.toInteger() == 0
67 }
68 }
Andrea Campanella80dcae02020-01-28 11:23:26 +010069 timeout(1) {
70 sh returnStdout: true, script: """
71 port_fwd_pid=`ps -ax | grep "port-forward -n default service/onos-openflow" | grep -v "grep" | awk '{print \$1}'`
72 if [[ "" != "\$port_fwd_pid" ]]; then
73 kill -9 \$port_fwd_pid > /dev/null 2>&1
74 fi
75 """
76 }
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -070077 }
78 }
Suchitra Vemuri4ac44632019-11-12 13:41:08 -080079 stage('Install Voltha') {
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -070080 timeout(10) {
81 sh returnStdout: true, script: """
82 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
83 cd kind-voltha/
Suchitra Vemuri4ac44632019-11-12 13:41:08 -080084 if ( ${released} ); then
Suchitra Vemuria7dae322020-02-19 22:38:18 -080085 export EXTRA_HELM_FLAGS="--set defaults.image_tag=null,images.onos.tag=4.0.0,images.onos.repository=voltha/voltha-onos"
Suchitra Vemuri946da612020-02-25 16:36:30 -080086 git clone -b '2.3.0rc1' --single-branch --depth 1 https://gerrit.opencord.org/voltha-helm-charts.git
87 cd voltha-helm-charts
88 helm dep update voltha-adapter-openolt
89 helm dep update voltha-adapter-openonu
90 helm dep update voltha-adapter-simulated
91 helm dep update voltha
92 export VOLTHA_ADAPTER_OPEN_OLT_CHART=voltha-helm-charts/voltha-adapter-openolt
93 export VOLTHA_ADAPTER_OPEN_ONU_CHART=voltha-helm-charts/voltha-adapter-openonu
94 export VOLTHA_ADAPTER_SIM_CHART=voltha-helm-charts/voltha-adapter-simulated
95 export VOLTHA_CHART=voltha-helm-charts/voltha
96 cd $WORKSPACE/kind-voltha
Suchitra Vemuric6f160e2020-03-18 13:05:13 -070097 source releases/voltha-2.2
98 cd $WORKSPACE/kind-voltha
Suchitra Vemuri225a2c82020-03-04 18:16:40 -080099 elif ( ${ofagentGo} ); then
100 export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}-ofagent-go.yml'
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800101 else
102 export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml'
103 fi
104
105 # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
Suchitra Vemuriae9cecb2020-03-12 12:59:14 -0700106 if [[ "${workFlow}" == "DT" ]]; then
107 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
108 else
109 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
110 fi
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800111
112 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
113 kubectl get nodes -o wide
114 kubectl get pods -n voltha -o wide
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700115 """
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800116 }
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700117 }
Andrea Campanella80dcae02020-01-28 11:23:26 +0100118 if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
119 stage('OpenFlow port forward for aggregation switch') {
120 timeout(1) {
121 sh returnStdout: true, script: """
122 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
123 #This uses the default route out, porperly configured is the management
124 mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
Andrea Campanella8eeba9f2020-03-10 10:51:25 +0100125 JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-openflow --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
Andrea Campanella80dcae02020-01-28 11:23:26 +0100126 """
127 }
128 }
129 }
Suchitra Vemuri225a2c82020-03-04 18:16:40 -0800130 if ( params.configurePod && params.profile != "Default" ) {
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700131 stage('Push Tech-Profile') {
132 timeout(1) {
133 out_push_tp = sh returnStatus: true, script: """
134 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
135 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800136 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
137 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/XGS-PON/64')
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700138 """
139 return out_push_tp == 0
140 }
141 timeout(1) {
142 out_get_tp = sh returnStatus: true, script: """
143 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800144 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64')
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700145 """
146 return out_get_tp == 0
147 }
148 }
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800149 }
150 stage('Push Sadis-config') {
151 timeout(1) {
152 sadis_out = sh returnStatus: true, script: """
Suchitra Vemurid3bf85c2020-02-14 14:15:39 -0800153 if [[ "${onosVersion}" == "1.13.9" ]]; then
Suchitra Vemuric735bab2020-02-05 14:55:00 -0800154 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}-${onosVersion}-sadis.json
Suchitra Vemuriae9cecb2020-03-12 12:59:14 -0700155 elif [[ "${workFlow}" == "DT" ]]; then
156 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 Vemuric735bab2020-02-05 14:55:00 -0800157 else
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700158 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 Vemuric735bab2020-02-05 14:55:00 -0800159 fi
Suchitra Vemuriae9cecb2020-03-12 12:59:14 -0700160 """
161 return sadis_out == 0
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700162 }
Suchitra Vemuri4ac44632019-11-12 13:41:08 -0800163 }
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700164 if ( params.reinstallOlt ) {
165 stage('Reinstall OLT software') {
166 for(int i=0; i < deployment_config.olts.size(); i++) {
167 sh returnStdout: true, script: """
168 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
169 sleep 10
170 """
171 timeout(5) {
172 waitUntil {
173 olt_sw_present = sh returnStdout: true, script: """
174 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'
Suchitra Vemurif574b942020-01-27 16:39:58 -0800175 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
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700178 """
179 return olt_sw_present.toInteger() == 1
180 }
181 }
182 }
183 }
184 stage('Restart OLT processes') {
185 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
189 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true
190 sleep 120
191 """
192 }
193 timeout(15) {
194 waitUntil {
195 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
203 }
204 }
205 }
206 }
207 }
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700208 if ( deployment_config.fabric_switches.size() > 0 ) {
209 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 Vemuric735bab2020-02-05 14:55:00 -0800214
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -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 Vemuri6db64b22019-12-09 13:00:54 -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"
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -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
227 """
228 return sr_active_out == 0
229 }
230 }
231 timeout(1) {
232 // FIXME support multiple OLTs
233 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
234 xconnect_out = sh returnStatus: true, script: """
Suchitra Vemuric4d92932020-01-16 21:50:30 -0800235 version=\$(sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
Suchitra Vemurid3bf85c2020-02-14 14:15:39 -0800236 sleep 10
Suchitra Vemuric4d92932020-01-16 21:50:30 -0800237 if [[ \$version == *"version=2.2"* ]]; then
238 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'
239 else
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}", "ports": [${deployment_config.fabric_switches[0].bngPort},${deployment_config.fabric_switches[0].oltPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
241 fi
Suchitra Vemuria8e7bb22019-10-22 15:50:05 -0700242 """
243 }
244 }
245 }
246 }
247 currentBuild.result = 'SUCCESS'
248 } catch (err) {
249 currentBuild.result = 'FAILURE'
250 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
251 throw err
252 }
253 echo "RESULT: ${currentBuild.result}"
254 }
255}