Matteo Scandolo | 633a2eb | 2022-03-28 08:26:17 -0700 | [diff] [blame] | 1 | // Copyright 2019-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 | // deploy VOLTHA and performs a scale test with the LWC controller |
| 16 | |
| 17 | library identifier: 'cord-jenkins-libraries@master', |
| 18 | retriever: modernSCM([ |
| 19 | $class: 'GitSCMSource', |
| 20 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 21 | ]) |
| 22 | |
| 23 | pipeline { |
| 24 | |
| 25 | /* no label, executor is determined by JJB */ |
| 26 | agent { |
| 27 | label "${params.buildNode}" |
| 28 | } |
| 29 | options { |
| 30 | timeout(time: 60, unit: 'MINUTES') |
| 31 | } |
| 32 | environment { |
| 33 | JENKINS_NODE_COOKIE="dontKillMe" // do not kill processes after the build is done |
| 34 | KUBECONFIG="$HOME/.kube/config" |
| 35 | VOLTCONFIG="$HOME/.volt/config" |
| 36 | SSHPASS="karaf" |
| 37 | VOLTHA_LOG_LEVEL="${logLevel}" |
| 38 | NUM_OF_BBSIM="${olts}" |
| 39 | NUM_OF_OPENONU="${openonuAdapterReplicas}" |
| 40 | NUM_OF_ONOS="${onosReplicas}" |
| 41 | NUM_OF_ATOMIX="${atomixReplicas}" |
| 42 | EXTRA_HELM_FLAGS=" " |
| 43 | LOG_FOLDER="$WORKSPACE/logs" |
| 44 | GERRIT_PROJECT="${GERRIT_PROJECT}" |
| 45 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
| 46 | } |
| 47 | |
| 48 | stages { |
| 49 | stage ('Cleanup') { |
| 50 | steps { |
| 51 | script { |
| 52 | try { |
| 53 | timeout(time: 5, unit: 'MINUTES') { |
| 54 | sh returnStdout: false, script: ''' |
| 55 | cd $WORKSPACE |
| 56 | rm -rf $WORKSPACE/* |
| 57 | ''' |
| 58 | // removing the voltha-infra chart first |
| 59 | // if we don't ONOS might get stuck because of all the events when BBSim goes down |
| 60 | sh returnStdout: false, script: ''' |
| 61 | set +x |
| 62 | helm del voltha-infra || true |
| 63 | echo -ne "\nWaiting for ONOS to be removed..." |
| 64 | onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l) |
| 65 | while [[ $onos != 0 ]]; do |
| 66 | onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l) |
| 67 | sleep 5 |
| 68 | echo -ne "." |
| 69 | done |
| 70 | ''' |
| 71 | } |
| 72 | } catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) { |
| 73 | // if we have a timeout in the Cleanup fase most likely ONOS got stuck somewhere, thuse force remove the pods |
| 74 | sh ''' |
| 75 | kubectl get pods | grep Terminating | awk '{print $1}' | xargs kubectl delete pod --force --grace-period=0 |
| 76 | ''' |
| 77 | } |
| 78 | timeout(time: 10, unit: 'MINUTES') { |
| 79 | script { |
| 80 | helmTeardown(["default", "voltha1", "voltha-infra"]) |
| 81 | } |
| 82 | sh returnStdout: false, script: ''' |
| 83 | helm repo add onf https://charts.opencord.org |
| 84 | helm repo update |
| 85 | |
| 86 | # remove all persistent volume claims |
| 87 | kubectl delete pvc --all-namespaces --all |
| 88 | PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l) |
| 89 | while [[ \$PVCS != 0 ]]; do |
| 90 | sleep 5 |
| 91 | PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l) |
| 92 | done |
| 93 | |
| 94 | # remove orphaned port-forward from different namespaces |
| 95 | ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true |
| 96 | ''' |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | stage('Deploy Voltha') { |
| 102 | steps { |
| 103 | timeout(time: 10, unit: 'MINUTES') { |
| 104 | installVoltctl("${release}") |
| 105 | script { |
| 106 | startComponentsLogs([ |
| 107 | appsToLog: [ |
| 108 | 'app.kubernetes.io/name=etcd', |
| 109 | 'app.kubernetes.io/name=kafka', |
| 110 | 'app=lwc', |
| 111 | 'app=adapter-open-onu', |
| 112 | 'app=adapter-open-olt', |
| 113 | 'app=rw-core', |
| 114 | 'app=bbsim', |
| 115 | ] |
| 116 | ]) |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | } |