Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -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 | // voltha-2.x e2e tests |
| 16 | // uses kind-voltha to deploy voltha-2.X |
| 17 | // uses bbsim to simulate OLT/ONUs |
| 18 | |
| 19 | pipeline { |
| 20 | |
| 21 | /* no label, executor is determined by JJB */ |
| 22 | agent { |
| 23 | label "${params.executorNode}" |
| 24 | } |
| 25 | options { |
| 26 | timeout(time: 40, unit: 'MINUTES') |
| 27 | } |
| 28 | |
| 29 | stages { |
| 30 | |
| 31 | stage('Download kind-voltha') { |
| 32 | steps { |
| 33 | sh """ |
Matteo Scandolo | a61c6d6 | 2019-09-23 17:17:27 -0700 | [diff] [blame] | 34 | rm -rf kind-voltha |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 35 | git clone https://github.com/ciena/kind-voltha.git |
| 36 | """ |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | stage('Deploy Voltha') { |
| 41 | steps { |
| 42 | sh """ |
| 43 | cd kind-voltha/ |
| 44 | EXTRA_HELM_FLAGS="${params.extraHelmFlags}" VOLTHA_LOG_LEVEL=DEBUG TYPE=minimal WITH_RADIUS=y WITH_BBSIM=n INSTALL_ONOS_APPS=y CONFIG_SADIS=y FANCY=0 ./voltha up |
| 45 | """ |
| 46 | } |
| 47 | } |
| 48 | |
Matteo Scandolo | a61c6d6 | 2019-09-23 17:17:27 -0700 | [diff] [blame] | 49 | stage('Download BBSim repo') { |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 50 | steps { |
| 51 | sh """ |
| 52 | cd $WORKSPACE |
Matteo Scandolo | a61c6d6 | 2019-09-23 17:17:27 -0700 | [diff] [blame] | 53 | rm -rf bbsim |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 54 | git clone https://github.com/opencord/bbsim.git bbsim |
Matteo Scandolo | a61c6d6 | 2019-09-23 17:17:27 -0700 | [diff] [blame] | 55 | """ |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | stage('config ONOS with BBSim sadis values') { |
| 60 | steps { |
| 61 | sh """ |
| 62 | cd $WORKSPACE/bbsim |
Matteo Scandolo | b95573a | 2019-09-24 09:54:22 -0700 | [diff] [blame] | 63 | curl --user karaf:karaf -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @examples/sadis-minimal-voltha-2.json http://127.0.0.1:8181/onos/v1/network/configuration/apps |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 64 | curl --user karaf:karaf -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @examples/onos-dhcp.json http://127.0.0.1:8181/onos/v1/network/configuration/apps |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 65 | """ |
| 66 | } |
| 67 | } |
| 68 | |
Matteo Scandolo | a61c6d6 | 2019-09-23 17:17:27 -0700 | [diff] [blame] | 69 | stage('Build and Deploy BBSim') { |
| 70 | // This step doing multple things as it is (hopefully) a temporary step |
| 71 | // once the new-bbsim is integrated with kind-voltha this all pipeline should be dismissed |
| 72 | steps { |
| 73 | sh ''' |
| 74 | cd $WORKSPACE/kind-voltha/ |
| 75 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 76 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
| 77 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
| 78 | cd $WORKSPACE/bbsim |
| 79 | # DOCKER_TAG=candidate make docker-build |
| 80 | # TYPE=minimal kind load docker-image voltha/bbsim:candidate --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; |
| 81 | # helm install -n bbsim deployments/helm-chart/bbsim/ --set images.bbsim.tag=candidate --set images.bbsim.pullPolicy=IfNotProsent |
| 82 | helm install -n bbsim deployments/helm-chart/bbsim/ --set images.bbsim.tag=master |
| 83 | ''' |
| 84 | } |
| 85 | } |
| 86 | |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 87 | stage('Run E2E Tests') { |
| 88 | steps { |
| 89 | sh ''' |
| 90 | git clone https://gerrit.opencord.org/voltha-system-tests |
| 91 | cd kind-voltha/ |
| 92 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 93 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
| 94 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
| 95 | cd $WORKSPACE/voltha-system-tests/tests/sanity |
| 96 | robot -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101 -e notready --critical sanity -v num_onus:1 -v BBSIM_IP:bbsim-olt-id-0 -v BBSIM_OLT_SN:BBSIM_OLT_0 -b BBSIM_ONU_SN:BBSM00000001 sanity.robot || true |
| 97 | ''' |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | post { |
| 103 | always { |
| 104 | sh ''' |
| 105 | # copy robot logs |
| 106 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 107 | cp -r $WORKSPACE/voltha-system-tests/tests/sanity/*ml ./RobotLogs || true |
| 108 | cd kind-voltha/ |
| 109 | cp install-minimal.log $WORKSPACE/ |
| 110 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 111 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
| 112 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
| 113 | kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s "[[:space:]]" "\n" | sort | uniq -c |
| 114 | kubectl get nodes -o wide |
| 115 | kubectl get pods -o wide |
| 116 | kubectl get pods -n voltha -o wide |
| 117 | ## get default pod logs |
| 118 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 119 | do |
| 120 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 121 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 122 | else |
| 123 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 124 | fi |
| 125 | done |
| 126 | ## get voltha pod logs |
| 127 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 128 | do |
| 129 | if [[ \$pod == *"-api-"* ]]; then |
| 130 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 131 | else |
| 132 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 133 | fi |
| 134 | done |
| 135 | ## clean up node |
| 136 | WAIT_ON_DOWN=y ./voltha down |
| 137 | cd $WORKSPACE/ |
| 138 | rm -rf kind-voltha/ voltha-system-tests/ || true |
| 139 | ''' |
| 140 | step([$class: 'RobotPublisher', |
| 141 | disableArchiveOutput: false, |
| 142 | logFileName: 'RobotLogs/log*.html', |
| 143 | otherFiles: '', |
| 144 | outputFileName: 'RobotLogs/output*.xml', |
| 145 | outputPath: '.', |
Matteo Scandolo | 26bc17e | 2019-09-24 09:03:01 -0700 | [diff] [blame] | 146 | passThreshold: 100, |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 147 | reportFileName: 'RobotLogs/report*.html', |
| 148 | unstableThreshold: 0]); |
| 149 | archiveArtifacts artifacts: '*.log' |
Matteo Scandolo | b95573a | 2019-09-24 09:54:22 -0700 | [diff] [blame] | 150 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "teo@opennetworking.org", sendToIndividuals: false]) |
Matteo Scandolo | e43b5f8 | 2019-09-23 15:21:04 -0700 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | } |