blob: 845e3c19d76e6f2b737beb5888f7a4a23cb50ea3 [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}") {
16 timeout (100) {
17 try {
18 stage ("Parse deployment configuration file") {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070019 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha"
Suchitra Vemurie514b8c2019-09-23 19:37:18 -070020 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/helm-repo-tools"
21 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
22 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/voltha-system-tests"
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070023 sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git"
Kailash6f5acb62019-08-28 14:38:45 -070024 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
25 }
26 stage('Clean up') {
You Wang25e58612019-10-01 16:30:28 -070027 timeout(10) {
Kailash6f5acb62019-08-28 14:38:45 -070028 sh returnStdout: true, script: """
29 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070030 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
31 do
32 echo "Purging chart: \${hchart}"
33 helm delete --purge "\${hchart}"
34 done
Kailash6f5acb62019-08-28 14:38:45 -070035 """
36 timeout(5) {
37 waitUntil {
38 helm_deleted = sh returnStdout: true, script: """
39 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
40 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
41 """
42 return helm_deleted.toInteger() == 0
43 }
44 }
45 timeout(5) {
46 waitUntil {
47 kubectl_deleted = sh returnStdout: true, script: """
48 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
49 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
50 """
51 return kubectl_deleted.toInteger() == 0
52 }
53 }
54 }
55 }
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080056 stage('Install Voltha') {
Kailash6f5acb62019-08-28 14:38:45 -070057 timeout(10) {
58 sh returnStdout: true, script: """
59 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
60 cd kind-voltha/
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080061 if ( ${released} ); then
62 EXTRA_HELM_FLAGS="--set defaults.image_tag=null" 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 Vemurib9483862019-11-05 21:37:29 -080063 else
64 EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml' 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 Vemuri1934abc2019-11-05 12:41:11 -080065 fi
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080066 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
67 kubectl get nodes -o wide
68 kubectl get pods -n voltha -o wide
Kailash6f5acb62019-08-28 14:38:45 -070069 """
Suchitra Vemuri1934abc2019-11-05 12:41:11 -080070 }
Kailash6f5acb62019-08-28 14:38:45 -070071 }
hwchiuc77c7d22019-10-18 13:58:35 -070072 if ( params.configurePod && params.profile != "Default") {
Suchitra Vemuri72680092019-10-03 12:39:20 -070073 stage('Push Tech-Profile') {
74 timeout(1) {
75 out_push_tp = sh returnStatus: true, script: """
76 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
77 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
hwchiuc77c7d22019-10-18 13:58:35 -070078 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
Suchitra Vemuri72680092019-10-03 12:39:20 -070079 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/xgspon/64')
80 """
81 return out_push_tp == 0
82 }
83 timeout(1) {
84 out_get_tp = sh returnStatus: true, script: """
85 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
86 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/xgspon/64')
87 """
88 return out_get_tp == 0
89 }
hwchiuc77c7d22019-10-18 13:58:35 -070090 }
91 }
92 stage('Push Sadis-config') {
93 timeout(1) {
94 sadis_out = sh returnStatus: true, script: """
Suchitra Vemuri72680092019-10-03 12:39:20 -070095 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
96 """
97 return sadis_out == 0
You Wangb9526e62019-10-07 15:25:48 -070098 }
hwchiuc77c7d22019-10-18 13:58:35 -070099 }
Kailash6f5acb62019-08-28 14:38:45 -0700100
101 if ( params.reinstallOlt ) {
102 stage('Reinstall OLT software') {
103 for(int i=0; i < deployment_config.olts.size(); i++) {
104 sh returnStdout: true, script: """
105 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'
106 """
107 timeout(5) {
108 waitUntil {
109 olt_sw_present = sh returnStdout: true, script: """
110 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'
111 """
112 return olt_sw_present.toInteger() == 0
113 }
114 }
115 sh returnStdout: true, script: """
116 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
117 """
118 timeout(5) {
119 waitUntil {
120 olt_sw_present = sh returnStdout: true, script: """
121 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'
122 """
123 return olt_sw_present.toInteger() == 1
124 }
125 }
126 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
127 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
128 sh returnStdout: true, script: """
129 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'
130 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
131 """
132 }
133 }
134 }
135 stage('Restart OLT processes') {
136 for(int i=0; i < deployment_config.olts.size(); i++) {
137 timeout(5) {
138 sh returnStdout: true, script: """
139 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
140 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist stop' || true
141 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
142 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/bal_core_dist.log'
143 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
144 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
145 sleep 5
146 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
147 """
148 }
149 timeout(15) {
150 waitUntil {
151 onu_discovered = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cat /var/log/openolt.log | grep \"oper_state: up\" | wc -l'"
152 return onu_discovered.toInteger() > 0
153 }
154 }
155 }
156 }
157 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700158 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700159 stage('Switch Configurations in ONOS') {
160 timeout(1) {
161 netcfg_out = sh returnStatus: true, script: """
162 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
163 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
164 """
165 return netcfg_out == 0
166 }
167 timeout(1) {
168 waitUntil {
169 sr_active_out = sh returnStatus: true, script: """
170 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
171 """
172 return sr_active_out == 0
173 }
174 }
175 timeout(1) {
176 // FIXME support multiple OLTs
177 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
178 xconnect_out = sh returnStatus: true, script: """
179 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'
180 """
181 }
182 }
Kailash6f5acb62019-08-28 14:38:45 -0700183 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700184 }
Kailash6f5acb62019-08-28 14:38:45 -0700185 currentBuild.result = 'SUCCESS'
186 } catch (err) {
187 currentBuild.result = 'FAILURE'
188 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
189 throw err
190 }
191 echo "RESULT: ${currentBuild.result}"
192 }
193}