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 | |
| 18 | node { |
| 19 | // Need this so that deployment_config has global scope when it's read later |
| 20 | deployment_config = null |
| 21 | localDeploymentConfigFile = null |
| 22 | localKindVolthaValuesFile = null |
| 23 | localSadisConfigFile = null |
| 24 | } |
| 25 | |
| 26 | pipeline { |
| 27 | |
| 28 | /* no label, executor is determined by JJB */ |
| 29 | agent { |
| 30 | label "${params.buildNode}" |
| 31 | } |
| 32 | options { |
| 33 | timeout(time: 60, unit: 'MINUTES') |
| 34 | } |
| 35 | |
| 36 | environment { |
| 37 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 38 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 39 | PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin" |
| 40 | TYPE="minimal" |
| 41 | FANCY=0 |
| 42 | //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests |
| 43 | ONOS_SSH_PORT=30115 |
| 44 | ONOS_API_PORT=30120 |
| 45 | } |
| 46 | |
| 47 | stages { |
| 48 | stage ('Initialize') { |
| 49 | steps { |
| 50 | sh returnStdout: true, script: """ |
| 51 | test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down |
| 52 | cd $WORKSPACE |
| 53 | rm -rf $WORKSPACE/* |
| 54 | """ |
| 55 | script { |
| 56 | if (env.configRepo && ! env.localConfigDir) { |
| 57 | env.localConfigDir = "$WORKSPACE" |
| 58 | sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configRepo}" |
| 59 | } |
| 60 | localDeploymentConfigFile = "${env.localConfigDir}/${params.deploymentConfigFile}" |
| 61 | localKindVolthaValuesFile = "${env.localConfigDir}/${params.kindVolthaValuesFile}" |
| 62 | localSadisConfigFile = "${env.localConfigDir}/${params.sadisConfigFile}" |
| 63 | if ( ! params.withPatchset ) { |
| 64 | sh returnStdout: false, script: """ |
| 65 | mkdir -p voltha |
| 66 | cd voltha |
| 67 | git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests |
| 68 | """ |
| 69 | } |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | stage('Get Patch') { |
| 75 | when { |
| 76 | expression { params.withPatchset } |
| 77 | } |
| 78 | steps { |
| 79 | checkout(changelog: false, \ |
| 80 | poll: false, |
| 81 | scm: [$class: 'RepoScm', \ |
| 82 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 83 | manifestBranch: "${params.manifestBranch}", \ |
| 84 | currentBranch: true, \ |
| 85 | destinationDir: 'voltha', \ |
| 86 | forceSync: true, |
| 87 | resetFirst: true, \ |
| 88 | quiet: true, \ |
| 89 | jobs: 4, \ |
| 90 | showAllChanges: true] \ |
| 91 | ) |
| 92 | sh returnStdout: false, script: """ |
| 93 | cd voltha |
| 94 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 95 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 96 | """ |
| 97 | } |
| 98 | } |
| 99 | |
Andy Bavier | 9a37660 | 2019-11-13 11:53:37 -0700 | [diff] [blame] | 100 | stage('Check config files') { |
| 101 | steps { |
Andy Bavier | 85ab094 | 2019-11-13 14:43:25 -0700 | [diff] [blame^] | 102 | script { |
| 103 | try { |
| 104 | deployment_config = readYaml file: "${localDeploymentConfigFile}" |
| 105 | } catch (err) { |
| 106 | echo "Error reading ${localDeploymentConfigFile}" |
| 107 | throw err |
| 108 | } |
| 109 | sh returnStdout: false, script: """ |
| 110 | if [ ! -e ${localKindVolthaValuesFile} ]; then echo "${localKindVolthaValuesFile} not found"; exit 1; fi |
| 111 | if [ ! -e ${localSadisConfigFile} ]; then echo "${localSadisConfigFile} not found"; exit 1; fi |
| 112 | """ |
Andy Bavier | 9a37660 | 2019-11-13 11:53:37 -0700 | [diff] [blame] | 113 | } |
Andy Bavier | 9a37660 | 2019-11-13 11:53:37 -0700 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 117 | stage('Create KinD Cluster') { |
| 118 | steps { |
| 119 | sh returnStdout: false, script: """ |
| 120 | git clone https://github.com/ciena/kind-voltha.git |
| 121 | cd kind-voltha/ |
| 122 | JUST_K8S=y ./voltha up |
| 123 | """ |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | stage('Build and Push Images') { |
| 128 | when { |
| 129 | expression { params.withPatchset } |
| 130 | } |
| 131 | steps { |
| 132 | sh returnStdout: false, script: """ |
| 133 | if ! [[ "${gerritProject}" =~ ^(voltha-system-tests)\$ ]]; then |
| 134 | make -C $WORKSPACE/voltha/${gerritProject} DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 135 | docker images | grep citest |
| 136 | for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}") |
| 137 | do |
| 138 | echo "Pushing \$image to nodes" |
| 139 | kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2 |
| 140 | docker rmi \$image:citest \$image:latest || true |
| 141 | done |
| 142 | fi |
| 143 | """ |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | stage('Deploy Voltha') { |
| 148 | environment { |
| 149 | WITH_SIM_ADAPTERS="n" |
| 150 | WITH_RADIUS="y" |
| 151 | DEPLOY_K8S="n" |
| 152 | VOLTHA_LOG_LEVEL="debug" |
| 153 | } |
| 154 | steps { |
| 155 | script { |
| 156 | if ( params.withPatchset ) { |
| 157 | sh returnStdout: false, script: """ |
| 158 | export EXTRA_HELM_FLAGS='-f ${localKindVolthaValuesFile} ' |
| 159 | |
| 160 | IMAGES="" |
| 161 | if [ "${gerritProject}" = "voltha-go" ]; then |
| 162 | IMAGES="cli ofagent rw_core ro_core " |
| 163 | elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
| 164 | IMAGES="adapter_open_olt " |
| 165 | elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
| 166 | IMAGES="adapter_open_onu " |
| 167 | elif [ "${gerritProject}" = "voltha-api-server" ]; then |
| 168 | IMAGES="afrouter afrouterd " |
| 169 | else |
| 170 | echo "No images to push" |
| 171 | fi |
| 172 | |
| 173 | for I in \$IMAGES |
| 174 | do |
| 175 | EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never " |
| 176 | done |
| 177 | |
| 178 | cd $WORKSPACE/kind-voltha/ |
| 179 | echo \$EXTRA_HELM_FLAGS |
| 180 | ./voltha up |
| 181 | """ |
| 182 | } else { |
| 183 | sh returnStdout: false, script: """ |
| 184 | export EXTRA_HELM_FLAGS='-f ${localKindVolthaValuesFile} ' |
| 185 | cd $WORKSPACE/kind-voltha/ |
| 186 | echo \$EXTRA_HELM_FLAGS |
| 187 | ./voltha up |
| 188 | """ |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | stage('Push Tech-Profile') { |
| 195 | when { |
| 196 | expression { params.profile != "Default" } |
| 197 | } |
| 198 | steps { |
| 199 | sh returnStdout: false, script: """ |
| 200 | etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}') |
| 201 | kubectl cp $WORKSPACE/voltha/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json |
| 202 | kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/xgspon/64' |
| 203 | """ |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | stage('Push Sadis-config') { |
| 208 | steps { |
| 209 | sh returnStdout: false, script: """ |
| 210 | 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} |
| 211 | """ |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | stage('Reinstall OLT software') { |
| 216 | when { |
| 217 | expression { params.reinstallOlt } |
| 218 | } |
| 219 | steps { |
| 220 | script { |
| 221 | deployment_config.olts.each { olt -> |
| 222 | sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true" |
| 223 | sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true" |
| 224 | sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'" |
| 225 | waitUntil { |
| 226 | olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'" |
| 227 | return olt_sw_present.toInteger() == 0 |
| 228 | } |
| 229 | sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'" |
| 230 | waitUntil { |
| 231 | olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'" |
| 232 | return olt_sw_present.toInteger() == 1 |
| 233 | } |
| 234 | if ( olt.fortygig ) { |
| 235 | // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded |
| 236 | sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'echo port ce128 sp=40000 >> /broadcom/qax.soc ; /opt/bcm68620/svk_init.sh'" |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | stage('Restart OLT processes') { |
| 244 | steps { |
| 245 | script { |
| 246 | deployment_config.olts.each { olt -> |
| 247 | sh returnStdout: true, script: """ |
| 248 | ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts |
| 249 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true |
| 250 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true |
| 251 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/bal_core_dist.log /var/log/openolt.log' |
| 252 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist start &' |
| 253 | sleep 5 |
| 254 | sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt start &' |
| 255 | """ |
| 256 | waitUntil { |
| 257 | 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'" |
| 258 | return onu_discovered.toInteger() > 0 |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | stage('Run E2E Tests') { |
| 266 | environment { |
Andy Bavier | bda4c6b | 2019-11-12 17:06:22 -0700 | [diff] [blame] | 267 | ROBOT_CONFIG_FILE="${localDeploymentConfigFile}" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 268 | ROBOT_MISC_ARGS="--removekeywords wuks -d $WORKSPACE/RobotLogs" |
Andy Bavier | bda4c6b | 2019-11-12 17:06:22 -0700 | [diff] [blame] | 269 | ROBOT_FILE="Voltha_PODTests.robot" |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 270 | } |
| 271 | steps { |
| 272 | sh returnStdout: false, script: """ |
| 273 | cd voltha |
| 274 | git clone -b ${branch} ${cordRepoUrl}/cord-tester |
| 275 | git clone -b ${branch} ${cordRepoUrl}/voltha # VOL-2104 recommends we get rid of this |
| 276 | mkdir -p $WORKSPACE/RobotLogs |
Andy Bavier | bda4c6b | 2019-11-12 17:06:22 -0700 | [diff] [blame] | 277 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true |
Andy Bavier | 61c5b2a | 2019-11-12 12:08:19 -0700 | [diff] [blame] | 278 | """ |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | post { |
| 284 | always { |
| 285 | sh returnStdout: true, script: """ |
| 286 | set +e |
| 287 | cp kind-voltha/install-minimal.log $WORKSPACE/ |
| 288 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 289 | kubectl get nodes -o wide |
| 290 | kubectl get pods -o wide |
| 291 | kubectl get pods -n voltha -o wide |
| 292 | ## get default pod logs |
| 293 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 294 | do |
| 295 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 296 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 297 | else |
| 298 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 299 | fi |
| 300 | done |
| 301 | ## get voltha pod logs |
| 302 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 303 | do |
| 304 | if [[ \$pod == *"-api-"* ]]; then |
| 305 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 306 | elif [[ \$pod == "bbsim-"* ]]; then |
| 307 | kubectl logs \$pod -n voltha -p > $WORKSPACE/\$pod.log; |
| 308 | else |
| 309 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 310 | fi |
| 311 | done |
| 312 | """ |
| 313 | step([$class: 'RobotPublisher', |
| 314 | disableArchiveOutput: false, |
| 315 | logFileName: 'RobotLogs/log*.html', |
| 316 | otherFiles: '', |
| 317 | outputFileName: 'RobotLogs/output*.xml', |
| 318 | outputPath: '.', |
| 319 | passThreshold: 80, |
| 320 | reportFileName: 'RobotLogs/report*.html', |
| 321 | unstableThreshold: 0]); |
| 322 | archiveArtifacts artifacts: '*.log' |
| 323 | } |
| 324 | } |
| 325 | } |