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