hwchiu | fdc4924 | 2019-11-18 16:37: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 | // voltha-2.x e2e tests |
| 16 | // uses kind-voltha to deploy voltha-2.X |
| 17 | // uses bbsim to simulate OLT/ONUs |
| 18 | |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 19 | |
| 20 | def logKubernetes(prefix) { |
| 21 | sh """ |
| 22 | set +e |
| 23 | cd kind-voltha/ |
| 24 | cp install-minimal.log $WORKSPACE/${prefix}_instsall-minimal.log |
| 25 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 26 | kubectl get nodes -o wide |
| 27 | kubectl get pods -o wide |
| 28 | kubectl get pods -n voltha -o wide |
| 29 | ## get default pod logs |
| 30 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 31 | do |
| 32 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 33 | kubectl logs \$pod onos> $WORKSPACE/${prefix}_\$pod.log; |
| 34 | else |
| 35 | kubectl logs \$pod> $WORKSPACE/${prefix}_\$pod.log; |
| 36 | fi |
| 37 | done |
| 38 | ## get voltha pod logs |
| 39 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 40 | do |
| 41 | if [[ \$pod == *"-api-"* ]]; then |
| 42 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/${prefix}_\$pod.log; |
| 43 | elif [[ \$pod == "bbsim-"* ]]; then |
| 44 | kubectl logs \$pod -n voltha -p > $WORKSPACE/${prefix}_\$pod.log; |
| 45 | else |
| 46 | kubectl logs \$pod -n voltha > $WORKSPACE/${prefix}_\$pod.log; |
| 47 | fi |
| 48 | done |
| 49 | """ |
| 50 | } |
| 51 | |
| 52 | |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 53 | pipeline { |
| 54 | |
| 55 | /* no label, executor is determined by JJB */ |
| 56 | agent { |
| 57 | label "${params.buildNode}" |
| 58 | } |
| 59 | options { |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 60 | timeout(time: 80, unit: 'MINUTES') |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 61 | } |
| 62 | environment { |
| 63 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 64 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 65 | PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin" |
| 66 | TYPE="minimal" |
| 67 | FANCY=0 |
| 68 | WITH_SIM_ADAPTERS="n" |
| 69 | WITH_RADIUS="y" |
| 70 | WITH_BBSIM="y" |
| 71 | DEPLOY_K8S="y" |
| 72 | VOLTHA_LOG_LEVEL="DEBUG" |
| 73 | CONFIG_SADIS="y" |
| 74 | EXTRA_HELM_FLAGS="${params.extraHelmFlags} --set voltha-etcd-cluster.clusterSize=3" |
| 75 | ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs" |
| 76 | } |
| 77 | stages { |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 78 | stage('Download kind-voltha') { |
| 79 | steps { |
| 80 | sh """ |
| 81 | git clone https://github.com/ciena/kind-voltha.git |
| 82 | """ |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | stage('Deploy Voltha') { |
| 87 | steps { |
| 88 | sh """ |
hwchiu | c7d5d03 | 2019-12-03 16:42:47 -0800 | [diff] [blame] | 89 | pushd kind-voltha/ |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 90 | ./voltha up |
hwchiu | c7d5d03 | 2019-12-03 16:42:47 -0800 | [diff] [blame] | 91 | popd |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 92 | """ |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | stage('Run E2E Tests') { |
| 97 | steps { |
| 98 | sh ''' |
| 99 | rm -rf $WORKSPACE/RobotLogs; mkdir -p $WORKSPACE/RobotLogs |
| 100 | git clone https://gerrit.opencord.org/voltha-system-tests |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 101 | make ROBOT_DEBUG_LOG_OPT="-l sanity_log.html -r sanity_result.html -o sanity_result.xml" -C $WORKSPACE/voltha-system-tests ${makeTarget} |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 102 | ''' |
| 103 | } |
| 104 | } |
| 105 | |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 106 | stage('Log the kubernetes for sanity-test') { |
| 107 | steps { |
| 108 | logKubernetes('sanity_test') |
| 109 | } |
| 110 | } |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 111 | //Remove this stage once https://jira.opencord.org/browse/VOL-1977 be resolved |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 112 | stage('Deploy Voltha Again for Functional Tests') { |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 113 | steps { |
| 114 | sh """ |
hwchiu | c7d5d03 | 2019-12-03 16:42:47 -0800 | [diff] [blame] | 115 | pushd kind-voltha/ |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 116 | WAIT_ON_DOWN=yes DEPLOY_K8S=no ./voltha down |
| 117 | DEPLOY_K8S=no ./voltha up |
hwchiu | c7d5d03 | 2019-12-03 16:42:47 -0800 | [diff] [blame] | 118 | popd |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 119 | """ |
| 120 | } |
| 121 | } |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 122 | |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 123 | stage('Kubernetes Functional Tests') { |
| 124 | steps { |
| 125 | sh ''' |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 126 | make ROBOT_DEBUG_LOG_OPT="-l functional_log.html -r functional_result.html -o functional_output.xml" -C $WORKSPACE/voltha-system-tests system-scale-test |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 127 | ''' |
| 128 | } |
| 129 | } |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 130 | |
| 131 | stage('Log the kubernetes for functional-test') { |
| 132 | steps { |
| 133 | logKubernetes('functional') |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | //Remove this stage once https://jira.opencord.org/browse/VOL-1977 be resolved |
| 138 | stage('Deploy Voltha Again for Failure Scenario Tests') { |
| 139 | steps { |
| 140 | sh """ |
| 141 | pushd kind-voltha/ |
| 142 | WAIT_ON_DOWN=yes DEPLOY_K8S=no ./voltha down |
| 143 | DEPLOY_K8S=no ./voltha up |
| 144 | popd |
| 145 | """ |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | stage('Kubernetes Failure Scenario Tests') { |
| 150 | steps { |
| 151 | sh ''' |
| 152 | make ROBOT_DEBUG_LOG_OPT="-l failure_log.html -r failure_result.html -o failure_output.xml" -C $WORKSPACE/voltha-system-tests failure-test |
| 153 | ''' |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | stage('Log the kubernetes for failure scenario test') { |
| 158 | steps { |
| 159 | logKubernetes('failure') |
| 160 | } |
| 161 | } |
| 162 | |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | post { |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 166 | failure { |
| 167 | logKubernetes('last') |
| 168 | } |
| 169 | aborted { |
| 170 | logKubernetes('last') |
| 171 | } |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 172 | always { |
hwchiu | 8585b57 | 2019-12-16 11:20:43 -0800 | [diff] [blame] | 173 | |
hwchiu | fdc4924 | 2019-11-18 16:37:22 -0800 | [diff] [blame] | 174 | step([$class: 'RobotPublisher', |
| 175 | disableArchiveOutput: false, |
| 176 | logFileName: 'RobotLogs/*log*.html', |
| 177 | otherFiles: '', |
| 178 | outputFileName: 'RobotLogs/*output*.xml', |
| 179 | outputPath: '.', |
| 180 | passThreshold: 100, |
| 181 | reportFileName: 'RobotLogs/*report*.html', |
| 182 | unstableThreshold: 0]); |
| 183 | archiveArtifacts artifacts: '*.log' |
| 184 | |
| 185 | } |
| 186 | } |
| 187 | } |