Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [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") { |
Kailash | e910815 | 2018-12-19 09:46:11 -0800 | [diff] [blame] | 19 | sh returnStdout: true, script: "rm -rf ${configBaseDir} helm-repo-tools" |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Kailash | 093f55b | 2018-12-19 09:33:49 -0800 | [diff] [blame] | 21 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools" |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 22 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 23 | } |
| 24 | stage('Clean up') { |
| 25 | timeout(10) { |
| 26 | sh returnStdout: true, script: """ |
| 27 | rm -rf cord-tester |
| 28 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 29 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 30 | do |
| 31 | echo "Purging chart: \${hchart}" |
| 32 | helm delete --purge "\${hchart}" |
| 33 | done |
| 34 | """ |
| 35 | timeout(5) { |
| 36 | waitUntil { |
| 37 | helm_deleted = sh returnStdout: true, script: """ |
| 38 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 39 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 40 | """ |
| 41 | return helm_deleted.toInteger() == 0 |
| 42 | } |
| 43 | } |
| 44 | timeout(5) { |
| 45 | waitUntil { |
| 46 | kubectl_deleted = sh returnStdout: true, script: """ |
| 47 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 48 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 49 | """ |
| 50 | return kubectl_deleted.toInteger() == 0 |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | stage('Add CORD repository') { |
| 56 | sh returnStdout: true, script: """ |
| 57 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 58 | helm repo add cord https://charts.opencord.org |
| 59 | helm repo update |
| 60 | """ |
| 61 | timeout(1) { |
| 62 | waitUntil { |
| 63 | cord_repo_present = sh returnStdout: true, script: """ |
| 64 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 65 | helm repo list | grep cord | wc -l |
| 66 | """ |
| 67 | return cord_repo_present.toInteger() == 1 |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | stage('Install CORD Platform') { |
| 72 | sh returnStdout: true, script: """ |
| 73 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
You Wang | be85ad7 | 2018-12-18 14:18:32 -0800 | [diff] [blame] | 74 | helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n cord-platform --version 6.1.0 cord/cord-platform |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 75 | """ |
| 76 | timeout(1) { |
| 77 | waitUntil { |
| 78 | cord_helm_installed = sh returnStdout: true, script: """ |
| 79 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 80 | helm ls | grep -i cord-platform | wc -l |
| 81 | """ |
| 82 | return cord_helm_installed.toInteger() == 1 |
| 83 | } |
| 84 | } |
| 85 | } |
Luca Prete | 0f3d578 | 2018-12-20 14:42:50 -0800 | [diff] [blame^] | 86 | stage('Wait for etcd-operator to be installed') { |
| 87 | timeout(10) { |
| 88 | waitUntil { |
| 89 | etcd_operator_installed = sh returnStdout: true, script: """ |
| 90 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 91 | kubectl get pods | grep -i etcd-operator | grep -i running | wc -l |
| 92 | """ |
| 93 | crd_present = sh returnStdout: true, script: """ |
| 94 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 95 | kubectl get crd | grep -i etcd | wc -l |
| 96 | """ |
| 97 | return etcd_operator_installed + crd_present.toInteger() == 6 |
| 98 | } |
| 99 | } |
| 100 | } |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 101 | stage('Install SEBA Profile') { |
| 102 | sh returnStdout: true, script: """ |
| 103 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
You Wang | be85ad7 | 2018-12-18 14:18:32 -0800 | [diff] [blame] | 104 | helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba --version 1.0.0 cord/seba |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 105 | """ |
| 106 | timeout(1) { |
| 107 | waitUntil { |
| 108 | seba_helm_installed = sh returnStdout: true, script: """ |
| 109 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 110 | helm ls | grep -i seba | wc -l |
| 111 | """ |
| 112 | return seba_helm_installed.toInteger() == 1 |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | stage('Install ATT workflow') { |
| 117 | sh returnStdout: true, script: """ |
| 118 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
You Wang | be85ad7 | 2018-12-18 14:18:32 -0800 | [diff] [blame] | 119 | helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n att-workflow --version 1.0.0 cord/att-workflow |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 120 | """ |
| 121 | timeout(1) { |
| 122 | waitUntil { |
| 123 | attworkflow_helm_installed = sh returnStdout: true, script: """ |
| 124 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 125 | helm ls | grep -i att-workflow | wc -l |
| 126 | """ |
| 127 | return attworkflow_helm_installed.toInteger() == 1 |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | stage('Check containers are running') { |
| 132 | timeout(20) { |
| 133 | waitUntil { |
Kailash | 093f55b | 2018-12-19 09:33:49 -0800 | [diff] [blame] | 134 | sh returnStdout: true, script: """ |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 135 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
Kailash | 093f55b | 2018-12-19 09:33:49 -0800 | [diff] [blame] | 136 | helm-repo-tools/wait_for_pods.sh |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 137 | """ |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 138 | pods_completed = sh returnStdout: true, script: """ |
| 139 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
Kailash | 392f4f4 | 2018-12-18 13:41:43 -0800 | [diff] [blame] | 140 | kubectl get pods --all-namespaces | grep -i completed | grep -E -v 'docker-registry|mavenrepo|ponnet|kube-system' | wc -l |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 141 | """ |
| 142 | return pods_completed.toInteger() == 3 |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | if ( params.reinstallOlt ) { |
| 147 | stage('Reinstall OLT software') { |
| 148 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 149 | sh returnStdout: true, script: """ |
| 150 | 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' |
| 151 | """ |
| 152 | timeout(5) { |
| 153 | waitUntil { |
| 154 | olt_sw_present = sh returnStdout: true, script: """ |
| 155 | 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' |
| 156 | """ |
| 157 | return olt_sw_present.toInteger() == 0 |
| 158 | } |
| 159 | } |
| 160 | sh returnStdout: true, script: """ |
| 161 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}" |
| 162 | """ |
| 163 | timeout(5) { |
| 164 | waitUntil { |
| 165 | olt_sw_present = sh returnStdout: true, script: """ |
| 166 | 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' |
| 167 | """ |
| 168 | return olt_sw_present.toInteger() == 1 |
| 169 | } |
| 170 | } |
| 171 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
| 172 | if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') { |
| 173 | sh returnStdout: true, script: """ |
| 174 | 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' |
| 175 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh' |
| 176 | """ |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | stage('Restart OLT processes') { |
| 181 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 182 | timeout(5) { |
| 183 | sh returnStdout: true, script: """ |
| 184 | ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts |
| 185 | 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 |
| 186 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true |
| 187 | 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' |
| 188 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log' |
| 189 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &' |
| 190 | sleep 5 |
| 191 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &' |
| 192 | """ |
| 193 | } |
| 194 | timeout(15) { |
| 195 | waitUntil { |
| 196 | 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'" |
| 197 | return onu_discovered.toInteger() > 0 |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | if ( params.configurePod ) { |
| 204 | dir ("${configBaseDir}/${configToscaDir}/att-workflow") { |
| 205 | stage('Configure R-CORD - Fabric and whitelist') { |
| 206 | timeout(1) { |
| 207 | waitUntil { |
| 208 | out_fabric = sh returnStdout: true, script: """ |
| 209 | curl -s -H "xos-username:admin@opencord.org" -H "xos-password:letmein" -X POST --data-binary @${configFileName}-fabric.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l |
| 210 | """ |
| 211 | return out_fabric.toInteger() == 1 |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | stage('Configure R-CORD - Subscriber') { |
| 216 | timeout(1) { |
| 217 | waitUntil { |
| 218 | out_subscriber = sh returnStdout: true, script: """ |
| 219 | curl -s -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-subscriber.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l |
| 220 | """ |
| 221 | return out_subscriber.toInteger() == 1 |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | stage('Configure R-CORD - OLT') { |
| 226 | timeout(1) { |
| 227 | waitUntil { |
| 228 | out_olt = sh returnStdout: true, script: """ |
| 229 | curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-olt.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l |
| 230 | """ |
| 231 | return out_olt.toInteger() == 1 |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | if ( params.installBBSim ) { |
| 238 | dir ("helm-charts") { |
| 239 | stage('Install BBSim') { |
| 240 | timeout(10) { |
| 241 | sh returnStdout: true, script: """ |
| 242 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
You Wang | be85ad7 | 2018-12-18 14:18:32 -0800 | [diff] [blame] | 243 | helm install -f ${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n bbsim bbsim --set onus_per_pon_port=${onuNumber} |
Luca Prete | 2261365 | 2018-12-17 14:17:43 -0800 | [diff] [blame] | 244 | """ |
| 245 | } |
| 246 | timeout(10) { |
| 247 | waitUntil { |
| 248 | base_kubernetes_tosca_running = sh returnStdout: true, script: """ |
| 249 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 250 | kubectl get pods -n voltha | grep -i bbsim | wc -l |
| 251 | """ |
| 252 | return base_kubernetes_tosca_running.toInteger() == 1 |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | dir ("${configBaseDir}/${configToscaDir}/bbsim") { |
| 258 | stage('Configure BBSim - OLT') { |
| 259 | timeout(1) { |
| 260 | waitUntil { |
| 261 | out_olt = sh returnStdout: true, script: """ |
| 262 | curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @bbsim-16.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l |
| 263 | """ |
| 264 | return out_olt.toInteger() == 1 |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | currentBuild.result = 'SUCCESS' |
| 271 | } catch (err) { |
| 272 | currentBuild.result = 'FAILURE' |
| 273 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 274 | } |
| 275 | echo "RESULT: ${currentBuild.result}" |
| 276 | } |
| 277 | } |