Matteo Scandolo | c88d313 | 2020-08-27 15:24:34 -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 | pipeline { |
| 16 | |
| 17 | agent { |
| 18 | label "${params.buildNode}" |
| 19 | } |
| 20 | options { |
| 21 | timeout(time: 30, unit: 'MINUTES') |
| 22 | } |
| 23 | environment { |
| 24 | |
| 25 | } |
| 26 | |
| 27 | stages { |
| 28 | stage ('Cleanup') { |
| 29 | steps { |
| 30 | timeout(time: 11, unit: 'MINUTES') { |
| 31 | sh returnStdout: false, script: """ |
| 32 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com |
| 33 | helm repo add stable https://kubernetes-charts.storage.googleapis.com |
| 34 | helm repo add onf https://charts.opencord.org |
| 35 | helm repo add cord https://charts.opencord.org |
| 36 | helm repo add onos https://charts.onosproject.org |
| 37 | helm repo add atomix https://charts.atomix.io |
| 38 | helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts |
| 39 | helm repo update |
| 40 | |
| 41 | # removing ETCD port forward |
| 42 | P_ID="\$(ps e -ww -A | grep "_TAG=etcd-port-forward" | grep -v grep | awk '{print \$1}')" |
| 43 | if [ -n "\$P_ID" ]; then |
| 44 | kill -9 \$P_ID |
| 45 | fi |
| 46 | |
| 47 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|kafkacat'); |
| 48 | do |
| 49 | echo "Purging chart: \${hchart}" |
| 50 | helm delete "\${hchart}" |
| 51 | done |
| 52 | bash /home/cord/voltha-scale/wait_for_pods.sh |
| 53 | |
| 54 | test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down |
| 55 | |
| 56 | cd $WORKSPACE |
| 57 | rm -rf $WORKSPACE/* |
| 58 | """ |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | stage('Clone kind-voltha') { |
| 63 | steps { |
| 64 | checkout([ |
| 65 | $class: 'GitSCM', |
| 66 | userRemoteConfigs: [[ url: "https://gerrit.opencord.org/kind-voltha", ]], |
| 67 | branches: [[ name: "master", ]], |
| 68 | extensions: [ |
| 69 | [$class: 'WipeWorkspace'], |
| 70 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 71 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 72 | ], |
| 73 | ]) |
| 74 | script { |
| 75 | sh(script:""" |
| 76 | if [ '${kindVolthaChange}' != '' ] ; then |
| 77 | cd $WORKSPACE/kind-voltha; |
| 78 | git fetch https://gerrit.opencord.org/kind-voltha ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 79 | fi |
| 80 | """) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | stage('Clone voltha-system-tests') { |
| 85 | steps { |
| 86 | checkout([ |
| 87 | $class: 'GitSCM', |
| 88 | userRemoteConfigs: [[ url: "https://gerrit.opencord.org/voltha-system-tests", ]], |
| 89 | branches: [[ name: "${release}", ]], |
| 90 | extensions: [ |
| 91 | [$class: 'WipeWorkspace'], |
| 92 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 93 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 94 | ], |
| 95 | ]) |
| 96 | script { |
| 97 | sh(script:""" |
| 98 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 99 | cd $WORKSPACE/voltha-system-tests; |
| 100 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 101 | fi |
| 102 | """) |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | stage('Deploy and test') { |
| 107 | repeat_deploy_and_test(topologies) |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | topologies = [ |
| 113 | {'onu': 1, 'pon': 1}, |
| 114 | {'onu': 2, 'pon': 1}, |
| 115 | {'onu': 2, 'pon': 2}, |
| 116 | ] |
| 117 | |
| 118 | def repeat_deploy_and_test(list) { |
| 119 | for (int i = 0; i < list.size(); i++) { |
| 120 | sh "echo Setting up with ${list[i]['pon']}x${list[i]['onu']}" |
| 121 | } |
| 122 | } |