Scott Baker | ff88771 | 2020-04-29 13:39:41 -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 | |
| 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 |
| 25 | if ( ! params.withPatchset ) { |
| 26 | GERRIT_EVENT_COMMENT_TEXT = "" |
| 27 | GERRIT_PROJECT = "" |
| 28 | GERRIT_CHANGE_NUMBER = "" |
| 29 | GERRIT_PATCHSET_NUMBER = "" |
| 30 | } |
| 31 | |
| 32 | pipeline { |
| 33 | |
| 34 | /* no label, executor is determined by JJB */ |
| 35 | agent { |
| 36 | label "${params.buildNode}" |
| 37 | } |
| 38 | options { |
| 39 | timeout(time: 90, unit: 'MINUTES') |
| 40 | } |
| 41 | |
| 42 | environment { |
| 43 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 44 | VOLTCONFIG="$HOME/.volt/config-minimal" |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 45 | PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 46 | TYPE="minimal" |
| 47 | FANCY=0 |
| 48 | //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests |
| 49 | ONOS_SSH_PORT=30115 |
| 50 | ONOS_API_PORT=30120 |
| 51 | } |
| 52 | |
| 53 | stages { |
| 54 | stage ('Initialize') { |
| 55 | steps { |
| 56 | sh returnStdout: false, script: """ |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 57 | test -e $WORKSPACE/voltha/kind-voltha/voltha && cd $WORKSPACE/voltha/kind-voltha && ./voltha down |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 58 | cd $WORKSPACE |
| 59 | rm -rf $WORKSPACE/* |
| 60 | """ |
| 61 | script { |
| 62 | if (env.configRepo && ! env.localConfigDir) { |
| 63 | env.localConfigDir = "$WORKSPACE" |
| 64 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configRepo}" |
| 65 | } |
| 66 | localDeploymentConfigFile = "${env.localConfigDir}/${params.deploymentConfigFile}" |
| 67 | localKindVolthaValuesFile = "${env.localConfigDir}/${params.kindVolthaValuesFile}" |
| 68 | localSadisConfigFile = "${env.localConfigDir}/${params.sadisConfigFile}" |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | stage('Repo') { |
| 74 | steps { |
| 75 | checkout(changelog: true, |
| 76 | poll: false, |
| 77 | scm: [$class: 'RepoScm', |
| 78 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 79 | manifestBranch: "${params.manifestBranch}", |
| 80 | currentBranch: true, |
| 81 | destinationDir: 'voltha', |
| 82 | forceSync: true, |
| 83 | resetFirst: true, |
| 84 | quiet: true, |
| 85 | jobs: 4, |
| 86 | showAllChanges: true] |
| 87 | ) |
| 88 | } |
| 89 | } |
| 90 | |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 91 | stage('Patch') { |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 92 | steps { |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 93 | sh """ |
| 94 | pushd $WORKSPACE/ |
| 95 | echo "${gerritProject}" "${gerritChangeNumber}" "${gerritPatchsetNumber}" |
| 96 | echo "${GERRIT_REFSPEC}" |
| 97 | git clone https://gerrit.opencord.org/${gerritProject} |
| 98 | cd "${gerritProject}" |
| 99 | git fetch https://gerrit.opencord.org/${gerritProject} "${GERRIT_REFSPEC}" && git checkout FETCH_HEAD |
| 100 | popd |
| 101 | """ |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | |
| 105 | stage('Check config files') { |
| 106 | steps { |
| 107 | script { |
| 108 | try { |
| 109 | deployment_config = readYaml file: "${localDeploymentConfigFile}" |
| 110 | } catch (err) { |
| 111 | echo "Error reading ${localDeploymentConfigFile}" |
| 112 | throw err |
| 113 | } |
| 114 | sh returnStdout: false, script: """ |
| 115 | if [ ! -e ${localKindVolthaValuesFile} ]; then echo "${localKindVolthaValuesFile} not found"; exit 1; fi |
| 116 | if [ ! -e ${localSadisConfigFile} ]; then echo "${localSadisConfigFile} not found"; exit 1; fi |
| 117 | """ |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 122 | stage('Build olt addr list') { |
| 123 | steps { |
| 124 | script { |
| 125 | sh """ |
| 126 | echo "ADDR_LIST:" > /tmp/robot_vars.yaml |
| 127 | """ |
| 128 | deployment_config.olts.each { olt -> |
| 129 | sh """ |
| 130 | echo " - ${olt.ip}:8888" >> /tmp/robot_vars.yaml |
| 131 | """ |
| 132 | } |
| 133 | sh """ |
| 134 | cat /tmp/robot_vars.yaml |
| 135 | """ |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 140 | stage('Create KinD Cluster') { |
| 141 | steps { |
| 142 | sh returnStdout: false, script: """ |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 143 | cd $WORKSPACE/voltha/kind-voltha/ |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 144 | JUST_K8S=y ./voltha up |
| 145 | """ |
| 146 | } |
| 147 | } |
| 148 | |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 149 | stage('Build Redfish Importer Image') { |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 150 | steps { |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 151 | sh """ |
| 152 | make -C $WORKSPACE/device-management/\$1 DOCKER_REPOSITORY=opencord/ DOCKER_TAG=citest docker-build-importer |
| 153 | """ |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | stage('Build demo_test Image') { |
| 158 | steps { |
| 159 | sh """ |
| 160 | make -C $WORKSPACE/device-management/\$1/demo_test DOCKER_REPOSITORY=opencord/ DOCKER_TAG=citest docker-build |
| 161 | """ |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | stage('Build mock-redfish-server Image') { |
| 166 | steps { |
| 167 | sh """ |
| 168 | make -C $WORKSPACE/device-management/\$1/mock-redfish-server DOCKER_REPOSITORY=opencord/ DOCKER_TAG=citest docker-build |
| 169 | """ |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | stage('Push Images') { |
| 174 | steps { |
| 175 | sh ''' |
| 176 | docker images | grep citest |
| 177 | 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 |
| 178 | ''' |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
| 182 | stage('Deploy Voltha') { |
| 183 | environment { |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 184 | WITH_SIM_ADAPTERS="no" |
| 185 | WITH_RADIUS="yes" |
| 186 | DEPLOY_K8S="no" |
| 187 | VOLTHA_LOG_LEVEL="DEBUG" |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 188 | } |
| 189 | steps { |
| 190 | script { |
| 191 | sh returnStdout: false, script: """ |
| 192 | export EXTRA_HELM_FLAGS='--set log_agent.enabled=False -f ${localKindVolthaValuesFile} ' |
| 193 | |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 194 | cd $WORKSPACE/voltha/kind-voltha/ |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 195 | echo \$EXTRA_HELM_FLAGS |
| 196 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 197 | ./voltha up |
| 198 | """ |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | stage('Deploy Kafka Dump Chart') { |
| 204 | steps { |
| 205 | script { |
| 206 | sh returnStdout: false, script: """ |
| 207 | helm repo add cord https://charts.opencord.org |
| 208 | helm repo update |
| 209 | helm install -n voltha-kafka-dump cord/voltha-kafka-dump |
| 210 | """ |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | stage('Push Tech-Profile') { |
| 216 | when { |
| 217 | expression { params.profile != "Default" } |
| 218 | } |
| 219 | steps { |
| 220 | sh returnStdout: false, script: """ |
| 221 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
| 222 | kubectl cp $WORKSPACE/voltha/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json |
| 223 | 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' |
| 224 | """ |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | stage('Push Sadis-config') { |
| 229 | steps { |
| 230 | sh returnStdout: false, script: """ |
| 231 | 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} |
| 232 | """ |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | stage('Reinstall OLT software') { |
| 237 | when { |
| 238 | expression { params.reinstallOlt } |
| 239 | } |
| 240 | steps { |
| 241 | script { |
| 242 | deployment_config.olts.each { olt -> |
| 243 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true" |
| 244 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'killall dev_mgmt_daemon' || true" |
| 245 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'" |
| 246 | waitUntil { |
| 247 | olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'" |
| 248 | return olt_sw_present.toInteger() == 0 |
| 249 | } |
| 250 | sh returnStdout: false, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'" |
| 251 | waitUntil { |
| 252 | olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'" |
| 253 | return olt_sw_present.toInteger() == 1 |
| 254 | } |
| 255 | if ( olt.fortygig ) { |
| 256 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
| 257 | 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'" |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | stage('Restart OLT processes') { |
| 265 | steps { |
| 266 | script { |
| 267 | deployment_config.olts.each { olt -> |
| 268 | sh returnStdout: false, script: """ |
| 269 | ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts |
| 270 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true |
| 271 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'killall dev_mgmt_daemon' || true |
| 272 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/openolt.log' |
| 273 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/dev_mgmt_daemon.log' |
| 274 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service dev_mgmt_daemon start &' |
| 275 | sleep 5 |
| 276 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt start &' |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 277 | # restart redfish server |
| 278 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service psme stop' || true |
| 279 | sleep 10 |
| 280 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service psme start' |
| 281 | sleep 10 |
| 282 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'ps auxw | grep -i psme' |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 283 | """ |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 284 | // Note: ONU Discovery wait loop removed as it was not necessary |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | stage('Run E2E Tests') { |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 291 | steps { |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 292 | sh ''' |
| 293 | mkdir -p $WORKSPACE/RobotLogs |
| 294 | # tell the kubernetes script to use images tagged citest and pullPolicy:Never |
| 295 | sed -i 's/master/citest/g' $WORKSPACE/device-management/kubernetes/deploy*.yaml |
| 296 | sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/g' $WORKSPACE/device-management/kubernetes/deploy*.yaml |
| 297 | # passing a list to robot framework on the command line is hard, so put the vars in a file |
| 298 | make -C $WORKSPACE/device-management ROBOT_EXTRA_ARGS="-V /tmp/robot_vars.yaml" functional-physical-test-single || true |
| 299 | ''' |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
| 303 | stage('After-Test Delay') { |
| 304 | when { |
| 305 | expression { params.withPatchset } |
| 306 | } |
| 307 | steps { |
| 308 | sh returnStdout: false, script: """ |
| 309 | # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line |
| 310 | REGEX="hardware test with delay\$" |
| 311 | [[ "$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]] && sleep 10m || true |
| 312 | """ |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | post { |
| 318 | always { |
| 319 | sh returnStdout: false, script: ''' |
| 320 | set +e |
| 321 | cp kind-voltha/install-minimal.log $WORKSPACE/ |
| 322 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 323 | kubectl get nodes -o wide |
| 324 | kubectl get pods -o wide |
| 325 | kubectl get pods -n voltha -o wide |
| 326 | |
| 327 | sync |
| 328 | pkill kail || true |
| 329 | |
| 330 | ## Pull out errors from log files |
| 331 | extract_errors_go() { |
| 332 | echo |
| 333 | echo "Error summary for $1:" |
| 334 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 335 | echo |
| 336 | } |
| 337 | |
| 338 | extract_errors_python() { |
| 339 | echo |
| 340 | echo "Error summary for $1:" |
| 341 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 342 | echo |
| 343 | } |
| 344 | |
| 345 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 346 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 347 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 348 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 349 | |
| 350 | gzip $WORKSPACE/onos-voltha-combined.log |
| 351 | |
| 352 | ## collect events, the chart should be running by now |
| 353 | kubectl get pods | grep -i voltha-kafka-dump | grep -i running |
| 354 | if [[ $? == 0 ]]; then |
| 355 | 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 |
| 356 | fi |
| 357 | ''' |
| 358 | script { |
| 359 | deployment_config.olts.each { olt -> |
| 360 | sh returnStdout: false, script: """ |
| 361 | sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log || true |
| 362 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.ip}.log # Remove escape sequences |
| 363 | sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log || true |
| 364 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.ip}.log # Remove escape sequences |
| 365 | """ |
| 366 | } |
| 367 | } |
| 368 | step([$class: 'RobotPublisher', |
| 369 | disableArchiveOutput: false, |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 370 | logFileName: 'device-management/demo_test/functional_test/log*.html', |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 371 | otherFiles: '', |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 372 | outputFileName: 'device-management/demo_test/functional_test/output*.xml', |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 373 | outputPath: '.', |
| 374 | passThreshold: 100, |
Scott Baker | 1ace6d7 | 2020-05-01 14:54:41 -0700 | [diff] [blame] | 375 | reportFileName: 'device-management/demo_test/functional_test/report*.html', |
Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [diff] [blame] | 376 | unstableThreshold: 0]); |
| 377 | archiveArtifacts artifacts: '*.log,*.gz' |
| 378 | } |
| 379 | } |
| 380 | } |