Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -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: 180, unit: 'MINUTES') |
| 27 | } |
| 28 | |
| 29 | environment { |
| 30 | KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf" |
| 31 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 32 | PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 33 | } |
| 34 | |
| 35 | stages { |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 36 | stage('Clone kind-voltha') { |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 37 | steps { |
| 38 | step([$class: 'WsCleanup']) |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 39 | checkout([ |
| 40 | $class: 'GitSCM', |
| 41 | userRemoteConfigs: [[ |
| 42 | url: "https://gerrit.opencord.org/kind-voltha", |
| 43 | refspec: "${kindVolthaChange}" |
| 44 | ]], |
| 45 | branches: [[ name: "master", ]], |
| 46 | extensions: [ |
| 47 | [$class: 'WipeWorkspace'], |
| 48 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 49 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 50 | ], |
| 51 | ]) |
| 52 | } |
| 53 | } |
| 54 | stage('Clone voltha-system-tests') { |
| 55 | steps { |
| 56 | checkout([ |
| 57 | $class: 'GitSCM', |
| 58 | userRemoteConfigs: [[ |
| 59 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 60 | refspec: "${volthaSystemTestsChange}" |
| 61 | ]], |
| 62 | branches: [[ name: "${branch}", ]], |
| 63 | extensions: [ |
| 64 | [$class: 'WipeWorkspace'], |
| 65 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 66 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 67 | ], |
| 68 | ]) |
| 69 | } |
| 70 | } |
| 71 | stage('Clone cord-tester') { |
| 72 | steps { |
| 73 | checkout([ |
| 74 | $class: 'GitSCM', |
| 75 | userRemoteConfigs: [[ |
| 76 | url: "https://gerrit.opencord.org/cord-tester", |
| 77 | refspec: "${cordTesterChange}" |
| 78 | ]], |
| 79 | branches: [[ name: "master", ]], |
| 80 | extensions: [ |
| 81 | [$class: 'WipeWorkspace'], |
| 82 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"], |
| 83 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 84 | ], |
| 85 | ]) |
| 86 | } |
| 87 | } |
| 88 | // This checkout allows us to show changes in Jenkins |
| 89 | // we only do this on master as we don't branch all the repos for all the releases |
| 90 | // (we should compute the difference by tracking the container version, not the code) |
| 91 | stage('Download All the VOLTHA repos') { |
| 92 | when { |
| 93 | expression { |
| 94 | return "${branch}" == 'master'; |
| 95 | } |
| 96 | } |
| 97 | steps { |
| 98 | checkout(changelog: true, |
| 99 | poll: false, |
| 100 | scm: [$class: 'RepoScm', |
| 101 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 102 | manifestBranch: "${params.branch}", |
| 103 | currentBranch: true, |
| 104 | destinationDir: 'voltha', |
| 105 | forceSync: true, |
| 106 | resetFirst: true, |
| 107 | quiet: true, |
| 108 | jobs: 4, |
| 109 | showAllChanges: true] |
| 110 | ) |
| 111 | } |
| 112 | } |
| 113 | stage ('Initialize') { |
| 114 | steps { |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 115 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 116 | script { |
| 117 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 118 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 119 | sh returnStdout: false, script: """ |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 120 | mkdir -p $WORKSPACE/bin |
| 121 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
| 122 | cd $WORKSPACE |
| 123 | if [ "${params.branch}" != "master" ]; then |
| 124 | cd $WORKSPACE/kind-voltha |
| 125 | source releases/${params.branch} |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 126 | else |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 127 | VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 128 | fi |
| 129 | |
| 130 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 131 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 132 | if [ \$HOSTARCH == "x86_64" ]; then |
| 133 | HOSTARCH="amd64" |
| 134 | fi |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 135 | curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH} |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 136 | chmod 755 $WORKSPACE/bin/voltctl |
| 137 | voltctl version --clientonly |
| 138 | |
Andrea Campanella | 9a95cb7 | 2020-09-03 11:28:35 +0200 | [diff] [blame] | 139 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 140 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 141 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 142 | # We should change this. In the meantime here is a workaround. |
| 143 | if [ "${params.branch}" == "master" ]; then |
| 144 | set +e |
| 145 | |
| 146 | |
| 147 | # Remove noise from voltha-core logs |
| 148 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 149 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 150 | # Remove noise from openolt logs |
| 151 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 152 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 153 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 154 | fi |
| 155 | """ |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | stage('Functional Tests') { |
| 160 | environment { |
| 161 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 162 | ROBOT_FILE="Voltha_TT_PODTests.robot" |
| 163 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests" |
| 164 | } |
| 165 | steps { |
| 166 | sh """ |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 167 | cd $WORKSPACE/kind-voltha/scripts |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 168 | ./log-collector.sh > /dev/null & |
| 169 | ./log-combine.sh > /dev/null & |
| 170 | |
| 171 | mkdir -p $ROBOT_LOGS_DIR |
| 172 | if ( ${powerSwitch} ); then |
Suchitra Vemuri | 5286272 | 2020-07-17 21:28:34 -0700 | [diff] [blame] | 173 | export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 174 | else |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 175 | export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanityTT -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 176 | fi |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 177 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 178 | """ |
| 179 | } |
| 180 | } |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 181 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 182 | post { |
| 183 | always { |
| 184 | sh returnStdout: false, script: ''' |
| 185 | set +e |
| 186 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 187 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 188 | kubectl get nodes -o wide |
| 189 | kubectl get pods -n voltha -o wide |
| 190 | |
| 191 | sleep 60 # Wait for log-collector and log-combine to complete |
| 192 | |
| 193 | # Clean up "announcer" pod used by the tests if present |
| 194 | kubectl delete pod announcer || true |
| 195 | |
| 196 | ## Pull out errors from log files |
| 197 | extract_errors_go() { |
| 198 | echo |
| 199 | echo "Error summary for $1:" |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 200 | grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 201 | echo |
| 202 | } |
| 203 | |
| 204 | extract_errors_python() { |
| 205 | echo |
| 206 | echo "Error summary for $1:" |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 207 | grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 208 | echo |
| 209 | } |
| 210 | |
| 211 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 212 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 213 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 214 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 215 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 216 | |
Andrea Campanella | 9a95cb7 | 2020-09-03 11:28:35 +0200 | [diff] [blame] | 217 | gzip error-report.log || true |
| 218 | |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 219 | cd $WORKSPACE/kind-voltha/scripts/logger/combined/ |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 220 | tar czf $WORKSPACE/container-logs.tgz * |
| 221 | |
| 222 | cd $WORKSPACE |
| 223 | gzip *-combined.log || true |
| 224 | ''' |
| 225 | script { |
| 226 | deployment_config.olts.each { olt -> |
| 227 | sh returnStdout: false, script: """ |
Suchitra Vemuri | a069566 | 2020-07-17 09:41:49 -0700 | [diff] [blame] | 228 | sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true |
| 229 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 230 | """ |
| 231 | } |
| 232 | } |
| 233 | step([$class: 'RobotPublisher', |
| 234 | disableArchiveOutput: false, |
| 235 | logFileName: '**/log*.html', |
| 236 | otherFiles: '', |
| 237 | outputFileName: '**/output*.xml', |
| 238 | outputPath: 'RobotLogs', |
| 239 | passThreshold: 100, |
| 240 | reportFileName: '**/report*.html', |
| 241 | unstableThreshold: 0 |
| 242 | ]); |
| 243 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz' |
| 244 | } |
| 245 | unstable { |
| 246 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 247 | } |
| 248 | } |
| 249 | } |