Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [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 { |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 26 | timeout(time: 30, unit: 'MINUTES') |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 27 | } |
| 28 | environment { |
| 29 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 30 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 31 | PATH="$PATH:$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 32 | NAME="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="external" |
| 40 | BBSIM_CFG="configs/bbsim-sadis-att.yaml" |
| 41 | ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}" |
| 42 | KARAF_HOME="${params.karafHome}" |
| 43 | DIAGS_PROFILE="VOLTHA_PROFILE" |
| 44 | NUM_OF_BBSIM="${olts}" |
| 45 | } |
| 46 | stages { |
| 47 | stage('Clone kind-voltha') { |
| 48 | steps { |
| 49 | checkout([ |
| 50 | $class: 'GitSCM', |
| 51 | userRemoteConfigs: [[ |
| 52 | url: "https://gerrit.opencord.org/kind-voltha", |
| 53 | // refspec: "${kindVolthaChange}" |
| 54 | ]], |
| 55 | branches: [[ name: "master", ]], |
| 56 | extensions: [ |
| 57 | [$class: 'WipeWorkspace'], |
| 58 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 59 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 60 | ], |
| 61 | ]) |
| 62 | } |
| 63 | } |
| 64 | stage('Cleanup') { |
| 65 | steps { |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 66 | timeout(time: 10, unit: 'MINUTES') { |
| 67 | sh """ |
| 68 | if [ "${branch}" != "master" ]; then |
| 69 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
| 70 | source "$WORKSPACE/kind-voltha/releases/${branch}" |
| 71 | else |
| 72 | echo "on master, using default settings for kind-voltha" |
| 73 | fi |
| 74 | cd $WORKSPACE/kind-voltha/ |
| 75 | WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down |
| 76 | """ |
| 77 | } |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | stage('Clone voltha-system-tests') { |
| 81 | steps { |
| 82 | checkout([ |
| 83 | $class: 'GitSCM', |
| 84 | userRemoteConfigs: [[ |
| 85 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 86 | // refspec: "${volthaSystemTestsChange}" |
| 87 | ]], |
| 88 | branches: [[ name: "${branch}", ]], |
| 89 | extensions: [ |
| 90 | [$class: 'WipeWorkspace'], |
| 91 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 92 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 93 | ], |
| 94 | ]) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | stage('Deploy Voltha') { |
| 99 | steps { |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 100 | timeout(time: 10, unit: 'MINUTES') { |
| 101 | sh """ |
| 102 | export EXTRA_HELM_FLAGS="" |
| 103 | if [ "${branch}" != "master" ]; then |
| 104 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
| 105 | source "$WORKSPACE/kind-voltha/releases/${branch}" |
| 106 | else |
| 107 | echo "on master, using default settings for kind-voltha" |
| 108 | fi |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 109 | |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 110 | EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags}" |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 111 | |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 112 | cd $WORKSPACE/kind-voltha/ |
| 113 | ./voltha up |
| 114 | """ |
| 115 | } |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | |
| 119 | stage('Device Management Interface Tests') { |
| 120 | environment { |
| 121 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DMITests" |
| 122 | } |
| 123 | steps { |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 124 | timeout(time: 10, unit: 'MINUTES') { |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 125 | sh ''' |
| 126 | set +e |
| 127 | mkdir -p $ROBOT_LOGS_DIR |
| 128 | cd $WORKSPACE/kind-voltha/scripts |
| 129 | ./log-collector.sh > /dev/null & |
| 130 | ./log-combine.sh > /dev/null & |
| 131 | |
Andrea Campanella | e973949 | 2020-12-17 09:54:04 +0100 | [diff] [blame] | 132 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 133 | make -C $WORKSPACE/voltha-system-tests ${makeTarget} || true |
| 134 | ''' |
Matteo Scandolo | e4abf85 | 2021-05-18 09:12:11 -0700 | [diff] [blame] | 135 | } |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | post { |
| 141 | always { |
| 142 | sh ''' |
| 143 | set +e |
| 144 | cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/ |
| 145 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 146 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 147 | kubectl get nodes -o wide |
| 148 | kubectl get pods -o wide |
| 149 | kubectl get pods -n voltha -o wide |
| 150 | |
| 151 | sleep 60 # Wait for log-collector and log-combine to complete |
| 152 | |
| 153 | ## Pull out errors from log files |
| 154 | extract_errors_go() { |
| 155 | echo |
| 156 | echo "Error summary for $1:" |
| 157 | grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
| 158 | echo |
| 159 | } |
| 160 | |
| 161 | extract_errors_python() { |
| 162 | echo |
| 163 | echo "Error summary for $1:" |
| 164 | grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
| 165 | echo |
| 166 | } |
| 167 | |
| 168 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 169 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 170 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 171 | extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log |
| 172 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 173 | |
| 174 | gzip error-report.log || true |
| 175 | |
| 176 | cd $WORKSPACE/kind-voltha/scripts/logger/combined/ |
| 177 | tar czf $WORKSPACE/container-logs.tgz * |
| 178 | |
| 179 | cd $WORKSPACE |
| 180 | gzip *-combined.log || true |
| 181 | |
| 182 | ## shut down voltha but leave kind-voltha cluster |
Andrea Campanella | 57735a8 | 2021-05-18 13:22:49 +0200 | [diff] [blame] | 183 | if [ "${branch}" != "master" ]; then |
| 184 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
| 185 | source "$WORKSPACE/kind-voltha/releases/${branch}" |
| 186 | else |
| 187 | echo "on master, using default settings for kind-voltha" |
| 188 | fi |
Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 189 | cd $WORKSPACE/kind-voltha/ |
| 190 | DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down |
| 191 | kubectl delete deployment voltctl || true |
| 192 | ''' |
| 193 | step([$class: 'RobotPublisher', |
| 194 | disableArchiveOutput: false, |
| 195 | logFileName: '**/log*.html', |
| 196 | otherFiles: '', |
| 197 | outputFileName: '**/output*.xml', |
| 198 | outputPath: 'RobotLogs', |
| 199 | passThreshold: 100, |
| 200 | reportFileName: '**/report*.html', |
| 201 | unstableThreshold: 0]); |
| 202 | |
| 203 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz' |
| 204 | |
| 205 | } |
| 206 | } |
| 207 | } |