Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -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 { |
| 26 | timeout(time: 90, unit: 'MINUTES') |
| 27 | } |
| 28 | environment { |
| 29 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 30 | VOLTCONFIG="$HOME/.volt/config-minimal" |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 31 | PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 32 | TYPE="minimal" |
| 33 | FANCY=0 |
| 34 | WITH_SIM_ADAPTERS="n" |
| 35 | WITH_RADIUS="y" |
| 36 | WITH_BBSIM="y" |
| 37 | DEPLOY_K8S="y" |
| 38 | VOLTHA_LOG_LEVEL="DEBUG" |
Andrea Campanella | a0cd5be | 2020-09-07 15:47:18 +0200 | [diff] [blame] | 39 | CONFIG_SADIS="external" |
| 40 | BBSIM_CFG="configs/bbsim-sadis-att.yaml" |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 41 | ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs" |
| 42 | } |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 43 | stages { |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 44 | stage('Clone kind-voltha') { |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 45 | steps { |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 46 | checkout([ |
| 47 | $class: 'GitSCM', |
| 48 | userRemoteConfigs: [[ |
| 49 | url: "https://gerrit.opencord.org/kind-voltha", |
| 50 | refspec: "${kindVolthaChange}" |
| 51 | ]], |
| 52 | branches: [[ name: "master", ]], |
| 53 | extensions: [ |
| 54 | [$class: 'WipeWorkspace'], |
| 55 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 56 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 57 | ], |
| 58 | ]) |
| 59 | sh """ |
| 60 | if [ '${kindVolthaChange}' != '' ] ; then |
| 61 | cd $WORKSPACE/kind-voltha |
| 62 | git fetch https://gerrit.opencord.org/kind-voltha ${kindVolthaChange} && git checkout FETCH_HEAD |
| 63 | fi |
| 64 | """ |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 65 | } |
| 66 | } |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 67 | stage('Clone voltha-system-tests') { |
| 68 | steps { |
| 69 | checkout([ |
| 70 | $class: 'GitSCM', |
| 71 | userRemoteConfigs: [[ |
| 72 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 73 | refspec: "${volthaSystemTestsChange}" |
| 74 | ]], |
| 75 | branches: [[ name: "${branch}", ]], |
| 76 | extensions: [ |
| 77 | [$class: 'WipeWorkspace'], |
| 78 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 79 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 80 | ], |
| 81 | ]) |
| 82 | sh """ |
| 83 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 84 | cd $WORKSPACE/voltha-system-tests |
| 85 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 86 | fi |
| 87 | """ |
| 88 | } |
| 89 | } |
| 90 | // If the repo under test is not kind-voltha |
| 91 | // then download it and checkout the patch |
| 92 | stage('Download Patch') { |
| 93 | when { |
| 94 | expression { |
| 95 | return "${gerritProject}" != 'kind-voltha'; |
| 96 | } |
| 97 | } |
| 98 | steps { |
| 99 | checkout([ |
| 100 | $class: 'GitSCM', |
| 101 | userRemoteConfigs: [[ |
| 102 | url: "https://gerrit.opencord.org/${gerritProject}", |
| 103 | refspec: "${gerritRefspec}" |
| 104 | ]], |
| 105 | branches: [[ name: "${branch}", ]], |
| 106 | extensions: [ |
| 107 | [$class: 'WipeWorkspace'], |
| 108 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gerritProject}"], |
| 109 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 110 | ], |
| 111 | ]) |
| 112 | sh """ |
| 113 | pushd $WORKSPACE/${gerritProject} |
| 114 | git fetch https://gerrit.opencord.org/${gerritProject} ${gerritRefspec} && git checkout FETCH_HEAD |
| 115 | echo "Currently on commit: \n" |
| 116 | git log -1 --oneline |
| 117 | popd |
| 118 | """ |
| 119 | } |
| 120 | } |
| 121 | // If the repo under test is kind-voltha we don't need to download it again, |
| 122 | // as we already have it, simply checkout the patch |
| 123 | stage('Checkout kind-voltha patch') { |
| 124 | when { |
| 125 | expression { |
| 126 | return "${gerritProject}" == 'kind-voltha'; |
| 127 | } |
| 128 | } |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 129 | steps { |
| 130 | sh """ |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 131 | cd $WORKSPACE/kind-voltha |
| 132 | git fetch https://gerrit.opencord.org/kind-voltha ${gerritRefspec} && git checkout FETCH_HEAD |
| 133 | """ |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | stage('Create K8s Cluster') { |
| 137 | steps { |
| 138 | sh """ |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 139 | cd $WORKSPACE/kind-voltha/ |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 140 | JUST_K8S=y ./voltha up |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 141 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin" |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 142 | """ |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | stage('Build Images') { |
| 147 | steps { |
| 148 | sh """ |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 149 | make -C $WORKSPACE/voltha-openonu-adapter-go DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 150 | """ |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | stage('Push Images') { |
| 155 | steps { |
| 156 | sh ''' |
| 157 | docker images | grep citest |
| 158 | for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; done |
| 159 | ''' |
| 160 | } |
| 161 | } |
| 162 | stage('Deploy Voltha') { |
| 163 | steps { |
| 164 | sh ''' |
Matteo Scandolo | f21ae31 | 2020-04-29 21:04:15 -0700 | [diff] [blame] | 165 | export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} " |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 166 | |
| 167 | IMAGES="adapter_open_onu_go" |
| 168 | |
| 169 | for I in \$IMAGES |
| 170 | do |
| 171 | EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never " |
| 172 | done |
| 173 | |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 174 | cd $WORKSPACE/kind-voltha/ |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 175 | echo \$EXTRA_HELM_FLAGS |
| 176 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 177 | ./voltha up |
| 178 | ''' |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | stage('Run E2E Tests') { |
Andrea Campanella | 40ff56f | 2020-05-11 15:22:29 +0200 | [diff] [blame] | 183 | environment { |
| 184 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/openonu-go" |
| 185 | } |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 186 | steps { |
| 187 | sh ''' |
Andrea Campanella | 40ff56f | 2020-05-11 15:22:29 +0200 | [diff] [blame] | 188 | mkdir -p $ROBOT_LOGS_DIR |
| 189 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
Andrea Campanella | 27ddf06 | 2020-08-07 10:35:15 +0200 | [diff] [blame] | 190 | export TARGET_DEFAULT=openonu-go-adapter-test |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 191 | |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 192 | make -C $WORKSPACE/voltha-system-tests \$TARGET_DEFAULT || true |
Andrea Campanella | 27ddf06 | 2020-08-07 10:35:15 +0200 | [diff] [blame] | 193 | |
| 194 | export TARGET_1T8GEM=1t8gem-openonu-go-adapter-test |
| 195 | |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 196 | make -C $WORKSPACE/voltha-system-tests \$TARGET_1T8GEM || true |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 197 | ''' |
| 198 | } |
| 199 | } |
Andrea Campanella | 40ff56f | 2020-05-11 15:22:29 +0200 | [diff] [blame] | 200 | |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | post { |
| 204 | always { |
| 205 | sh ''' |
| 206 | set +e |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 207 | cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/ |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 208 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 209 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 210 | kubectl get nodes -o wide |
| 211 | kubectl get pods -o wide |
| 212 | kubectl get pods -n voltha -o wide |
| 213 | |
| 214 | sync |
| 215 | pkill kail || true |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 216 | md5sum $WORKSPACE/kind-voltha/bin/voltctl |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 217 | |
| 218 | ## Pull out errors from log files |
| 219 | extract_errors_go() { |
| 220 | echo |
| 221 | echo "Error summary for $1:" |
| 222 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 223 | echo |
| 224 | } |
| 225 | |
| 226 | extract_errors_python() { |
| 227 | echo |
| 228 | echo "Error summary for $1:" |
| 229 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 230 | echo |
| 231 | } |
| 232 | |
| 233 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 234 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 235 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 236 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 237 | |
| 238 | gzip $WORKSPACE/onos-voltha-combined.log |
| 239 | |
| 240 | |
| 241 | ## shut down kind-voltha |
| 242 | if [ "${branch}" != "master" ]; then |
| 243 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 244 | source "$WORKSPACE/kind-voltha/releases/${branch}" |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 245 | else |
| 246 | echo "on master, using default settings for kind-voltha" |
| 247 | fi |
| 248 | |
Andrea Campanella | 919361e | 2020-09-21 14:27:19 +0200 | [diff] [blame] | 249 | cd $WORKSPACE/kind-voltha |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 250 | WAIT_ON_DOWN=y ./voltha down |
| 251 | ''' |
Andrea Campanella | 40ff56f | 2020-05-11 15:22:29 +0200 | [diff] [blame] | 252 | step([$class: 'RobotPublisher', |
| 253 | disableArchiveOutput: false, |
| 254 | logFileName: 'RobotLogs/*/log*.html', |
| 255 | otherFiles: '', |
| 256 | outputFileName: 'RobotLogs/*/output*.xml', |
| 257 | outputPath: '.', |
| 258 | passThreshold: 100, |
| 259 | reportFileName: 'RobotLogs/*/report*.html', |
| 260 | unstableThreshold: 0]); |
Matteo Scandolo | fff6e06 | 2020-04-29 13:36:33 -0700 | [diff] [blame] | 261 | archiveArtifacts artifacts: '*.log,*.gz' |
| 262 | } |
| 263 | } |
| 264 | } |