blob: 6bb08f1c3a69fdd6d619852a95f7c30f4c00fa91 [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") {
Suchitra Vemurifdc89ec2019-09-19 15:34:36 -070019 sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests"
Kailash6f5acb62019-08-28 14:38:45 -070020 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
21 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri1056c4a2019-08-29 18:03:51 -070022 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests"
Kailash6f5acb62019-08-28 14:38:45 -070023 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
24 }
25 stage('Clean up') {
26 timeout(10) {
27 sh returnStdout: true, script: """
28 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
29 cd kind-voltha/
30 DEPLOY_K8S=no ./voltha down
31 """
32 timeout(5) {
33 waitUntil {
34 helm_deleted = sh returnStdout: true, script: """
35 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
36 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
37 """
38 return helm_deleted.toInteger() == 0
39 }
40 }
41 timeout(5) {
42 waitUntil {
43 kubectl_deleted = sh returnStdout: true, script: """
44 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
45 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
46 """
47 return kubectl_deleted.toInteger() == 0
48 }
49 }
50 }
51 }
52 stage('Install Voltha') {
53 timeout(10) {
54 sh returnStdout: true, script: """
55 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
56 cd kind-voltha/
57 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
58 """
59 }
60 }
61
62 if ( params.reinstallOlt ) {
63 stage('Reinstall OLT software') {
64 for(int i=0; i < deployment_config.olts.size(); i++) {
65 sh returnStdout: true, script: """
66 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'
67 """
68 timeout(5) {
69 waitUntil {
70 olt_sw_present = sh returnStdout: true, script: """
71 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'
72 """
73 return olt_sw_present.toInteger() == 0
74 }
75 }
76 sh returnStdout: true, script: """
77 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
78 """
79 timeout(5) {
80 waitUntil {
81 olt_sw_present = sh returnStdout: true, script: """
82 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'
83 """
84 return olt_sw_present.toInteger() == 1
85 }
86 }
87 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
88 if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
89 sh returnStdout: true, script: """
90 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'
91 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
92 """
93 }
94 }
95 }
96 stage('Restart OLT processes') {
97 for(int i=0; i < deployment_config.olts.size(); i++) {
98 timeout(5) {
99 sh returnStdout: true, script: """
100 ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
101 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
102 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
103 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'
104 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
105 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
106 sleep 5
107 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
108 """
109 }
110 timeout(15) {
111 waitUntil {
112 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'"
113 return onu_discovered.toInteger() > 0
114 }
115 }
116 }
117 }
118 }
119 if ( params.configurePod ) {
120 stage('Configure ONOS Netcfg') {
121 timeout(1) {
Kailash6f5acb62019-08-28 14:38:45 -0700122 sh returnStdout: true, script: """
Kailash57210eb2019-08-30 13:27:19 -0700123 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}-onos-netcfg.json
124 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
Kailash6f5acb62019-08-28 14:38:45 -0700125 """
Kailash6f5acb62019-08-28 14:38:45 -0700126 }
127 }
You Wang5f8ab4a2019-09-13 16:27:24 -0700128 stage('Push Tech-Profile') {
Kailash6f5acb62019-08-28 14:38:45 -0700129 timeout(1) {
You Wang5f8ab4a2019-09-13 16:27:24 -0700130 sh returnStdout: true, script: """
131 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
132 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
133 kubectl cp /home/cord/voltha-system-tests/tests/data/${configFileName}-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
134 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')
135 get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/xgspon/64')
136 """
Kailash6f5acb62019-08-28 14:38:45 -0700137 }
You Wang5f8ab4a2019-09-13 16:27:24 -0700138 }
Kailash6f5acb62019-08-28 14:38:45 -0700139 }
140 currentBuild.result = 'SUCCESS'
141 } catch (err) {
142 currentBuild.result = 'FAILURE'
143 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
144 throw err
145 }
146 echo "RESULT: ${currentBuild.result}"
147 }
148}
149