Andy Bavier | 358aa0b | 2019-11-22 11:55:39 -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 | node { |
| 16 | // Need this so that deployment_config has global scope when it's read later |
| 17 | deployment_config = null |
| 18 | } |
| 19 | |
| 20 | pipeline { |
| 21 | /* no label, executor is determined by JJB */ |
| 22 | agent { |
| 23 | label "${params.buildNode}" |
| 24 | } |
| 25 | options { |
| 26 | timeout(time: 60, unit: 'MINUTES') |
| 27 | } |
| 28 | |
| 29 | environment { |
| 30 | KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf" |
| 31 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 32 | PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin" |
| 33 | } |
| 34 | |
| 35 | stages { |
| 36 | stage ('Initialize') { |
| 37 | steps { |
| 38 | step([$class: 'WsCleanup']) |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 39 | sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Andy Bavier | 358aa0b | 2019-11-22 11:55:39 -0700 | [diff] [blame] | 40 | script { |
| 41 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 42 | } |
| 43 | // This checkout is just so that we can show changes in Jenkins |
| 44 | checkout(changelog: true, |
| 45 | poll: false, |
| 46 | scm: [$class: 'RepoScm', |
| 47 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 48 | manifestBranch: "${params.manifestBranch}", |
| 49 | currentBranch: true, |
| 50 | destinationDir: 'voltha', |
| 51 | forceSync: true, |
| 52 | resetFirst: true, |
| 53 | quiet: true, |
| 54 | jobs: 4, |
| 55 | showAllChanges: true] |
| 56 | ) |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 57 | sh returnStdout: false, script: """ |
Andy Bavier | 358aa0b | 2019-11-22 11:55:39 -0700 | [diff] [blame] | 58 | cd voltha |
| 59 | git clone -b ${branch} ${cordRepoUrl}/cord-tester |
| 60 | git clone -b ${branch} ${cordRepoUrl}/voltha # NOTE do we need the voltha source code?? |
| 61 | """ |
| 62 | } |
| 63 | } |
| 64 | stage('Subscriber Validation and Ping Tests') { |
| 65 | environment { |
| 66 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
Suchitra Vemuri | bd4bcb7 | 2019-12-19 18:46:47 -0800 | [diff] [blame] | 67 | ROBOT_MISC_ARGS="--removekeywords wuks -e bbsim -e notready -d $WORKSPACE/RobotLogs -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir}" |
Andy Bavier | 358aa0b | 2019-11-22 11:55:39 -0700 | [diff] [blame] | 68 | ROBOT_FILE="Voltha_PODTests.robot" |
| 69 | } |
| 70 | steps { |
| 71 | sh """ |
| 72 | mkdir -p $WORKSPACE/RobotLogs |
| 73 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true |
| 74 | """ |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | post { |
| 80 | always { |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 81 | sh returnStdout: false, script: """ |
Andy Bavier | 358aa0b | 2019-11-22 11:55:39 -0700 | [diff] [blame] | 82 | set +e |
| 83 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 84 | kubectl get nodes -o wide |
| 85 | kubectl get pods -n voltha -o wide |
| 86 | ## get default pod logs |
| 87 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 88 | do |
| 89 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 90 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 91 | else |
| 92 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 93 | fi |
| 94 | done |
| 95 | ## get voltha pod logs |
| 96 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 97 | do |
| 98 | if [[ \$pod == *"-api-"* ]]; then |
| 99 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 100 | else |
| 101 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 102 | fi |
| 103 | done |
| 104 | """ |
| 105 | script { |
| 106 | deployment_config.olts.each { olt -> |
hwchiu | 1f0b0fe | 2019-12-06 11:45:23 -0800 | [diff] [blame] | 107 | sh returnStdout: false, script: """ |
Andy Bavier | 358aa0b | 2019-11-22 11:55:39 -0700 | [diff] [blame] | 108 | sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log || true |
| 109 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.ip}.log # Remove escape sequences |
| 110 | """ |
| 111 | } |
| 112 | } |
| 113 | step([$class: 'RobotPublisher', |
| 114 | disableArchiveOutput: false, |
| 115 | logFileName: 'RobotLogs/log*.html', |
| 116 | otherFiles: '', |
| 117 | outputFileName: 'RobotLogs/output*.xml', |
| 118 | outputPath: '.', |
| 119 | passThreshold: 100, |
| 120 | reportFileName: 'RobotLogs/report*.html', |
| 121 | unstableThreshold: 0 |
| 122 | ]); |
| 123 | archiveArtifacts artifacts: '*.log' |
| 124 | } |
| 125 | unstable { |
| 126 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 127 | } |
| 128 | } |
| 129 | } |