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 | |
Hardik Windlass | 5e7230e | 2021-07-22 04:08:42 +0000 | [diff] [blame] | 15 | library identifier: 'cord-jenkins-libraries@master', |
| 16 | retriever: modernSCM([ |
| 17 | $class: 'GitSCMSource', |
| 18 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 19 | ]) |
| 20 | |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 21 | node { |
| 22 | // Need this so that deployment_config has global scope when it's read later |
| 23 | deployment_config = null |
| 24 | } |
| 25 | |
| 26 | pipeline { |
| 27 | /* no label, executor is determined by JJB */ |
| 28 | agent { |
| 29 | label "${params.buildNode}" |
| 30 | } |
| 31 | options { |
| 32 | timeout(time: 280, unit: 'MINUTES') |
| 33 | } |
| 34 | |
| 35 | environment { |
| 36 | KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf" |
| 37 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 38 | PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 39 | } |
| 40 | |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 41 | |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 42 | stages { |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 43 | stage('Clone voltha-system-tests') { |
| 44 | steps { |
Hardik Windlass | 13d8e95 | 2021-07-20 09:16:46 +0000 | [diff] [blame] | 45 | step([$class: 'WsCleanup']) |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 46 | checkout([ |
| 47 | $class: 'GitSCM', |
| 48 | userRemoteConfigs: [[ |
| 49 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 50 | refspec: "${volthaSystemTestsChange}" |
| 51 | ]], |
| 52 | branches: [[ name: "${branch}", ]], |
| 53 | extensions: [ |
| 54 | [$class: 'WipeWorkspace'], |
| 55 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 56 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 57 | ], |
| 58 | ]) |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 59 | script { |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 60 | sh(script:""" |
| 61 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 62 | cd $WORKSPACE/voltha-system-tests; |
| 63 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 64 | fi |
| 65 | """) |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 66 | } |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 67 | } |
| 68 | } |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 69 | // This checkout allows us to show changes in Jenkins |
| 70 | // we only do this on master as we don't branch all the repos for all the releases |
| 71 | // (we should compute the difference by tracking the container version, not the code) |
| 72 | stage('Download All the VOLTHA repos') { |
| 73 | when { |
| 74 | expression { |
| 75 | return "${branch}" == 'master'; |
| 76 | } |
| 77 | } |
| 78 | steps { |
| 79 | checkout(changelog: true, |
| 80 | poll: false, |
| 81 | scm: [$class: 'RepoScm', |
| 82 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 83 | manifestBranch: "${params.branch}", |
| 84 | currentBranch: true, |
| 85 | destinationDir: 'voltha', |
| 86 | forceSync: true, |
| 87 | resetFirst: true, |
| 88 | quiet: true, |
| 89 | jobs: 4, |
| 90 | showAllChanges: true] |
| 91 | ) |
| 92 | } |
| 93 | } |
| 94 | stage ('Initialize') { |
| 95 | steps { |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 96 | sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 97 | script { |
| 98 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
| 99 | } |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 100 | sh returnStdout: false, script: """ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 101 | mkdir -p $WORKSPACE/bin |
| 102 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
| 103 | cd $WORKSPACE |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 104 | if [ "${params.branch}" == "voltha-2.8" ]; then |
Hardik Windlass | e217510 | 2021-07-23 08:34:32 +0000 | [diff] [blame] | 105 | VC_VERSION=1.6.11 |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 106 | else |
| 107 | VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 108 | fi |
| 109 | |
| 110 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 111 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 112 | if [ \$HOSTARCH == "x86_64" ]; then |
| 113 | HOSTARCH="amd64" |
| 114 | fi |
| 115 | curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH} |
| 116 | chmod 755 $WORKSPACE/bin/voltctl |
| 117 | voltctl version --clientonly |
| 118 | |
| 119 | if [ "${params.branch}" == "master" ]; then |
| 120 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 121 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 122 | # We should change this. In the meantime here is a workaround. |
| 123 | set +e |
| 124 | |
| 125 | # Remove noise from voltha-core logs |
| 126 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 127 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 128 | # Remove noise from openolt logs |
| 129 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 130 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 131 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 132 | fi |
| 133 | """ |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | stage('Functional Tests') { |
| 138 | environment { |
| 139 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 140 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 141 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 142 | } |
| 143 | steps { |
| 144 | sh """ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 145 | mkdir -p $ROBOT_LOGS_DIR |
| 146 | if [ "${params.testType}" == "Functional" ]; then |
| 147 | if ( ${powerSwitch} ); then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 148 | 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] | 149 | else |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 150 | 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] | 151 | fi |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 152 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 153 | fi |
| 154 | """ |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | stage('Failure/Recovery Tests') { |
| 159 | environment { |
| 160 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 161 | ROBOT_FILE="Voltha_DT_FailureScenarios.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 162 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 163 | } |
| 164 | steps { |
| 165 | sh """ |
| 166 | mkdir -p $ROBOT_LOGS_DIR |
| 167 | if [ "${params.testType}" == "Failure" ]; then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 168 | 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] | 169 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 170 | fi |
| 171 | """ |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | stage('Dataplane Tests') { |
| 176 | environment { |
| 177 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 178 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 179 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 180 | } |
| 181 | steps { |
| 182 | sh """ |
| 183 | mkdir -p $ROBOT_LOGS_DIR |
Suchitra Vemuri | 6060303 | 2020-09-10 17:13:37 -0700 | [diff] [blame] | 184 | if [ "${params.testType}" == "Dataplane" ]; then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 185 | 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] | 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 | } |
| 193 | post { |
| 194 | always { |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 195 | getPodsInfo("$WORKSPACE/pods") |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 196 | sh returnStdout: false, script: ''' |
| 197 | set +e |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 198 | |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 199 | # collect logs collected in the Robot Framework StartLogging keyword |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 200 | cd $WORKSPACE |
| 201 | gzip *-combined.log || true |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 202 | rm *-combined.log || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 203 | |
| 204 | # collect ETCD cluster logs |
| 205 | mkdir -p $WORKSPACE/etcd |
Girish Gowdra | 3eb96f6 | 2020-10-15 12:48:34 -0700 | [diff] [blame] | 206 | 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] | 207 | ''' |
| 208 | script { |
| 209 | deployment_config.olts.each { olt -> |
| 210 | sh returnStdout: false, script: """ |
| 211 | 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 |
| 212 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
| 213 | 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 |
| 214 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences |
| 215 | 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 |
| 216 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences |
| 217 | 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 |
| 218 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences |
| 219 | """ |
| 220 | } |
| 221 | } |
| 222 | step([$class: 'RobotPublisher', |
| 223 | disableArchiveOutput: false, |
| 224 | logFileName: '**/log*.html', |
| 225 | otherFiles: '', |
| 226 | outputFileName: '**/output*.xml', |
| 227 | outputPath: 'RobotLogs', |
| 228 | passThreshold: 100, |
| 229 | reportFileName: '**/report*.html', |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 230 | unstableThreshold: 0, |
| 231 | onlyCritical: true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 232 | ]); |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 233 | archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt' |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 234 | } |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 235 | } |
| 236 | } |