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 | |
Matteo Scandolo | 712514a | 2021-07-20 09:49:09 -0700 | [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 | 376859a | 2020-07-08 17:04:44 -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 { |
Hardik Windlass | 6c22b20 | 2021-07-02 03:46:37 +0000 | [diff] [blame] | 32 | timeout(time: 210, unit: 'MINUTES') |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 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 | |
| 41 | stages { |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 42 | stage('Clone voltha-system-tests') { |
| 43 | steps { |
Hardik Windlass | 13d8e95 | 2021-07-20 09:16:46 +0000 | [diff] [blame] | 44 | step([$class: 'WsCleanup']) |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 45 | checkout([ |
| 46 | $class: 'GitSCM', |
| 47 | userRemoteConfigs: [[ |
| 48 | url: "https://gerrit.opencord.org/voltha-system-tests", |
Matteo Scandolo | a42c6f5 | 2020-09-19 01:35:12 +0000 | [diff] [blame] | 49 | refspec: "${volthaSystemTestsChange}" |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 50 | ]], |
Suchitra Vemuri | 1143ae3 | 2021-03-26 01:08:37 +0000 | [diff] [blame] | 51 | branches: [[ name: "${branch}", ]], |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 52 | extensions: [ |
| 53 | [$class: 'WipeWorkspace'], |
| 54 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 55 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 56 | ], |
| 57 | ]) |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 58 | script { |
| 59 | sh(script:""" |
| 60 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 61 | cd $WORKSPACE/voltha-system-tests; |
| 62 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 63 | fi |
| 64 | """) |
| 65 | } |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 66 | } |
| 67 | } |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 68 | // This checkout allows us to show changes in Jenkins |
| 69 | // we only do this on master as we don't branch all the repos for all the releases |
| 70 | // (we should compute the difference by tracking the container version, not the code) |
| 71 | stage('Download All the VOLTHA repos') { |
| 72 | when { |
| 73 | expression { |
| 74 | return "${branch}" == 'master'; |
| 75 | } |
| 76 | } |
| 77 | steps { |
| 78 | checkout(changelog: true, |
| 79 | poll: false, |
| 80 | scm: [$class: 'RepoScm', |
| 81 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 82 | manifestBranch: "${params.branch}", |
| 83 | currentBranch: true, |
| 84 | destinationDir: 'voltha', |
| 85 | forceSync: true, |
| 86 | resetFirst: true, |
| 87 | quiet: true, |
| 88 | jobs: 4, |
| 89 | showAllChanges: true] |
| 90 | ) |
| 91 | } |
| 92 | } |
| 93 | stage ('Initialize') { |
| 94 | steps { |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 95 | sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 96 | script { |
| 97 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 98 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 99 | sh returnStdout: false, script: """ |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 100 | mkdir -p $WORKSPACE/bin |
| 101 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
| 102 | cd $WORKSPACE |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 103 | if [ "${params.branch}" == "voltha-2.8" ]; then |
Hardik Windlass | e217510 | 2021-07-23 08:34:32 +0000 | [diff] [blame] | 104 | VOLTCTL_VERSION=1.6.11 |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 105 | else |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 106 | 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] | 107 | fi |
| 108 | |
| 109 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 110 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 111 | if [ \$HOSTARCH == "x86_64" ]; then |
| 112 | HOSTARCH="amd64" |
| 113 | fi |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 114 | 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] | 115 | chmod 755 $WORKSPACE/bin/voltctl |
| 116 | voltctl version --clientonly |
| 117 | |
Andrea Campanella | 9a95cb7 | 2020-09-03 11:28:35 +0200 | [diff] [blame] | 118 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 119 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 120 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 121 | # We should change this. In the meantime here is a workaround. |
| 122 | if [ "${params.branch}" == "master" ]; then |
| 123 | set +e |
| 124 | |
| 125 | |
| 126 | # Remove noise from voltha-core logs |
| 127 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 128 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 129 | # Remove noise from openolt logs |
| 130 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 131 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 132 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 133 | fi |
| 134 | """ |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | stage('Functional Tests') { |
| 139 | environment { |
| 140 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 141 | ROBOT_FILE="Voltha_TT_PODTests.robot" |
| 142 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests" |
| 143 | } |
| 144 | steps { |
| 145 | sh """ |
Hardik Windlass | af12d20 | 2021-07-27 07:52:44 +0000 | [diff] [blame] | 146 | device_teardown=True |
| 147 | if [ ${params.enableMultiUni} = true ]; then |
| 148 | device_teardown=False |
| 149 | fi |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 150 | mkdir -p $ROBOT_LOGS_DIR |
| 151 | if ( ${powerSwitch} ); then |
Hardik Windlass | af12d20 | 2021-07-27 07:52:44 +0000 | [diff] [blame] | 152 | export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -i PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:\${device_teardown} -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 153 | else |
Hardik Windlass | af12d20 | 2021-07-27 07:52:44 +0000 | [diff] [blame] | 154 | export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -e PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:\${device_teardown} -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 155 | fi |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 156 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 157 | """ |
| 158 | } |
| 159 | } |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 160 | |
| 161 | stage('Failure/Recovery Tests') { |
| 162 | environment { |
| 163 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 164 | ROBOT_FILE="Voltha_TT_FailureScenarios.robot" |
| 165 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios" |
| 166 | } |
| 167 | steps { |
| 168 | sh """ |
| 169 | mkdir -p $ROBOT_LOGS_DIR |
Hardik Windlass | 47c4dc1 | 2021-07-02 23:40:03 +0000 | [diff] [blame] | 170 | if [ ${params.enableMultiUni} = false ]; then |
Hardik Windlass | 6598b03 | 2021-07-02 10:12:01 +0000 | [diff] [blame] | 171 | if ( ${powerSwitch} ); then |
| 172 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -i 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}" |
| 173 | else |
| 174 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}" |
| 175 | fi |
| 176 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 177 | fi |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 178 | """ |
| 179 | } |
| 180 | } |
| 181 | |
Hardik Windlass | 6a233e8 | 2021-05-27 04:08:50 +0000 | [diff] [blame] | 182 | stage('Multi-Tcont Tests') { |
| 183 | environment { |
| 184 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 185 | ROBOT_FILE="Voltha_TT_MultiTcontTests.robot" |
| 186 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios" |
| 187 | ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml" |
| 188 | } |
| 189 | steps { |
| 190 | sh """ |
| 191 | mkdir -p $ROBOT_LOGS_DIR |
Hardik Windlass | 92dba5d | 2021-07-14 06:37:44 +0000 | [diff] [blame] | 192 | if [ ${params.enableMultiUni} = false ]; then |
| 193 | if ( ${powerSwitch} ); then |
| 194 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -i 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE" |
| 195 | else |
| 196 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE" |
Hardik Windlass | 6598b03 | 2021-07-02 10:12:01 +0000 | [diff] [blame] | 197 | fi |
Hardik Windlass | 92dba5d | 2021-07-14 06:37:44 +0000 | [diff] [blame] | 198 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Hardik Windlass | 6a233e8 | 2021-05-27 04:08:50 +0000 | [diff] [blame] | 199 | fi |
| 200 | """ |
| 201 | } |
| 202 | } |
| 203 | |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 204 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 205 | post { |
| 206 | always { |
Hardik Windlass | ceb5631 | 2021-07-21 16:12:25 +0000 | [diff] [blame] | 207 | getPodsInfo("$WORKSPACE/pods") |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 208 | sh returnStdout: false, script: ''' |
| 209 | set +e |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 210 | |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 211 | # collect logs collected in the Robot Framework StartLogging keyword |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 212 | cd $WORKSPACE |
| 213 | gzip *-combined.log || true |
Andrea Campanella | c9c8068 | 2020-09-30 12:02:01 +0200 | [diff] [blame] | 214 | rm *-combined.log || true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 215 | ''' |
| 216 | script { |
| 217 | deployment_config.olts.each { olt -> |
Andrea Campanella | 0d3110c | 2021-01-20 12:25:45 +0100 | [diff] [blame] | 218 | if (olt.type == null || olt.type == "" || olt.type == "openolt") { |
| 219 | sh returnStdout: false, script: """ |
| 220 | sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true |
| 221 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
| 222 | """ |
| 223 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | step([$class: 'RobotPublisher', |
| 227 | disableArchiveOutput: false, |
| 228 | logFileName: '**/log*.html', |
| 229 | otherFiles: '', |
| 230 | outputFileName: '**/output*.xml', |
| 231 | outputPath: 'RobotLogs', |
| 232 | passThreshold: 100, |
| 233 | reportFileName: '**/report*.html', |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 234 | unstableThreshold: 0, |
| 235 | onlyCritical: true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 236 | ]); |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 237 | archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt' |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 238 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 239 | } |
| 240 | } |