Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -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: 280, 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 | |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 35 | |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 36 | stages { |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 37 | stage('Clone kind-voltha') { |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 38 | steps { |
| 39 | step([$class: 'WsCleanup']) |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 40 | checkout([ |
| 41 | $class: 'GitSCM', |
| 42 | userRemoteConfigs: [[ |
| 43 | url: "https://gerrit.opencord.org/kind-voltha", |
| 44 | refspec: "${kindVolthaChange}" |
| 45 | ]], |
| 46 | branches: [[ name: "master", ]], |
| 47 | extensions: [ |
| 48 | [$class: 'WipeWorkspace'], |
| 49 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 50 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 51 | ], |
| 52 | ]) |
| 53 | } |
| 54 | } |
| 55 | stage('Clone voltha-system-tests') { |
| 56 | steps { |
| 57 | checkout([ |
| 58 | $class: 'GitSCM', |
| 59 | userRemoteConfigs: [[ |
| 60 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 61 | refspec: "${volthaSystemTestsChange}" |
| 62 | ]], |
| 63 | branches: [[ name: "${branch}", ]], |
| 64 | extensions: [ |
| 65 | [$class: 'WipeWorkspace'], |
| 66 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 67 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 68 | ], |
| 69 | ]) |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 70 | script { |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 71 | sh(script:""" |
| 72 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 73 | cd $WORKSPACE/voltha-system-tests; |
| 74 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 75 | fi |
| 76 | """) |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 77 | } |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | stage('Clone cord-tester') { |
| 81 | steps { |
| 82 | checkout([ |
| 83 | $class: 'GitSCM', |
| 84 | userRemoteConfigs: [[ |
| 85 | url: "https://gerrit.opencord.org/cord-tester", |
| 86 | refspec: "${cordTesterChange}" |
| 87 | ]], |
| 88 | branches: [[ name: "master", ]], |
| 89 | extensions: [ |
| 90 | [$class: 'WipeWorkspace'], |
| 91 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"], |
| 92 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 93 | ], |
| 94 | ]) |
| 95 | } |
| 96 | } |
| 97 | // This checkout allows us to show changes in Jenkins |
| 98 | // we only do this on master as we don't branch all the repos for all the releases |
| 99 | // (we should compute the difference by tracking the container version, not the code) |
| 100 | stage('Download All the VOLTHA repos') { |
| 101 | when { |
| 102 | expression { |
| 103 | return "${branch}" == 'master'; |
| 104 | } |
| 105 | } |
| 106 | steps { |
| 107 | checkout(changelog: true, |
| 108 | poll: false, |
| 109 | scm: [$class: 'RepoScm', |
| 110 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 111 | manifestBranch: "${params.branch}", |
| 112 | currentBranch: true, |
| 113 | destinationDir: 'voltha', |
| 114 | forceSync: true, |
| 115 | resetFirst: true, |
| 116 | quiet: true, |
| 117 | jobs: 4, |
| 118 | showAllChanges: true] |
| 119 | ) |
| 120 | } |
| 121 | } |
| 122 | stage ('Initialize') { |
| 123 | steps { |
| 124 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}" |
| 125 | script { |
| 126 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
| 127 | } |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 128 | sh returnStdout: false, script: """ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 129 | mkdir -p $WORKSPACE/bin |
| 130 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
| 131 | cd $WORKSPACE |
| 132 | if [ "${params.branch}" != "master" ]; then |
| 133 | cd $WORKSPACE/kind-voltha |
| 134 | source releases/${params.branch} |
| 135 | VC_VERSION=1.1.8 |
| 136 | else |
| 137 | VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 138 | fi |
| 139 | |
| 140 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 141 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 142 | if [ \$HOSTARCH == "x86_64" ]; then |
| 143 | HOSTARCH="amd64" |
| 144 | fi |
| 145 | curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH} |
| 146 | chmod 755 $WORKSPACE/bin/voltctl |
| 147 | voltctl version --clientonly |
| 148 | |
| 149 | if [ "${params.branch}" == "master" ]; then |
| 150 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 151 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 152 | # We should change this. In the meantime here is a workaround. |
| 153 | set +e |
| 154 | |
| 155 | # Remove noise from voltha-core logs |
| 156 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 157 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 158 | # Remove noise from openolt logs |
| 159 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 160 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 161 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 162 | fi |
| 163 | """ |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | stage('Functional Tests') { |
| 168 | environment { |
| 169 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 170 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 171 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 172 | } |
| 173 | steps { |
| 174 | sh """ |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 175 | cd $WORKSPACE/kind-voltha/scripts |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 176 | ./log-collector.sh > /dev/null & |
| 177 | ./log-combine.sh > /dev/null & |
| 178 | |
| 179 | mkdir -p $ROBOT_LOGS_DIR |
| 180 | if [ "${params.testType}" == "Functional" ]; then |
| 181 | if ( ${powerSwitch} ); then |
Suchitra Vemuri | c495d7f | 2021-02-25 14:28:31 -0800 | [diff] [blame] | 182 | export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 183 | else |
Suchitra Vemuri | c495d7f | 2021-02-25 14:28:31 -0800 | [diff] [blame] | 184 | export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 185 | fi |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 186 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 187 | fi |
| 188 | """ |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | stage('Failure/Recovery Tests') { |
| 193 | environment { |
| 194 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 195 | ROBOT_FILE="Voltha_DT_FailureScenarios.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 196 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 197 | } |
| 198 | steps { |
| 199 | sh """ |
| 200 | mkdir -p $ROBOT_LOGS_DIR |
| 201 | if [ "${params.testType}" == "Failure" ]; then |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 202 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i soak -e PowerSwitch -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 | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 203 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 204 | fi |
| 205 | """ |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | stage('Dataplane Tests') { |
| 210 | environment { |
| 211 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 212 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 213 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 214 | } |
| 215 | steps { |
| 216 | sh """ |
| 217 | mkdir -p $ROBOT_LOGS_DIR |
Suchitra Vemuri | 6060303 | 2020-09-10 17:13:37 -0700 | [diff] [blame] | 218 | if [ "${params.testType}" == "Dataplane" ]; then |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 219 | export ROBOT_MISC_ARGS="--removekeywords wuks -i BandwidthProfileUDPDt -i TechProfileDt -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 | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 220 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 221 | fi |
| 222 | """ |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | } |
| 227 | post { |
| 228 | always { |
| 229 | sh returnStdout: false, script: ''' |
| 230 | set +e |
| 231 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 232 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 233 | kubectl get nodes -o wide |
| 234 | kubectl get pods -n voltha -o wide |
| 235 | |
| 236 | sleep 60 # Wait for log-collector and log-combine to complete |
| 237 | |
| 238 | # Clean up "announcer" pod used by the tests if present |
| 239 | kubectl delete pod announcer || true |
| 240 | |
| 241 | ## Pull out errors from log files |
| 242 | extract_errors_go() { |
| 243 | echo |
| 244 | echo "Error summary for $1:" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 245 | grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 246 | echo |
| 247 | } |
| 248 | |
| 249 | extract_errors_python() { |
| 250 | echo |
| 251 | echo "Error summary for $1:" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 252 | grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 253 | echo |
| 254 | } |
| 255 | |
| 256 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 257 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 258 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 259 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 260 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 261 | |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 262 | cd $WORKSPACE/kind-voltha/scripts/logger/combined/ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 263 | tar czf $WORKSPACE/container-logs.tgz * |
| 264 | |
| 265 | cd $WORKSPACE |
| 266 | gzip *-combined.log || true |
| 267 | |
| 268 | # collect ETCD cluster logs |
| 269 | mkdir -p $WORKSPACE/etcd |
Girish Gowdra | 3eb96f6 | 2020-10-15 12:48:34 -0700 | [diff] [blame] | 270 | printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I% bash -c "kubectl logs % > $WORKSPACE/etcd/%.log" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 271 | ''' |
| 272 | script { |
| 273 | deployment_config.olts.each { olt -> |
| 274 | sh returnStdout: false, script: """ |
| 275 | sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true |
| 276 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
| 277 | sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true |
| 278 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences |
| 279 | sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/startup.log $WORKSPACE/startup-${olt.sship}.log || true |
| 280 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences |
| 281 | sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt_process_watchdog.log $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true |
| 282 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences |
| 283 | """ |
| 284 | } |
| 285 | } |
| 286 | step([$class: 'RobotPublisher', |
| 287 | disableArchiveOutput: false, |
| 288 | logFileName: '**/log*.html', |
| 289 | otherFiles: '', |
| 290 | outputFileName: '**/output*.xml', |
| 291 | outputPath: 'RobotLogs', |
| 292 | passThreshold: 100, |
| 293 | reportFileName: '**/report*.html', |
| 294 | unstableThreshold: 0 |
| 295 | ]); |
| 296 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log' |
| 297 | } |
| 298 | unstable { |
| 299 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 300 | } |
| 301 | } |
| 302 | } |