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 { |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 124 | sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 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 |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 132 | if [ "${params.branch}" == "voltha-2.8" ]; then |
| 133 | VC_VERSION=1.6.10 |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 134 | else |
| 135 | VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 136 | fi |
| 137 | |
| 138 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 139 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 140 | if [ \$HOSTARCH == "x86_64" ]; then |
| 141 | HOSTARCH="amd64" |
| 142 | fi |
| 143 | curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH} |
| 144 | chmod 755 $WORKSPACE/bin/voltctl |
| 145 | voltctl version --clientonly |
| 146 | |
| 147 | if [ "${params.branch}" == "master" ]; then |
| 148 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 149 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 150 | # We should change this. In the meantime here is a workaround. |
| 151 | set +e |
| 152 | |
| 153 | # Remove noise from voltha-core logs |
| 154 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 155 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 156 | # Remove noise from openolt logs |
| 157 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 158 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 159 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 160 | fi |
| 161 | """ |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | stage('Functional Tests') { |
| 166 | environment { |
| 167 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 168 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 169 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 170 | } |
| 171 | steps { |
| 172 | sh """ |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 173 | cd $WORKSPACE/kind-voltha/scripts |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 174 | ./log-collector.sh > /dev/null & |
| 175 | ./log-combine.sh > /dev/null & |
| 176 | |
| 177 | mkdir -p $ROBOT_LOGS_DIR |
| 178 | if [ "${params.testType}" == "Functional" ]; then |
| 179 | if ( ${powerSwitch} ); then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 180 | export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -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] | 181 | else |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 182 | export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -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 | fi |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 184 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 185 | fi |
| 186 | """ |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | stage('Failure/Recovery Tests') { |
| 191 | environment { |
| 192 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 193 | ROBOT_FILE="Voltha_DT_FailureScenarios.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 194 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 195 | } |
| 196 | steps { |
| 197 | sh """ |
| 198 | mkdir -p $ROBOT_LOGS_DIR |
| 199 | if [ "${params.testType}" == "Failure" ]; then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 200 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i soak -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -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] | 201 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 202 | fi |
| 203 | """ |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | stage('Dataplane Tests') { |
| 208 | environment { |
| 209 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 210 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 211 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 212 | } |
| 213 | steps { |
| 214 | sh """ |
| 215 | mkdir -p $ROBOT_LOGS_DIR |
Suchitra Vemuri | 6060303 | 2020-09-10 17:13:37 -0700 | [diff] [blame] | 216 | if [ "${params.testType}" == "Dataplane" ]; then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 217 | export ROBOT_MISC_ARGS="--removekeywords wuks -i soakDataplane -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -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] | 218 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 219 | fi |
| 220 | """ |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | } |
| 225 | post { |
| 226 | always { |
| 227 | sh returnStdout: false, script: ''' |
| 228 | set +e |
| 229 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 230 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 231 | kubectl get nodes -o wide |
| 232 | kubectl get pods -n voltha -o wide |
| 233 | |
| 234 | sleep 60 # Wait for log-collector and log-combine to complete |
| 235 | |
| 236 | # Clean up "announcer" pod used by the tests if present |
| 237 | kubectl delete pod announcer || true |
| 238 | |
| 239 | ## Pull out errors from log files |
| 240 | extract_errors_go() { |
| 241 | echo |
| 242 | echo "Error summary for $1:" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 243 | grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 244 | echo |
| 245 | } |
| 246 | |
| 247 | extract_errors_python() { |
| 248 | echo |
| 249 | echo "Error summary for $1:" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 250 | grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 251 | echo |
| 252 | } |
| 253 | |
| 254 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 255 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 256 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 257 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 258 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 259 | |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 260 | cd $WORKSPACE/kind-voltha/scripts/logger/combined/ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 261 | tar czf $WORKSPACE/container-logs.tgz * |
| 262 | |
| 263 | cd $WORKSPACE |
| 264 | gzip *-combined.log || true |
| 265 | |
| 266 | # collect ETCD cluster logs |
| 267 | mkdir -p $WORKSPACE/etcd |
Girish Gowdra | 3eb96f6 | 2020-10-15 12:48:34 -0700 | [diff] [blame] | 268 | 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] | 269 | ''' |
| 270 | script { |
| 271 | deployment_config.olts.each { olt -> |
| 272 | sh returnStdout: false, script: """ |
| 273 | 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 |
| 274 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
| 275 | 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 |
| 276 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${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/startup.log $WORKSPACE/startup-${olt.sship}.log || true |
| 278 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences |
| 279 | 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 |
| 280 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences |
| 281 | """ |
| 282 | } |
| 283 | } |
| 284 | step([$class: 'RobotPublisher', |
| 285 | disableArchiveOutput: false, |
| 286 | logFileName: '**/log*.html', |
| 287 | otherFiles: '', |
| 288 | outputFileName: '**/output*.xml', |
| 289 | outputPath: 'RobotLogs', |
| 290 | passThreshold: 100, |
| 291 | reportFileName: '**/report*.html', |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 292 | unstableThreshold: 0, |
| 293 | onlyCritical: true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 294 | ]); |
| 295 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log' |
| 296 | } |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 297 | } |
| 298 | } |