Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | node ("${TestNodeName}") { |
| 16 | timeout (100) { |
| 17 | try { |
| 18 | stage ("Parse deployment configuration file") { |
Suchitra Vemuri | 1056c4a | 2019-08-29 18:03:51 -0700 | [diff] [blame] | 19 | sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} kind-voltha" |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools" |
| 21 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
| 22 | sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git" |
Suchitra Vemuri | 1056c4a | 2019-08-29 18:03:51 -0700 | [diff] [blame] | 23 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests" |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 24 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 25 | } |
| 26 | stage('Clean up') { |
| 27 | timeout(10) { |
| 28 | sh returnStdout: true, script: """ |
| 29 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 30 | cd kind-voltha/ |
| 31 | DEPLOY_K8S=no ./voltha down |
| 32 | """ |
| 33 | timeout(5) { |
| 34 | waitUntil { |
| 35 | helm_deleted = sh returnStdout: true, script: """ |
| 36 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 37 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 38 | """ |
| 39 | return helm_deleted.toInteger() == 0 |
| 40 | } |
| 41 | } |
| 42 | timeout(5) { |
| 43 | waitUntil { |
| 44 | kubectl_deleted = sh returnStdout: true, script: """ |
| 45 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 46 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 47 | """ |
| 48 | return kubectl_deleted.toInteger() == 0 |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | stage('Install Voltha') { |
| 54 | timeout(10) { |
| 55 | sh returnStdout: true, script: """ |
| 56 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 57 | cd kind-voltha/ |
| 58 | 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 |
| 59 | """ |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if ( params.reinstallOlt ) { |
| 64 | stage('Reinstall OLT software') { |
| 65 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 66 | sh returnStdout: true, script: """ |
| 67 | 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' |
| 68 | """ |
| 69 | timeout(5) { |
| 70 | waitUntil { |
| 71 | olt_sw_present = sh returnStdout: true, script: """ |
| 72 | 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' |
| 73 | """ |
| 74 | return olt_sw_present.toInteger() == 0 |
| 75 | } |
| 76 | } |
| 77 | sh returnStdout: true, script: """ |
| 78 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}" |
| 79 | """ |
| 80 | timeout(5) { |
| 81 | waitUntil { |
| 82 | olt_sw_present = sh returnStdout: true, script: """ |
| 83 | 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' |
| 84 | """ |
| 85 | return olt_sw_present.toInteger() == 1 |
| 86 | } |
| 87 | } |
| 88 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
| 89 | if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') { |
| 90 | sh returnStdout: true, script: """ |
| 91 | 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' |
| 92 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh' |
| 93 | """ |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | stage('Restart OLT processes') { |
| 98 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 99 | timeout(5) { |
| 100 | sh returnStdout: true, script: """ |
| 101 | ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts |
| 102 | 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 |
| 103 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true |
| 104 | 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' |
| 105 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log' |
| 106 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &' |
| 107 | sleep 5 |
| 108 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &' |
| 109 | """ |
| 110 | } |
| 111 | timeout(15) { |
| 112 | waitUntil { |
| 113 | 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'" |
| 114 | return onu_discovered.toInteger() > 0 |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | if ( params.configurePod ) { |
| 121 | stage('Configure ONOS Netcfg') { |
| 122 | timeout(1) { |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 123 | sh returnStdout: true, script: """ |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 124 | 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 |
| 125 | curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 126 | """ |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 127 | } |
| 128 | } |
Suchitra Vemuri | baed17e | 2019-08-30 15:22:09 -0700 | [diff] [blame] | 129 | /*stage('Push Tech-Profile') { |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 130 | timeout(1) { |
| 131 | waitUntil { |
| 132 | sh returnStdout: true, script: """ |
| 133 | kubectl exec -it $(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk ‘NR==1{print $1}‘) -n voltha /bin/sh |
| 134 | cat voltha-system-tests/tests/data/${configFileName}-${techProfile}.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/xgspon/64 |
| 135 | """ |
| 136 | } |
| 137 | } |
Suchitra Vemuri | baed17e | 2019-08-30 15:22:09 -0700 | [diff] [blame] | 138 | }*/ |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 139 | } |
| 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 | |