blob: 5f1eb990c7c33480f61bed01079b2007c341d78f [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') {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -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 }
56 stage('Install Voltha') {
57 timeout(10) {
58 sh returnStdout: true, script: """
59 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
60 cd kind-voltha/
61 EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml' WITH_RADIUS=y WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no ONOS_TAG=voltha-2.1 ./voltha up
62 """
63 }
64 }
65
66 if ( params.reinstallOlt ) {
67 stage('Reinstall OLT software') {
68 for(int i=0; i < deployment_config.olts.size(); i++) {
69 sh returnStdout: true, script: """
70 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'
71 """
72 timeout(5) {
73 waitUntil {
74 olt_sw_present = sh returnStdout: true, script: """
75 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'
76 """
77 return olt_sw_present.toInteger() == 0
78 }
79 }
80 sh returnStdout: true, script: """
81 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
82 """
83 timeout(5) {
84 waitUntil {
85 olt_sw_present = sh returnStdout: true, script: """
86 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'
87 """
88 return olt_sw_present.toInteger() == 1
89 }
90 }
91 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
92 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
93 sh returnStdout: true, script: """
94 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'
95 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
96 """
97 }
98 }
99 }
100 stage('Restart OLT processes') {
101 for(int i=0; i < deployment_config.olts.size(); i++) {
102 timeout(5) {
103 sh returnStdout: true, script: """
104 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
105 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
106 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
107 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'
108 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
109 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
110 sleep 5
111 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
112 """
113 }
114 timeout(15) {
115 waitUntil {
116 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'"
117 return onu_discovered.toInteger() > 0
118 }
119 }
120 }
121 }
122 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700123 if ( deployment_config.fabric_switches.size() > 0 ) {
Suchitra Vemuri44a9b672019-09-25 23:13:00 -0700124 stage('Switch Configurations in ONOS') {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700125 timeout(1) {
126 netcfg_out = sh returnStatus: true, script: """
127 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
128 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
129 """
130 return netcfg_out == 0
Kailash6f5acb62019-08-28 14:38:45 -0700131 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700132 timeout(1) {
133 // FIXME iterate over the hosts section to create multiple xconnect if needed
134 // FIXME read the device id from deployment_config.fabric_switches
135 xconnect_out = sh returnStatus: true, script: """
136 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "of:0000000000000001", "vlanId": "111", "ports": [3,10]}' 'http://10.192.20.45:30120/onos/segmentrouting/xconnect'
137 """
138 return xconnect_out == 0
139 }
140 }
141 }
142 if ( params.configurePod ) {
You Wang5f8ab4a2019-09-13 16:27:24 -0700143 stage('Push Tech-Profile') {
Kailash6f5acb62019-08-28 14:38:45 -0700144 timeout(1) {
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700145 out_push_tp = sh returnStatus: true, script: """
You Wang5f8ab4a2019-09-13 16:27:24 -0700146 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
147 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
Suchitra Vemurif2e0a4a2019-09-26 09:30:57 -0700148 kubectl cp /home/cord/voltha-system-tests/tests/data/${configFileName}-multipleGem.json voltha/\$etcd_container:/tmp/flexpod.json
You Wang5f8ab4a2019-09-13 16:27:24 -0700149 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')
You Wang5f8ab4a2019-09-13 16:27:24 -0700150 """
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700151 return out_push_tp == 0
Kailash6f5acb62019-08-28 14:38:45 -0700152 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700153 timeout(1) {
154 out_get_tp = sh returnStatus: true, script: """
155 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
156 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/xgspon/64')
157 """
158 return out_get_tp == 0
159 }
160 }
161 stage('Push Sadis-config') {
162 timeout(1) {
163 sadis_out = sh returnStatus: true, script: """
164 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
165 """
166 return sadis_out == 0
167 }
You Wang5f8ab4a2019-09-13 16:27:24 -0700168 }
Kailash6f5acb62019-08-28 14:38:45 -0700169 }
170 currentBuild.result = 'SUCCESS'
171 } catch (err) {
172 currentBuild.result = 'FAILURE'
173 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
174 throw err
175 }
176 echo "RESULT: ${currentBuild.result}"
177 }
178}