Luca Prete | 45401c8 | 2019-01-15 15:31:22 -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") { |
| 19 | sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir}" |
| 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools" |
| 21 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
| 22 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 23 | } |
| 24 | stage('Clean up') { |
| 25 | timeout(10) { |
| 26 | sh returnStdout: true, script: """ |
| 27 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 28 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 29 | do |
| 30 | echo "Purging chart: \${hchart}" |
| 31 | helm delete --purge "\${hchart}" |
| 32 | done |
| 33 | """ |
| 34 | timeout(5) { |
| 35 | waitUntil { |
| 36 | helm_deleted = sh returnStdout: true, script: """ |
| 37 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 38 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 39 | """ |
| 40 | return helm_deleted.toInteger() == 0 |
| 41 | } |
| 42 | } |
| 43 | timeout(5) { |
| 44 | waitUntil { |
| 45 | kubectl_deleted = sh returnStdout: true, script: """ |
| 46 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 47 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 48 | """ |
| 49 | return kubectl_deleted.toInteger() == 0 |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | stage('Add CORD repository') { |
| 55 | sh returnStdout: true, script: """ |
| 56 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 57 | helm repo add cord https://charts.opencord.org |
| 58 | helm repo update |
| 59 | """ |
| 60 | timeout(1) { |
| 61 | waitUntil { |
| 62 | cord_repo_present = sh returnStdout: true, script: """ |
| 63 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 64 | helm repo list | grep cord | wc -l |
| 65 | """ |
| 66 | return cord_repo_present.toInteger() == 1 |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | stage('Install CORD Kafka') { |
| 71 | timeout(10) { |
| 72 | sh returnStdout: true, script: """ |
| 73 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 74 | helm install --version 0.8.8 --set configurationOverrides."offsets\\.topic\\.replication\\.factor"=1 --set configurationOverrides."log\\.retention\\.hours"=4 --set configurationOverrides."log\\.message\\.timestamp\\.type"="LogAppendTime" --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false -n cord-kafka incubator/kafka |
| 75 | """ |
| 76 | } |
| 77 | timeout(10) { |
| 78 | waitUntil { |
| 79 | kafka_instances_running = sh returnStdout: true, script: """ |
| 80 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 81 | kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l |
| 82 | """ |
| 83 | return kafka_instances_running.toInteger() == 2 |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | stage('Install Logging Infrastructure') { |
| 88 | timeout(10) { |
| 89 | sh returnStdout: true, script: """ |
| 90 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 91 | helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set elasticsearch.cluster.env.MINIMUM_MASTER_NODES="1" --set elasticsearch.client.replicas=1 --set elasticsearch.master.replicas=2 --set elasticsearch.master.persistence.enabled=false --set elasticsearch.data.replicas=1 --set elasticsearch.data.persistence.enabled=false -n logging cord/logging |
| 92 | helm-repo-tools/wait_for_pods.sh |
| 93 | """ |
| 94 | } |
| 95 | } |
| 96 | stage('Install Monitoring Infrastructure') { |
| 97 | timeout(10) { |
| 98 | sh returnStdout: true, script: """ |
| 99 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 100 | helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring |
| 101 | helm-repo-tools/wait_for_pods.sh |
| 102 | """ |
| 103 | } |
| 104 | } |
| 105 | stage('Install ONOS') { |
| 106 | timeout(10) { |
| 107 | sh returnStdout: true, script: """ |
| 108 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 109 | helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos |
| 110 | """ |
| 111 | } |
| 112 | timeout(10) { |
| 113 | waitUntil { |
| 114 | onos_completed = sh returnStdout: true, script: """ |
| 115 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 116 | kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l |
| 117 | """ |
| 118 | return onos_completed.toInteger() == 1 |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | stage('Install xos-core') { |
| 123 | timeout(10) { |
| 124 | sh returnStdout: true, script: """ |
| 125 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 126 | helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core |
| 127 | """ |
| 128 | } |
| 129 | timeout(10) { |
| 130 | waitUntil { |
| 131 | xos_core_completed = sh returnStdout: true, script: """ |
| 132 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 133 | kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l |
| 134 | """ |
| 135 | return xos_core_completed.toInteger() == 6 |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | if ( params.configurePod ) { |
| 141 | dir ("${configBaseDir}/${configToscaDir}/att-workflow") { |
| 142 | stage('Configure R-CORD - Fabric and whitelist') { |
| 143 | timeout(1) { |
| 144 | waitUntil { |
| 145 | out_fabric = sh returnStdout: true, script: """ |
| 146 | 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 |
| 147 | """ |
| 148 | return out_fabric.toInteger() == 1 |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | stage('Configure R-CORD - Subscriber') { |
| 153 | timeout(1) { |
| 154 | waitUntil { |
| 155 | out_subscriber = sh returnStdout: true, script: """ |
| 156 | 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 |
| 157 | """ |
| 158 | return out_subscriber.toInteger() == 1 |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | stage('Configure R-CORD - OLT') { |
| 163 | timeout(1) { |
| 164 | waitUntil { |
| 165 | out_olt = sh returnStdout: true, script: """ |
| 166 | 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 |
| 167 | """ |
| 168 | return out_olt.toInteger() == 1 |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | currentBuild.result = 'SUCCESS' |
| 175 | } catch (err) { |
| 176 | currentBuild.result = 'FAILURE' |
| 177 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 178 | } |
| 179 | echo "RESULT: ${currentBuild.result}" |
| 180 | } |
| 181 | } |