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 """ |
| 34 | git clone https://github.com/ciena/kind-voltha.git |
| 35 | """ |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | stage('Deploy Voltha') { |
| 40 | steps { |
| 41 | sh """ |
| 42 | cd kind-voltha/ |
| 43 | 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 |
| 44 | """ |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | stage('Deploy and run BBSim') { |
| 49 | // This step doing multple things as it is (hopefully) a temporary step |
| 50 | // once the new-bbsim is integrated with kind-voltha this all pipeline should be dismissed |
| 51 | steps { |
| 52 | sh """ |
| 53 | cd $WORKSPACE |
| 54 | git clone https://github.com/opencord/bbsim.git bbsim |
| 55 | cd bbsim |
| 56 | # override sadis config |
| 57 | curl --user karaf:karaf -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d @examples/sadis-minimal.json http://127.0.0.1:8181/onos/v1/network/configuration/apps |
| 58 | 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 |
| 59 | # build and run BBSim |
| 60 | DOCKER_TAG=candidate make docker-build |
| 61 | TYPE=minimal kind load docker-image voltha/bbsim:candidate --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; |
| 62 | helm install -n bbsim deployments/helm-chart/bbsim/ --set images.bbsim.tag=candidate --set images.bbsim.pullPolicy=IfNotProsent |
| 63 | """ |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | stage('Run E2E Tests') { |
| 68 | steps { |
| 69 | sh ''' |
| 70 | git clone https://gerrit.opencord.org/voltha-system-tests |
| 71 | cd kind-voltha/ |
| 72 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 73 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
| 74 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
| 75 | cd $WORKSPACE/voltha-system-tests/tests/sanity |
| 76 | 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 |
| 77 | ''' |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | post { |
| 83 | always { |
| 84 | sh ''' |
| 85 | # copy robot logs |
| 86 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 87 | cp -r $WORKSPACE/voltha-system-tests/tests/sanity/*ml ./RobotLogs || true |
| 88 | cd kind-voltha/ |
| 89 | cp install-minimal.log $WORKSPACE/ |
| 90 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 91 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
| 92 | export PATH=$WORKSPACE/kind-voltha/bin:$PATH |
| 93 | kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s "[[:space:]]" "\n" | sort | uniq -c |
| 94 | kubectl get nodes -o wide |
| 95 | kubectl get pods -o wide |
| 96 | kubectl get pods -n voltha -o wide |
| 97 | ## get default pod logs |
| 98 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 99 | do |
| 100 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 101 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 102 | else |
| 103 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 104 | fi |
| 105 | done |
| 106 | ## get voltha pod logs |
| 107 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 108 | do |
| 109 | if [[ \$pod == *"-api-"* ]]; then |
| 110 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 111 | else |
| 112 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 113 | fi |
| 114 | done |
| 115 | ## clean up node |
| 116 | WAIT_ON_DOWN=y ./voltha down |
| 117 | cd $WORKSPACE/ |
| 118 | rm -rf kind-voltha/ voltha-system-tests/ || true |
| 119 | ''' |
| 120 | step([$class: 'RobotPublisher', |
| 121 | disableArchiveOutput: false, |
| 122 | logFileName: 'RobotLogs/log*.html', |
| 123 | otherFiles: '', |
| 124 | outputFileName: 'RobotLogs/output*.xml', |
| 125 | outputPath: '.', |
| 126 | passThreshold: 80, |
| 127 | reportFileName: 'RobotLogs/report*.html', |
| 128 | unstableThreshold: 0]); |
| 129 | archiveArtifacts artifacts: '*.log' |
| 130 | |
| 131 | } |
| 132 | } |
| 133 | } |