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') { |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -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/ |
| 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 Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 123 | if ( deployment_config.fabric_switches.size() > 0 ) { |
Suchitra Vemuri | 44a9b67 | 2019-09-25 23:13:00 -0700 | [diff] [blame] | 124 | stage('Switch Configurations in ONOS') { |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 125 | 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 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 131 | } |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 132 | 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 Wang | 5f8ab4a | 2019-09-13 16:27:24 -0700 | [diff] [blame] | 143 | stage('Push Tech-Profile') { |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 144 | timeout(1) { |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 145 | out_push_tp = sh returnStatus: true, script: """ |
You Wang | 5f8ab4a | 2019-09-13 16:27:24 -0700 | [diff] [blame] | 146 | 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 Vemuri | f2e0a4a | 2019-09-26 09:30:57 -0700 | [diff] [blame^] | 148 | kubectl cp /home/cord/voltha-system-tests/tests/data/${configFileName}-multipleGem.json voltha/\$etcd_container:/tmp/flexpod.json |
You Wang | 5f8ab4a | 2019-09-13 16:27:24 -0700 | [diff] [blame] | 149 | 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 Wang | 5f8ab4a | 2019-09-13 16:27:24 -0700 | [diff] [blame] | 150 | """ |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 151 | return out_push_tp == 0 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 152 | } |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 153 | 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 Wang | 5f8ab4a | 2019-09-13 16:27:24 -0700 | [diff] [blame] | 168 | } |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 169 | } |
| 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 | } |