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") { |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 19 | sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha" |
Suchitra Vemuri | e514b8c | 2019-09-23 19:37:18 -0700 | [diff] [blame] | 20 | 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 Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 23 | sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git" |
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') { |
You Wang | 25e5861 | 2019-10-01 16:30:28 -0700 | [diff] [blame] | 27 | timeout(10) { |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 28 | sh returnStdout: true, script: """ |
| 29 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 30 | 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 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 35 | """ |
| 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/ |
Suchitra Vemuri | 017a14b | 2019-10-30 14:31:29 -0700 | [diff] [blame] | 61 | 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 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 62 | """ |
| 63 | } |
| 64 | } |
hwchiu | c77c7d2 | 2019-10-18 13:58:35 -0700 | [diff] [blame] | 65 | if ( params.configurePod && params.profile != "Default") { |
Suchitra Vemuri | 7268009 | 2019-10-03 12:39:20 -0700 | [diff] [blame] | 66 | stage('Push Tech-Profile') { |
| 67 | timeout(1) { |
| 68 | out_push_tp = sh returnStatus: true, script: """ |
| 69 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 70 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
hwchiu | c77c7d2 | 2019-10-18 13:58:35 -0700 | [diff] [blame] | 71 | kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json |
Suchitra Vemuri | 7268009 | 2019-10-03 12:39:20 -0700 | [diff] [blame] | 72 | 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') |
| 73 | """ |
| 74 | return out_push_tp == 0 |
| 75 | } |
| 76 | timeout(1) { |
| 77 | out_get_tp = sh returnStatus: true, script: """ |
| 78 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
| 79 | get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/xgspon/64') |
| 80 | """ |
| 81 | return out_get_tp == 0 |
| 82 | } |
hwchiu | c77c7d2 | 2019-10-18 13:58:35 -0700 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | stage('Push Sadis-config') { |
| 86 | timeout(1) { |
| 87 | sadis_out = sh returnStatus: true, script: """ |
Suchitra Vemuri | 7268009 | 2019-10-03 12:39:20 -0700 | [diff] [blame] | 88 | 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 |
| 89 | """ |
| 90 | return sadis_out == 0 |
You Wang | b9526e6 | 2019-10-07 15:25:48 -0700 | [diff] [blame] | 91 | } |
hwchiu | c77c7d2 | 2019-10-18 13:58:35 -0700 | [diff] [blame] | 92 | } |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 93 | |
| 94 | if ( params.reinstallOlt ) { |
| 95 | stage('Reinstall OLT software') { |
| 96 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 97 | sh returnStdout: true, script: """ |
| 98 | 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' |
| 99 | """ |
| 100 | timeout(5) { |
| 101 | waitUntil { |
| 102 | olt_sw_present = sh returnStdout: true, script: """ |
| 103 | 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' |
| 104 | """ |
| 105 | return olt_sw_present.toInteger() == 0 |
| 106 | } |
| 107 | } |
| 108 | sh returnStdout: true, script: """ |
| 109 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}" |
| 110 | """ |
| 111 | timeout(5) { |
| 112 | waitUntil { |
| 113 | olt_sw_present = sh returnStdout: true, script: """ |
| 114 | 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' |
| 115 | """ |
| 116 | return olt_sw_present.toInteger() == 1 |
| 117 | } |
| 118 | } |
| 119 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
| 120 | if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') { |
| 121 | sh returnStdout: true, script: """ |
| 122 | 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' |
| 123 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh' |
| 124 | """ |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | stage('Restart OLT processes') { |
| 129 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 130 | timeout(5) { |
| 131 | sh returnStdout: true, script: """ |
| 132 | ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts |
| 133 | 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 |
| 134 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true |
| 135 | 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' |
| 136 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log' |
| 137 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &' |
| 138 | sleep 5 |
| 139 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &' |
| 140 | """ |
| 141 | } |
| 142 | timeout(15) { |
| 143 | waitUntil { |
| 144 | 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'" |
| 145 | return onu_discovered.toInteger() > 0 |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | } |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 151 | if ( deployment_config.fabric_switches.size() > 0 ) { |
You Wang | 25e5861 | 2019-10-01 16:30:28 -0700 | [diff] [blame] | 152 | stage('Switch Configurations in ONOS') { |
| 153 | timeout(1) { |
| 154 | netcfg_out = sh returnStatus: true, script: """ |
| 155 | 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 |
| 156 | curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active |
| 157 | """ |
| 158 | return netcfg_out == 0 |
| 159 | } |
| 160 | timeout(1) { |
| 161 | waitUntil { |
| 162 | sr_active_out = sh returnStatus: true, script: """ |
| 163 | curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE |
| 164 | """ |
| 165 | return sr_active_out == 0 |
| 166 | } |
| 167 | } |
| 168 | timeout(1) { |
| 169 | // FIXME support multiple OLTs |
| 170 | for(int i=0; i < deployment_config.hosts.src.size(); i++) { |
| 171 | xconnect_out = sh returnStatus: true, script: """ |
| 172 | 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' |
| 173 | """ |
| 174 | } |
| 175 | } |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 176 | } |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 177 | } |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 178 | currentBuild.result = 'SUCCESS' |
| 179 | } catch (err) { |
| 180 | currentBuild.result = 'FAILURE' |
| 181 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 182 | throw err |
| 183 | } |
| 184 | echo "RESULT: ${currentBuild.result}" |
| 185 | } |
| 186 | } |