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