Joey Armstrong | 16bd8e8 | 2023-01-12 15:20:06 -0500 | [diff] [blame^] | 1 | #!/usr/bin/env groovy |
| 2 | // ----------------------------------------------------------------------- |
| 3 | // Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
Joey Armstrong | 16bd8e8 | 2023-01-12 15:20:06 -0500 | [diff] [blame^] | 16 | // ----------------------------------------------------------------------- |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 17 | |
Matteo Scandolo | 712514a | 2021-07-20 09:49:09 -0700 | [diff] [blame] | 18 | library identifier: 'cord-jenkins-libraries@master', |
| 19 | retriever: modernSCM([ |
| 20 | $class: 'GitSCMSource', |
| 21 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 22 | ]) |
| 23 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 24 | node { |
| 25 | // Need this so that deployment_config has global scope when it's read later |
| 26 | deployment_config = null |
| 27 | } |
| 28 | |
Hardik Windlass | 806505d | 2021-10-27 08:15:48 +0000 | [diff] [blame] | 29 | def volthaNamespace = "voltha" |
| 30 | def infraNamespace = "infra" |
| 31 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 32 | pipeline { |
| 33 | /* no label, executor is determined by JJB */ |
| 34 | agent { |
| 35 | label "${params.buildNode}" |
| 36 | } |
| 37 | options { |
Hardik Windlass | d0f0166 | 2021-09-03 08:07:15 +0000 | [diff] [blame] | 38 | timeout(time: "${timeout}", unit: 'MINUTES') |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | environment { |
| 42 | KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf" |
| 43 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 44 | PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 45 | } |
| 46 | |
| 47 | stages { |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 48 | stage('Clone voltha-system-tests') { |
| 49 | steps { |
Hardik Windlass | 13d8e95 | 2021-07-20 09:16:46 +0000 | [diff] [blame] | 50 | step([$class: 'WsCleanup']) |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 51 | checkout([ |
| 52 | $class: 'GitSCM', |
| 53 | userRemoteConfigs: [[ |
| 54 | url: "https://gerrit.opencord.org/voltha-system-tests", |
Matteo Scandolo | a42c6f5 | 2020-09-19 01:35:12 +0000 | [diff] [blame] | 55 | refspec: "${volthaSystemTestsChange}" |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 56 | ]], |
Suchitra Vemuri | 1143ae3 | 2021-03-26 01:08:37 +0000 | [diff] [blame] | 57 | branches: [[ name: "${branch}", ]], |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 58 | extensions: [ |
| 59 | [$class: 'WipeWorkspace'], |
| 60 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 61 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 62 | ], |
| 63 | ]) |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 64 | script { |
| 65 | sh(script:""" |
| 66 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 67 | cd $WORKSPACE/voltha-system-tests; |
| 68 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 69 | fi |
| 70 | """) |
| 71 | } |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 72 | } |
| 73 | } |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 74 | // This checkout allows us to show changes in Jenkins |
| 75 | // we only do this on master as we don't branch all the repos for all the releases |
| 76 | // (we should compute the difference by tracking the container version, not the code) |
| 77 | stage('Download All the VOLTHA repos') { |
| 78 | when { |
| 79 | expression { |
| 80 | return "${branch}" == 'master'; |
| 81 | } |
| 82 | } |
| 83 | steps { |
| 84 | checkout(changelog: true, |
| 85 | poll: false, |
| 86 | scm: [$class: 'RepoScm', |
| 87 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 88 | manifestBranch: "${params.branch}", |
| 89 | currentBranch: true, |
| 90 | destinationDir: 'voltha', |
| 91 | forceSync: true, |
| 92 | resetFirst: true, |
| 93 | quiet: true, |
| 94 | jobs: 4, |
| 95 | showAllChanges: true] |
| 96 | ) |
| 97 | } |
| 98 | } |
| 99 | stage ('Initialize') { |
| 100 | steps { |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 101 | sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 102 | script { |
| 103 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 104 | } |
Hardik Windlass | 9658cd2 | 2021-10-25 11:13:25 +0000 | [diff] [blame] | 105 | installVoltctl("${branch}") |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 106 | sh returnStdout: false, script: """ |
Joey Armstrong | 16bd8e8 | 2023-01-12 15:20:06 -0500 | [diff] [blame^] | 107 | mkdir -p "$WORKSPACE/bin" |
| 108 | |
| 109 | # install kail |
| 110 | make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail |
Andrea Campanella | 9a95cb7 | 2020-09-03 11:28:35 +0200 | [diff] [blame] | 111 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 112 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 113 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 114 | # We should change this. In the meantime here is a workaround. |
| 115 | if [ "${params.branch}" == "master" ]; then |
| 116 | set +e |
| 117 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 118 | # Remove noise from voltha-core logs |
| 119 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 120 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 121 | # Remove noise from openolt logs |
| 122 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 123 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 124 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 125 | fi |
| 126 | """ |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | stage('Functional Tests') { |
| 131 | environment { |
| 132 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 133 | ROBOT_FILE="Voltha_TT_PODTests.robot" |
| 134 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests" |
| 135 | } |
| 136 | steps { |
| 137 | sh """ |
Joey Armstrong | 16bd8e8 | 2023-01-12 15:20:06 -0500 | [diff] [blame^] | 138 | mkdir -p "$ROBOT_LOGS_DIR" |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 139 | if ( ${powerSwitch} ); then |
Hardik Windlass | 44461ee | 2021-05-26 07:19:53 +0000 | [diff] [blame] | 140 | 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] | 141 | else |
Hardik Windlass | 44461ee | 2021-05-26 07:19:53 +0000 | [diff] [blame] | 142 | 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] | 143 | fi |
Hardik Windlass | 806505d | 2021-10-27 08:15:48 +0000 | [diff] [blame] | 144 | ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}" |
Suchitra Vemuri | e3bb90d | 2020-09-15 17:15:50 -0700 | [diff] [blame] | 145 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 146 | """ |
| 147 | } |
| 148 | } |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 149 | |
| 150 | stage('Failure/Recovery Tests') { |
| 151 | environment { |
| 152 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 153 | ROBOT_FILE="Voltha_TT_FailureScenarios.robot" |
| 154 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios" |
| 155 | } |
| 156 | steps { |
| 157 | sh """ |
| 158 | mkdir -p $ROBOT_LOGS_DIR |
Hardik Windlass | 47c4dc1 | 2021-07-02 23:40:03 +0000 | [diff] [blame] | 159 | if [ ${params.enableMultiUni} = false ]; then |
Hardik Windlass | 6598b03 | 2021-07-02 10:12:01 +0000 | [diff] [blame] | 160 | if ( ${powerSwitch} ); then |
| 161 | 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}" |
| 162 | else |
| 163 | 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}" |
| 164 | fi |
Hardik Windlass | 806505d | 2021-10-27 08:15:48 +0000 | [diff] [blame] | 165 | ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}" |
Hardik Windlass | 6598b03 | 2021-07-02 10:12:01 +0000 | [diff] [blame] | 166 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 167 | fi |
Hardik Windlass | 81f67dc | 2021-03-05 16:15:42 +0530 | [diff] [blame] | 168 | """ |
| 169 | } |
| 170 | } |
| 171 | |
Hardik Windlass | 6a233e8 | 2021-05-27 04:08:50 +0000 | [diff] [blame] | 172 | stage('Multi-Tcont Tests') { |
| 173 | environment { |
| 174 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 175 | ROBOT_FILE="Voltha_TT_MultiTcontTests.robot" |
| 176 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios" |
| 177 | ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml" |
| 178 | } |
| 179 | steps { |
| 180 | sh """ |
| 181 | mkdir -p $ROBOT_LOGS_DIR |
Hardik Windlass | 92dba5d | 2021-07-14 06:37:44 +0000 | [diff] [blame] | 182 | if [ ${params.enableMultiUni} = false ]; then |
| 183 | if ( ${powerSwitch} ); then |
| 184 | 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" |
| 185 | else |
| 186 | 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] | 187 | fi |
Hardik Windlass | 806505d | 2021-10-27 08:15:48 +0000 | [diff] [blame] | 188 | ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}" |
Hardik Windlass | 92dba5d | 2021-07-14 06:37:44 +0000 | [diff] [blame] | 189 | make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true |
Hardik Windlass | 6a233e8 | 2021-05-27 04:08:50 +0000 | [diff] [blame] | 190 | fi |
| 191 | """ |
| 192 | } |
| 193 | } |
| 194 | |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 195 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 196 | post { |
| 197 | always { |
Hardik Windlass | ceb5631 | 2021-07-21 16:12:25 +0000 | [diff] [blame] | 198 | getPodsInfo("$WORKSPACE/pods") |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 199 | sh returnStdout: false, script: ''' |
| 200 | set +e |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 201 | |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 202 | # collect logs collected in the Robot Framework StartLogging keyword |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 203 | cd $WORKSPACE |
| 204 | gzip *-combined.log || true |
Andrea Campanella | c9c8068 | 2020-09-30 12:02:01 +0200 | [diff] [blame] | 205 | rm *-combined.log || true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 206 | ''' |
| 207 | script { |
| 208 | deployment_config.olts.each { olt -> |
Andrea Campanella | 0d3110c | 2021-01-20 12:25:45 +0100 | [diff] [blame] | 209 | if (olt.type == null || olt.type == "" || olt.type == "openolt") { |
| 210 | sh returnStdout: false, script: """ |
| 211 | sshpass -p ${olt.pass} scp ${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 |
Girish Gowdra | 1cdfeb5 | 2021-10-28 15:12:45 -0700 | [diff] [blame] | 213 | sshpass -p ${olt.pass} scp ${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 |
Andrea Campanella | 0d3110c | 2021-01-20 12:25:45 +0100 | [diff] [blame] | 215 | """ |
| 216 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | step([$class: 'RobotPublisher', |
| 220 | disableArchiveOutput: false, |
| 221 | logFileName: '**/log*.html', |
| 222 | otherFiles: '', |
| 223 | outputFileName: '**/output*.xml', |
| 224 | outputPath: 'RobotLogs', |
| 225 | passThreshold: 100, |
| 226 | reportFileName: '**/report*.html', |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 227 | unstableThreshold: 0, |
| 228 | onlyCritical: true |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 229 | ]); |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 230 | archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt' |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 231 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 232 | } |
| 233 | } |