Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 1 | // Copyright 2019-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 | // deploy VOLTHA built from patchset on a physical pod and run e2e test |
| 16 | // uses kind-voltha to deploy voltha-2.X |
| 17 | |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 18 | // Need this so that deployment_config has global scope when it's read later |
| 19 | deployment_config = null |
| 20 | localDeploymentConfigFile = null |
| 21 | localKindVolthaValuesFile = null |
| 22 | localSadisConfigFile = null |
| 23 | |
| 24 | // The pipeline assumes these variables are always defined |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 25 | if ( params.manualBranch != "" ) { |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 26 | GERRIT_EVENT_COMMENT_TEXT = "" |
| 27 | GERRIT_PROJECT = "" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 28 | GERRIT_BRANCH = "${params.manualBranch}" |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 29 | GERRIT_CHANGE_NUMBER = "" |
| 30 | GERRIT_PATCHSET_NUMBER = "" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | pipeline { |
| 34 | |
| 35 | /* no label, executor is determined by JJB */ |
| 36 | agent { |
| 37 | label "${params.buildNode}" |
| 38 | } |
| 39 | options { |
Andy Bavier | 880d886 | 2020-06-28 12:03:35 -0700 | [diff] [blame] | 40 | timeout(time: 120, unit: 'MINUTES') |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | environment { |
| 44 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 45 | VOLTCONFIG="$HOME/.volt/config-minimal" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 46 | PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 47 | TYPE="minimal" |
| 48 | FANCY=0 |
| 49 | //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests |
| 50 | ONOS_SSH_PORT=30115 |
| 51 | ONOS_API_PORT=30120 |
| 52 | } |
| 53 | |
| 54 | stages { |
| 55 | stage ('Initialize') { |
| 56 | steps { |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 57 | sh returnStdout: false, script: """ |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 58 | test -e $WORKSPACE/voltha/kind-voltha/voltha && cd $WORKSPACE/voltha/kind-voltha && ./voltha down |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 59 | cd $WORKSPACE |
| 60 | rm -rf $WORKSPACE/* |
| 61 | """ |
| 62 | script { |
| 63 | if (env.configRepo && ! env.localConfigDir) { |
| 64 | env.localConfigDir = "$WORKSPACE" |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 65 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configRepo}" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 66 | } |
| 67 | localDeploymentConfigFile = "${env.localConfigDir}/${params.deploymentConfigFile}" |
| 68 | localKindVolthaValuesFile = "${env.localConfigDir}/${params.kindVolthaValuesFile}" |
| 69 | localSadisConfigFile = "${env.localConfigDir}/${params.sadisConfigFile}" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
Andy Bavier | 06d816c | 2019-11-19 11:40:48 -0700 | [diff] [blame] | 74 | stage('Repo') { |
| 75 | steps { |
| 76 | checkout(changelog: true, |
| 77 | poll: false, |
| 78 | scm: [$class: 'RepoScm', |
| 79 | manifestRepositoryUrl: "${params.manifestUrl}", |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 80 | manifestBranch: "${params.branch}", |
Andy Bavier | 06d816c | 2019-11-19 11:40:48 -0700 | [diff] [blame] | 81 | currentBranch: true, |
| 82 | destinationDir: 'voltha', |
| 83 | forceSync: true, |
| 84 | resetFirst: true, |
| 85 | quiet: true, |
| 86 | jobs: 4, |
| 87 | showAllChanges: true] |
| 88 | ) |
| 89 | } |
| 90 | } |
| 91 | |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 92 | stage('Get Patch') { |
| 93 | when { |
Andy Bavier | fc3ca14 | 2020-03-27 13:44:25 -0700 | [diff] [blame] | 94 | expression { params.manualBranch == "" } |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 95 | } |
| 96 | steps { |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 97 | sh returnStdout: false, script: """ |
| 98 | cd voltha |
Andy Bavier | 5b52353 | 2020-02-24 15:31:25 -0700 | [diff] [blame] | 99 | repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 100 | """ |
| 101 | } |
| 102 | } |
| 103 | |
Andy Bavier | 9a37660 | 2019-11-13 11:53:37 -0700 | [diff] [blame] | 104 | stage('Check config files') { |
| 105 | steps { |
Andy Bavier | 85ab094 | 2019-11-13 14:43:25 -0700 | [diff] [blame] | 106 | script { |
| 107 | try { |
| 108 | deployment_config = readYaml file: "${localDeploymentConfigFile}" |
| 109 | } catch (err) { |
| 110 | echo "Error reading ${localDeploymentConfigFile}" |
| 111 | throw err |
| 112 | } |
| 113 | sh returnStdout: false, script: """ |
| 114 | if [ ! -e ${localKindVolthaValuesFile} ]; then echo "${localKindVolthaValuesFile} not found"; exit 1; fi |
| 115 | if [ ! -e ${localSadisConfigFile} ]; then echo "${localSadisConfigFile} not found"; exit 1; fi |
| 116 | """ |
Andy Bavier | 9a37660 | 2019-11-13 11:53:37 -0700 | [diff] [blame] | 117 | } |
Andy Bavier | 9a37660 | 2019-11-13 11:53:37 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 121 | stage('Create KinD Cluster') { |
| 122 | steps { |
| 123 | sh returnStdout: false, script: """ |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 124 | if [ "${branch}" != "master" ]; then |
| 125 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 126 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 127 | else |
| 128 | echo "on master, using default settings for kind-voltha" |
| 129 | fi |
| 130 | |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 131 | cd $WORKSPACE/voltha/kind-voltha/ |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 132 | JUST_K8S=y ./voltha up |
| 133 | """ |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | stage('Build and Push Images') { |
| 138 | when { |
Andy Bavier | fc3ca14 | 2020-03-27 13:44:25 -0700 | [diff] [blame] | 139 | expression { params.manualBranch == "" } |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 140 | } |
| 141 | steps { |
| 142 | sh returnStdout: false, script: """ |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 143 | |
| 144 | if [ "${branch}" != "master" ]; then |
| 145 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 146 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 147 | else |
| 148 | echo "on master, using default settings for kind-voltha" |
| 149 | fi |
| 150 | |
Andy Bavier | c1cb94b | 2020-06-04 16:39:32 -0700 | [diff] [blame] | 151 | if ! [[ "${gerritProject}" =~ ^(voltha-system-tests|kind-voltha|voltha-helm-charts)\$ ]]; then |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 152 | make -C $WORKSPACE/voltha/${gerritProject} DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 153 | docker images | grep citest |
| 154 | for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}") |
| 155 | do |
| 156 | echo "Pushing \$image to nodes" |
| 157 | kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2 |
| 158 | docker rmi \$image:citest \$image:latest || true |
| 159 | done |
| 160 | fi |
| 161 | """ |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | stage('Deploy Voltha') { |
| 166 | environment { |
Andy Bavier | 1f530f5 | 2020-04-14 15:57:33 -0700 | [diff] [blame] | 167 | WITH_SIM_ADAPTERS="no" |
| 168 | WITH_RADIUS="yes" |
| 169 | DEPLOY_K8S="no" |
| 170 | VOLTHA_LOG_LEVEL="DEBUG" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 171 | } |
| 172 | steps { |
| 173 | script { |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 174 | sh returnStdout: false, script: """ |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 175 | if [ "${branch}" != "master" ]; then |
| 176 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 177 | source "$WORKSPACE/voltha/kind-voltha/releases/${branch}" |
Zack Williams | 03ebb27 | 2020-03-27 09:42:33 -0700 | [diff] [blame] | 178 | else |
| 179 | echo "on master, using default settings for kind-voltha" |
| 180 | fi |
| 181 | |
| 182 | export EXTRA_HELM_FLAGS+='--set log_agent.enabled=False -f ${localKindVolthaValuesFile} ' |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 183 | |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 184 | IMAGES="" |
| 185 | if [ "${gerritProject}" = "voltha-go" ]; then |
| 186 | IMAGES="rw_core ro_core " |
| 187 | elif [ "${gerritProject}" = "ofagent-py" ]; then |
| 188 | IMAGES="ofagent " |
| 189 | elif [ "${gerritProject}" = "voltha-onos" ]; then |
| 190 | IMAGES="onos " |
| 191 | elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
| 192 | IMAGES="adapter_open_olt " |
| 193 | elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
| 194 | IMAGES="adapter_open_onu " |
| 195 | elif [ "${gerritProject}" = "voltha-api-server" ]; then |
| 196 | IMAGES="afrouter afrouterd " |
| 197 | else |
| 198 | echo "No images to push" |
| 199 | fi |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 200 | |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 201 | for I in \$IMAGES |
| 202 | do |
| 203 | EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never " |
| 204 | done |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 205 | |
Andy Bavier | c1cb94b | 2020-06-04 16:39:32 -0700 | [diff] [blame] | 206 | if [ "${gerritProject}" = "voltha-helm-charts" ]; then |
| 207 | export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts |
| 208 | export VOLTHA_CHART=\$CHART_PATH/voltha |
| 209 | export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt |
| 210 | export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu |
| 211 | helm dep update \$VOLTHA_CHART |
| 212 | helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART |
| 213 | helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART |
| 214 | fi |
| 215 | |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 216 | cd $WORKSPACE/voltha/kind-voltha/ |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 217 | echo \$EXTRA_HELM_FLAGS |
| 218 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 219 | ./voltha up |
Andy Bavier | 1f530f5 | 2020-04-14 15:57:33 -0700 | [diff] [blame] | 220 | |
Andy Bavier | cf7a581 | 2020-04-24 15:06:30 -0700 | [diff] [blame] | 221 | set +e |
| 222 | |
Andy Bavier | 1f530f5 | 2020-04-14 15:57:33 -0700 | [diff] [blame] | 223 | # Remove noise from voltha-core logs |
Andy Bavier | cf7a581 | 2020-04-24 15:06:30 -0700 | [diff] [blame] | 224 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 225 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
Andy Bavier | 1f530f5 | 2020-04-14 15:57:33 -0700 | [diff] [blame] | 226 | # Remove noise from openolt logs |
Andy Bavier | cf7a581 | 2020-04-24 15:06:30 -0700 | [diff] [blame] | 227 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 228 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 229 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 230 | """ |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
Scott Baker | fb0284c | 2019-12-12 17:22:38 -0800 | [diff] [blame] | 235 | stage('Deploy Kafka Dump Chart') { |
| 236 | steps { |
| 237 | script { |
| 238 | sh returnStdout: false, script: """ |
| 239 | helm repo add cord https://charts.opencord.org |
| 240 | helm repo update |
Andy Bavier | b0f4e00 | 2020-07-23 09:37:23 -0700 | [diff] [blame] | 241 | if helm version -c --short|grep v2 -q; then |
| 242 | helm install -n voltha-kafka-dump cord/voltha-kafka-dump |
| 243 | else |
| 244 | helm install voltha-kafka-dump cord/voltha-kafka-dump |
| 245 | fi |
Scott Baker | fb0284c | 2019-12-12 17:22:38 -0800 | [diff] [blame] | 246 | """ |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 251 | stage('Push Tech-Profile') { |
| 252 | when { |
| 253 | expression { params.profile != "Default" } |
| 254 | } |
| 255 | steps { |
| 256 | sh returnStdout: false, script: """ |
| 257 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
| 258 | kubectl cp $WORKSPACE/voltha/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json |
Andy Bavier | 6ebf318 | 2019-11-21 13:47:21 -0700 | [diff] [blame] | 259 | kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64' |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 260 | """ |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | stage('Push Sadis-config') { |
| 265 | steps { |
| 266 | sh returnStdout: false, script: """ |
Suchitra Vemuri | 63b7174 | 2020-08-11 16:54:57 -0700 | [diff] [blame] | 267 | ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115 |
| 268 | ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts |
| 269 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay" |
| 270 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa" |
| 271 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt" |
| 272 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.onosproject.net.flowobjective.impl.FlowObjectiveManager" |
| 273 | sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 274 | curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:$ONOS_API_PORT/onos/v1/network/configuration --data @${localSadisConfigFile} |
| 275 | """ |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | stage('Reinstall OLT software') { |
| 280 | when { |
| 281 | expression { params.reinstallOlt } |
| 282 | } |
| 283 | steps { |
| 284 | script { |
| 285 | deployment_config.olts.each { olt -> |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 286 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 287 | waitUntil { |
| 288 | olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'" |
| 289 | return olt_sw_present.toInteger() == 0 |
| 290 | } |
Andy Bavier | 893d244 | 2020-05-21 12:41:17 -0700 | [diff] [blame] | 291 | if ( params.branch == 'voltha-2.3' ) { |
| 292 | oltDebVersion = oltDebVersionVoltha23 |
| 293 | } else { |
| 294 | oltDebVersion = oltDebVersionMaster |
| 295 | } |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 296 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 297 | waitUntil { |
| 298 | olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'" |
| 299 | return olt_sw_present.toInteger() == 1 |
| 300 | } |
| 301 | if ( olt.fortygig ) { |
| 302 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 303 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'echo port ce128 sp=40000 >> /broadcom/qax.soc ; /opt/bcm68620/svk_init.sh'" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 304 | } |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | stage('Restart OLT processes') { |
| 311 | steps { |
| 312 | script { |
| 313 | deployment_config.olts.each { olt -> |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 314 | sh returnStdout: false, script: """ |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 315 | ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts |
Andy Bavier | 5bb88bc | 2020-06-18 14:51:21 -0700 | [diff] [blame] | 316 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; reboot' |
| 317 | sleep 120 |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 318 | """ |
| 319 | waitUntil { |
| 320 | onu_discovered = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'grep \"onu discover indication\" /var/log/openolt.log | wc -l'" |
| 321 | return onu_discovered.toInteger() > 0 |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | stage('Run E2E Tests') { |
| 329 | environment { |
Andy Bavier | bda4c6b | 2019-11-12 17:06:22 -0700 | [diff] [blame] | 330 | ROBOT_CONFIG_FILE="${localDeploymentConfigFile}" |
Andy Bavier | d3be2bf | 2020-02-07 17:02:21 -0700 | [diff] [blame] | 331 | ROBOT_MISC_ARGS="${params.extraRobotArgs} --removekeywords wuks -d $WORKSPACE/RobotLogs -v container_log_dir:$WORKSPACE " |
Andy Bavier | bda4c6b | 2019-11-12 17:06:22 -0700 | [diff] [blame] | 332 | ROBOT_FILE="Voltha_PODTests.robot" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 333 | } |
| 334 | steps { |
| 335 | sh returnStdout: false, script: """ |
| 336 | cd voltha |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 337 | mkdir -p $WORKSPACE/RobotLogs |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 338 | |
| 339 | # If the Gerrit comment contains a line with "functional tests" then run the full |
| 340 | # functional test suite. This covers tests tagged either 'sanity' or 'functional'. |
| 341 | # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line |
| 342 | REGEX="functional tests" |
| 343 | if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then |
| 344 | ROBOT_MISC_ARGS+="-i functional" |
| 345 | fi |
Andy Bavier | c8ee432 | 2020-08-18 16:37:38 -0700 | [diff] [blame] | 346 | # Likewise for dataplane tests |
| 347 | REGEX="dataplane tests" |
| 348 | if [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then |
| 349 | ROBOT_MISC_ARGS+="-i dataplane" |
| 350 | fi |
Andy Bavier | e06dcff | 2020-02-06 11:36:40 -0700 | [diff] [blame] | 351 | |
Andy Bavier | bda4c6b | 2019-11-12 17:06:22 -0700 | [diff] [blame] | 352 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 353 | """ |
| 354 | } |
| 355 | } |
Scott Baker | da31d7b | 2020-01-08 16:35:52 -0800 | [diff] [blame] | 356 | |
| 357 | stage('After-Test Delay') { |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 358 | when { |
Andy Bavier | fc3ca14 | 2020-03-27 13:44:25 -0700 | [diff] [blame] | 359 | expression { params.manualBranch == "" } |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 360 | } |
Scott Baker | da31d7b | 2020-01-08 16:35:52 -0800 | [diff] [blame] | 361 | steps { |
| 362 | sh returnStdout: false, script: """ |
| 363 | # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line |
| 364 | REGEX="hardware test with delay\$" |
| 365 | [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]] && sleep 10m || true |
| 366 | """ |
| 367 | } |
| 368 | } |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | post { |
| 372 | always { |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 373 | sh returnStdout: false, script: ''' |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 374 | set +e |
Andy Bavier | b5c8caf | 2020-04-06 14:12:07 -0700 | [diff] [blame] | 375 | cp $WORKSPACE/voltha/kind-voltha/install-minimal.log $WORKSPACE/ |
Matteo Scandolo | 97b1257 | 2020-04-13 12:44:46 -0700 | [diff] [blame] | 376 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 377 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 378 | kubectl get nodes -o wide |
| 379 | kubectl get pods -o wide |
| 380 | kubectl get pods -n voltha -o wide |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 381 | |
| 382 | sync |
| 383 | pkill kail || true |
| 384 | |
| 385 | ## Pull out errors from log files |
| 386 | extract_errors_go() { |
| 387 | echo |
| 388 | echo "Error summary for $1:" |
| 389 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 390 | echo |
| 391 | } |
| 392 | |
| 393 | extract_errors_python() { |
| 394 | echo |
| 395 | echo "Error summary for $1:" |
| 396 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 397 | echo |
| 398 | } |
| 399 | |
| 400 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 401 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 402 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 403 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 404 | |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 405 | gzip $WORKSPACE/onos-voltha-combined.log |
| 406 | |
Scott Baker | fb0284c | 2019-12-12 17:22:38 -0800 | [diff] [blame] | 407 | ## collect events, the chart should be running by now |
| 408 | kubectl get pods | grep -i voltha-kafka-dump | grep -i running |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 409 | if [[ $? == 0 ]]; then |
Scott Baker | fb0284c | 2019-12-12 17:22:38 -0800 | [diff] [blame] | 410 | kubectl exec -it `kubectl get pods | grep -i voltha-kafka-dump | grep -i running | cut -f1 -d " "` ./voltha-dump-events.sh > $WORKSPACE/voltha-events.log |
| 411 | fi |
Andy Bavier | 4af0272 | 2020-01-15 10:24:24 -0700 | [diff] [blame] | 412 | ''' |
Andy Bavier | 6ebf318 | 2019-11-21 13:47:21 -0700 | [diff] [blame] | 413 | script { |
| 414 | deployment_config.olts.each { olt -> |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 415 | sh returnStdout: false, script: """ |
Andy Bavier | 827560b | 2020-06-05 09:49:32 -0700 | [diff] [blame] | 416 | until sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log |
| 417 | do |
| 418 | echo "Fetching openolt.log log failed, retrying..." |
| 419 | sleep 10 |
| 420 | done |
Andy Bavier | 6ebf318 | 2019-11-21 13:47:21 -0700 | [diff] [blame] | 421 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.ip}.log # Remove escape sequences |
Andy Bavier | 827560b | 2020-06-05 09:49:32 -0700 | [diff] [blame] | 422 | until sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log |
| 423 | do |
| 424 | echo "Fetching dev_mgmt_daemon.log failed, retrying..." |
| 425 | sleep 10 |
| 426 | done |
Andy Bavier | becaa8e | 2020-01-08 11:49:57 -0700 | [diff] [blame] | 427 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log # Remove escape sequences |
Andy Bavier | 6ebf318 | 2019-11-21 13:47:21 -0700 | [diff] [blame] | 428 | """ |
| 429 | } |
| 430 | } |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 431 | step([$class: 'RobotPublisher', |
| 432 | disableArchiveOutput: false, |
| 433 | logFileName: 'RobotLogs/log*.html', |
| 434 | otherFiles: '', |
| 435 | outputFileName: 'RobotLogs/output*.xml', |
| 436 | outputPath: '.', |
Andy Bavier | e19b67b | 2020-02-14 11:29:50 -0700 | [diff] [blame] | 437 | passThreshold: 100, |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 438 | reportFileName: 'RobotLogs/report*.html', |
| 439 | unstableThreshold: 0]); |
Andy Bavier | 2178d10 | 2020-02-06 16:22:11 -0700 | [diff] [blame] | 440 | archiveArtifacts artifacts: '*.log,*.gz' |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | } |