Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -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.buildNode}" |
| 24 | } |
| 25 | options { |
Andy Bavier | 6a801b3 | 2020-05-27 12:53:15 -0700 | [diff] [blame] | 26 | timeout(time: 60, unit: 'MINUTES') |
Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -0700 | [diff] [blame] | 27 | } |
| 28 | environment { |
| 29 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 30 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 31 | PATH="$HOME/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 32 | TYPE="minimal" |
| 33 | FANCY=0 |
| 34 | WITH_SIM_ADAPTERS="no" |
| 35 | WITH_RADIUS="yes" |
| 36 | WITH_BBSIM="yes" |
| 37 | DEPLOY_K8S="yes" |
| 38 | VOLTHA_LOG_LEVEL="DEBUG" |
| 39 | CONFIG_SADIS="no" |
Andy Bavier | 4be3706 | 2020-06-29 15:17:26 -0700 | [diff] [blame] | 40 | ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}" |
Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -0700 | [diff] [blame] | 41 | } |
| 42 | stages { |
| 43 | |
| 44 | stage('Repo') { |
| 45 | steps { |
| 46 | step([$class: 'WsCleanup']) |
| 47 | checkout(changelog: true, |
| 48 | poll: false, |
| 49 | scm: [$class: 'RepoScm', |
| 50 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 51 | manifestBranch: "${params.branch}", |
| 52 | currentBranch: true, |
| 53 | destinationDir: 'voltha', |
| 54 | forceSync: true, |
| 55 | resetFirst: true, |
| 56 | quiet: true, |
| 57 | jobs: 4, |
| 58 | showAllChanges: true] |
| 59 | ) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | stage('Download kind-voltha') { |
| 64 | steps { |
| 65 | sh """ |
| 66 | cd $HOME |
| 67 | [ -d kind-voltha ] || git clone https://gerrit.opencord.org/kind-voltha |
| 68 | rm -rf $HOME/kind-voltha/scripts/logger |
| 69 | cd $HOME/kind-voltha |
| 70 | git pull |
| 71 | """ |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | stage('Deploy Voltha') { |
| 76 | steps { |
| 77 | sh """ |
| 78 | export EXTRA_HELM_FLAGS="" |
| 79 | if [ "${branch}" != "master" ]; then |
| 80 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
| 81 | source "$HOME/kind-voltha/releases/${branch}" |
| 82 | else |
| 83 | echo "on master, using default settings for kind-voltha" |
| 84 | fi |
| 85 | |
| 86 | EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags} " |
| 87 | |
| 88 | cd $HOME/kind-voltha/ |
| 89 | WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down |
| 90 | ./voltha up |
| 91 | """ |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | stage('Functional Tests') { |
| 96 | environment { |
| 97 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests" |
| 98 | } |
| 99 | steps { |
| 100 | sh ''' |
| 101 | set +e |
| 102 | mkdir -p $ROBOT_LOGS_DIR |
| 103 | cd $HOME/kind-voltha/scripts |
| 104 | ./log-collector.sh > /dev/null & |
| 105 | ./log-combine.sh > /dev/null & |
| 106 | |
| 107 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
| 108 | make -C $WORKSPACE/voltha/voltha-system-tests functional-single-kind || true |
| 109 | ''' |
| 110 | } |
| 111 | } |
| 112 | |
Hung-Wei Chiu | c72fe1f | 2020-05-04 13:54:32 -0700 | [diff] [blame] | 113 | stage('Alarm Tests') { |
| 114 | environment { |
| 115 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/AlarmTests" |
| 116 | } |
| 117 | steps { |
| 118 | sh ''' |
| 119 | set +e |
| 120 | mkdir -p $WORKSPACE/RobotLogs |
| 121 | |
| 122 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
| 123 | make -C $WORKSPACE/voltha/voltha-system-tests bbsim-alarms-kind || true |
| 124 | ''' |
| 125 | } |
| 126 | } |
| 127 | |
Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -0700 | [diff] [blame] | 128 | stage('Failure/Recovery Tests') { |
| 129 | environment { |
| 130 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureTests" |
| 131 | } |
| 132 | steps { |
| 133 | sh ''' |
| 134 | set +e |
| 135 | mkdir -p $WORKSPACE/RobotLogs |
| 136 | |
| 137 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
| 138 | make -C $WORKSPACE/voltha/voltha-system-tests bbsim-failurescenarios || true |
| 139 | ''' |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | stage('Error Tests') { |
| 144 | environment { |
| 145 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ErrorTests" |
| 146 | } |
| 147 | steps { |
| 148 | sh ''' |
| 149 | set +e |
| 150 | mkdir -p $WORKSPACE/RobotLogs |
| 151 | |
| 152 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
| 153 | make -C $WORKSPACE/voltha/voltha-system-tests bbsim-errorscenarios || true |
| 154 | ''' |
| 155 | } |
| 156 | } |
Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | post { |
| 160 | always { |
| 161 | sh ''' |
| 162 | set +e |
| 163 | cp $HOME/kind-voltha/install-minimal.log $WORKSPACE/ |
| 164 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 165 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 166 | kubectl get nodes -o wide |
| 167 | kubectl get pods -o wide |
| 168 | kubectl get pods -n voltha -o wide |
| 169 | |
| 170 | sleep 60 # Wait for log-collector and log-combine to complete |
| 171 | |
| 172 | ## Pull out errors from log files |
| 173 | extract_errors_go() { |
| 174 | echo |
| 175 | echo "Error summary for $1:" |
| 176 | grep '"level":"error"' $HOME/kind-voltha/scripts/logger/combined/$1* |
| 177 | echo |
| 178 | } |
| 179 | |
| 180 | extract_errors_python() { |
| 181 | echo |
| 182 | echo "Error summary for $1:" |
| 183 | grep 'ERROR' $HOME/kind-voltha/scripts/logger/combined/$1* |
| 184 | echo |
| 185 | } |
| 186 | |
| 187 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 188 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 189 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 190 | extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log |
| 191 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 192 | |
| 193 | cd $HOME/kind-voltha/scripts/logger/combined/ |
| 194 | tar czf $WORKSPACE/container-logs.tgz * |
| 195 | |
| 196 | cd $WORKSPACE |
| 197 | gzip *-combined.log || true |
| 198 | |
Hung-Wei Chiu | 9669b7d | 2020-05-14 12:12:05 -0700 | [diff] [blame] | 199 | ## Collect ONOS log |
| 200 | wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-k8s |
| 201 | wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-profile |
| 202 | chmod 755 onos-diagnostics-k8s |
| 203 | pod_name=$(kubectl get pods -lapp=onos-onos-classic -o name | cut -d '/' -f2 | tr '\n' ' ') |
| 204 | ./onos-diagnostics-k8s -k karaf ${pod_names} |
| 205 | cp /tmp/onos-diags.tar.gz $WORKSPACE/onos-diags.tar.gz |
| 206 | |
Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -0700 | [diff] [blame] | 207 | ## shut down voltha but leave kind-voltha cluster |
| 208 | cd $HOME/kind-voltha/ |
| 209 | DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down |
Andy Bavier | fcae383 | 2020-06-04 08:51:10 -0700 | [diff] [blame] | 210 | kubectl delete deployment voltctl || true |
Hung-Wei Chiu | 5ec2edf | 2020-04-30 14:53:13 -0700 | [diff] [blame] | 211 | ''' |
| 212 | step([$class: 'RobotPublisher', |
| 213 | disableArchiveOutput: false, |
| 214 | logFileName: '**/log*.html', |
| 215 | otherFiles: '', |
| 216 | outputFileName: '**/output*.xml', |
| 217 | outputPath: 'RobotLogs', |
| 218 | passThreshold: 100, |
| 219 | reportFileName: '**/report*.html', |
| 220 | unstableThreshold: 0]); |
| 221 | |
| 222 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz' |
| 223 | |
| 224 | } |
| 225 | } |
| 226 | } |