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 | |
Hardik Windlass | 5cfb29a | 2021-08-10 09:39:29 +0000 | [diff] [blame] | 26 | def volthaNamespace = "voltha" |
Hardik Windlass | 7e4e315 | 2021-09-29 06:42:05 +0000 | [diff] [blame] | 27 | def infraNamespace = "infra" |
Hardik Windlass | 5cfb29a | 2021-08-10 09:39:29 +0000 | [diff] [blame] | 28 | |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -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 | f446165 | 2020-09-03 21:47:19 -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 | |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 44 | |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 45 | stages { |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 46 | stage('Clone voltha-system-tests') { |
| 47 | steps { |
Hardik Windlass | 13d8e95 | 2021-07-20 09:16:46 +0000 | [diff] [blame] | 48 | step([$class: 'WsCleanup']) |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 49 | checkout([ |
| 50 | $class: 'GitSCM', |
| 51 | userRemoteConfigs: [[ |
| 52 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 53 | refspec: "${volthaSystemTestsChange}" |
| 54 | ]], |
| 55 | branches: [[ name: "${branch}", ]], |
| 56 | extensions: [ |
| 57 | [$class: 'WipeWorkspace'], |
| 58 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 59 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 60 | ], |
| 61 | ]) |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 62 | script { |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 63 | sh(script:""" |
| 64 | if [ '${volthaSystemTestsChange}' != '' ] ; then |
| 65 | cd $WORKSPACE/voltha-system-tests; |
| 66 | git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD |
| 67 | fi |
| 68 | """) |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 69 | } |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 70 | } |
| 71 | } |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 72 | // This checkout allows us to show changes in Jenkins |
| 73 | // we only do this on master as we don't branch all the repos for all the releases |
| 74 | // (we should compute the difference by tracking the container version, not the code) |
| 75 | stage('Download All the VOLTHA repos') { |
| 76 | when { |
| 77 | expression { |
| 78 | return "${branch}" == 'master'; |
| 79 | } |
| 80 | } |
| 81 | steps { |
| 82 | checkout(changelog: true, |
| 83 | poll: false, |
| 84 | scm: [$class: 'RepoScm', |
| 85 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 86 | manifestBranch: "${params.branch}", |
| 87 | currentBranch: true, |
| 88 | destinationDir: 'voltha', |
| 89 | forceSync: true, |
| 90 | resetFirst: true, |
| 91 | quiet: true, |
| 92 | jobs: 4, |
| 93 | showAllChanges: true] |
| 94 | ) |
| 95 | } |
| 96 | } |
| 97 | stage ('Initialize') { |
| 98 | steps { |
Hardik Windlass | 6f854a1 | 2021-07-12 13:20:21 +0000 | [diff] [blame] | 99 | sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Suchitra Vemuri | ef0a6e9 | 2021-02-23 21:14:07 -0800 | [diff] [blame] | 100 | script { |
| 101 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
| 102 | } |
Hardik Windlass | 9658cd2 | 2021-10-25 11:13:25 +0000 | [diff] [blame] | 103 | installVoltctl("${branch}") |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 104 | sh returnStdout: false, script: """ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 105 | mkdir -p $WORKSPACE/bin |
Hardik Windlass | 9658cd2 | 2021-10-25 11:13:25 +0000 | [diff] [blame] | 106 | # download kail |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 107 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 108 | |
| 109 | if [ "${params.branch}" == "master" ]; then |
| 110 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 111 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 112 | # We should change this. In the meantime here is a workaround. |
| 113 | set +e |
| 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 | """ |
Girish Gowdra | 15f62dd | 2022-02-07 16:38:18 -0800 | [diff] [blame^] | 124 | sh """ |
| 125 | mkdir -p $WORKSPACE/voltha-pods-mem-consumption |
| 126 | cd $WORKSPACE/voltha-system-tests |
| 127 | make vst_venv |
| 128 | source ./vst_venv/bin/activate || true |
| 129 | # Collect initial memory consumption |
| 130 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption -a 0.0.0.0:31301 -n ${volthaNamespace} || true |
| 131 | """ |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
| 135 | stage('Functional Tests') { |
| 136 | environment { |
| 137 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 138 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 139 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 140 | } |
| 141 | steps { |
| 142 | sh """ |
Hardik Windlass | 5cfb29a | 2021-08-10 09:39:29 +0000 | [diff] [blame] | 143 | JENKINS_NODE_COOKIE="dontKillMe" _TAG="prometheus" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n cattle-prometheus svc/access-prometheus 31301:80; done"& |
| 144 | ps aux | grep port-forward |
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 |
Hardik Windlass | 7e4e315 | 2021-09-29 06:42:05 +0000 | [diff] [blame] | 152 | ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 153 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 154 | fi |
| 155 | """ |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | stage('Failure/Recovery Tests') { |
| 160 | environment { |
| 161 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 162 | ROBOT_FILE="Voltha_DT_FailureScenarios.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 163 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 164 | } |
| 165 | steps { |
| 166 | sh """ |
| 167 | mkdir -p $ROBOT_LOGS_DIR |
| 168 | if [ "${params.testType}" == "Failure" ]; then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 169 | 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" |
Hardik Windlass | 7e4e315 | 2021-09-29 06:42:05 +0000 | [diff] [blame] | 170 | ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 171 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 172 | fi |
| 173 | """ |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | stage('Dataplane Tests') { |
| 178 | environment { |
| 179 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Suchitra Vemuri | 4d944e9 | 2020-09-03 22:50:44 -0700 | [diff] [blame] | 180 | ROBOT_FILE="Voltha_DT_PODTests.robot" |
Suchitra Vemuri | 07ceef3 | 2020-09-03 23:19:09 -0700 | [diff] [blame] | 181 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests" |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 182 | } |
| 183 | steps { |
| 184 | sh """ |
| 185 | mkdir -p $ROBOT_LOGS_DIR |
Suchitra Vemuri | 6060303 | 2020-09-10 17:13:37 -0700 | [diff] [blame] | 186 | if [ "${params.testType}" == "Dataplane" ]; then |
Hardik Windlass | c6eae66 | 2021-05-19 11:58:23 +0000 | [diff] [blame] | 187 | 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" |
Hardik Windlass | 7e4e315 | 2021-09-29 06:42:05 +0000 | [diff] [blame] | 188 | ROBOT_MISC_ARGS+=" -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}" |
Suchitra Vemuri | 0287e9b | 2021-02-25 11:17:32 -0800 | [diff] [blame] | 189 | make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 190 | fi |
| 191 | """ |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | } |
| 196 | post { |
| 197 | always { |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 198 | getPodsInfo("$WORKSPACE/pods") |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 199 | sh returnStdout: false, script: ''' |
| 200 | set +e |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -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 | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 203 | cd $WORKSPACE |
| 204 | gzip *-combined.log || true |
Matteo Scandolo | 5e7bd1d | 2021-07-16 13:29:42 -0700 | [diff] [blame] | 205 | rm *-combined.log || true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 206 | |
| 207 | # collect ETCD cluster logs |
| 208 | mkdir -p $WORKSPACE/etcd |
Girish Gowdra | 3eb96f6 | 2020-10-15 12:48:34 -0700 | [diff] [blame] | 209 | 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] | 210 | ''' |
| 211 | script { |
| 212 | deployment_config.olts.each { olt -> |
| 213 | sh returnStdout: false, script: """ |
| 214 | 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 |
| 215 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
| 216 | 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 |
| 217 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences |
| 218 | 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 |
| 219 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences |
| 220 | 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 |
| 221 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences |
| 222 | """ |
| 223 | } |
| 224 | } |
| 225 | step([$class: 'RobotPublisher', |
| 226 | disableArchiveOutput: false, |
| 227 | logFileName: '**/log*.html', |
| 228 | otherFiles: '', |
| 229 | outputFileName: '**/output*.xml', |
| 230 | outputPath: 'RobotLogs', |
| 231 | passThreshold: 100, |
| 232 | reportFileName: '**/report*.html', |
Andrea Campanella | abc0977 | 2021-06-16 12:08:57 +0200 | [diff] [blame] | 233 | unstableThreshold: 0, |
| 234 | onlyCritical: true |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 235 | ]); |
Hardik Windlass | 5cfb29a | 2021-08-10 09:39:29 +0000 | [diff] [blame] | 236 | // get cpu usage by container |
Hardik Windlass | 48e75f9 | 2021-08-11 22:11:33 +0530 | [diff] [blame] | 237 | sh """ |
Hardik Windlass | 5cfb29a | 2021-08-10 09:39:29 +0000 | [diff] [blame] | 238 | mkdir -p $WORKSPACE/plots || true |
| 239 | cd $WORKSPACE/voltha-system-tests |
| 240 | source ./vst_venv/bin/activate || true |
| 241 | sleep 60 # we have to wait for prometheus to collect all the information |
Hardik Windlass | b9dfd08 | 2021-08-19 04:41:14 +0000 | [diff] [blame] | 242 | python scripts/sizing.py -o $WORKSPACE/plots -a 0.0.0.0:31301 -n ${volthaNamespace} -s 3600 || true |
Girish Gowdra | 15f62dd | 2022-02-07 16:38:18 -0800 | [diff] [blame^] | 243 | # Collect memory consumption of voltha pods once all the tests are complete |
| 244 | python scripts/mem_consumption.py -o $WORKSPACE/voltha-pods-mem-consumption -a 0.0.0.0:31301 -n ${volthaNamespace} || true |
Hardik Windlass | 48e75f9 | 2021-08-11 22:11:33 +0530 | [diff] [blame] | 245 | """ |
Girish Gowdra | 15f62dd | 2022-02-07 16:38:18 -0800 | [diff] [blame^] | 246 | archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt,plots/*,voltha-pods-mem-consumption/*' |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 247 | } |
Suchitra Vemuri | f446165 | 2020-09-03 21:47:19 -0700 | [diff] [blame] | 248 | } |
| 249 | } |