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