Suchitra Vemuri | e662522 | 2020-09-01 17:12:56 -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 | |
| 15 | node { |
| 16 | // Need this so that deployment_config has global scope when it's read later |
| 17 | deployment_config = null |
| 18 | } |
| 19 | |
| 20 | pipeline { |
| 21 | /* no label, executor is determined by JJB */ |
| 22 | agent { |
| 23 | label "${params.buildNode}" |
| 24 | } |
| 25 | options { |
| 26 | timeout(time: 280, unit: 'MINUTES') |
| 27 | } |
| 28 | |
| 29 | environment { |
| 30 | KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf" |
| 31 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 32 | PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 33 | } |
| 34 | |
| 35 | stages { |
| 36 | stage ('Initialize') { |
| 37 | steps { |
| 38 | step([$class: 'WsCleanup']) |
| 39 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}" |
| 40 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/kind-voltha" |
| 41 | script { |
| 42 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 43 | } |
| 44 | // This checkout allows us to show changes in Jenkins |
| 45 | checkout(changelog: true, |
| 46 | poll: false, |
| 47 | scm: [$class: 'RepoScm', |
| 48 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 49 | manifestBranch: "${params.branch}", |
| 50 | currentBranch: true, |
| 51 | destinationDir: 'voltha', |
| 52 | forceSync: true, |
| 53 | resetFirst: true, |
| 54 | quiet: true, |
| 55 | jobs: 4, |
| 56 | showAllChanges: true] |
| 57 | ) |
| 58 | sh returnStdout: false, script: """ |
| 59 | cd voltha |
| 60 | git clone -b master ${cordRepoUrl}/cord-tester |
| 61 | mkdir -p $WORKSPACE/bin |
| 62 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
| 63 | cd $WORKSPACE |
| 64 | if [ "${params.branch}" != "master" ]; then |
| 65 | cd $WORKSPACE/kind-voltha |
| 66 | source releases/${params.branch} |
| 67 | VC_VERSION=1.1.8 |
| 68 | else |
| 69 | VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 70 | fi |
| 71 | |
| 72 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 73 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 74 | if [ \$HOSTARCH == "x86_64" ]; then |
| 75 | HOSTARCH="amd64" |
| 76 | fi |
| 77 | curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH} |
| 78 | chmod 755 $WORKSPACE/bin/voltctl |
| 79 | voltctl version --clientonly |
| 80 | |
| 81 | if [ "${params.branch}" == "master" ]; then |
| 82 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 83 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 84 | # We should change this. In the meantime here is a workaround. |
| 85 | set +e |
| 86 | |
| 87 | # Remove noise from voltha-core logs |
| 88 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 89 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 90 | # Remove noise from openolt logs |
| 91 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 92 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 93 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 94 | fi |
| 95 | """ |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | stage('Functional Tests') { |
| 100 | environment { |
| 101 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 102 | ROBOT_FILE="Voltha_PODTests.robot" |
| 103 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests" |
| 104 | } |
| 105 | steps { |
| 106 | sh """ |
| 107 | cd $WORKSPACE/voltha/kind-voltha/scripts |
| 108 | ./log-collector.sh > /dev/null & |
| 109 | ./log-combine.sh > /dev/null & |
| 110 | |
| 111 | mkdir -p $ROBOT_LOGS_DIR |
| 112 | if [ "${params.testType}" == "Functional" ]; then |
| 113 | if ( ${powerSwitch} ); then |
Suchitra Vemuri | 0d96672 | 2020-09-08 21:03:58 -0700 | [diff] [blame] | 114 | export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanity -i functional -e DeleteOLT -e DisableONU_AuthCheck -e DisableDeleteONUandOLT -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
Suchitra Vemuri | e662522 | 2020-09-01 17:12:56 -0700 | [diff] [blame] | 115 | else |
| 116 | export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanity -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
| 117 | fi |
| 118 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true |
| 119 | fi |
Suchitra Vemuri | e662522 | 2020-09-01 17:12:56 -0700 | [diff] [blame] | 120 | """ |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | stage('Failure/Recovery Tests') { |
| 125 | environment { |
| 126 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 127 | ROBOT_FILE="Voltha_FailureScenarios.robot" |
| 128 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureScenarios" |
| 129 | } |
| 130 | steps { |
| 131 | sh """ |
| 132 | mkdir -p $ROBOT_LOGS_DIR |
| 133 | if [ "${params.testType}" == "Failure" ]; then |
| 134 | if ( ${powerSwitch} ); then |
| 135 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -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" |
| 136 | else |
| 137 | export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -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" |
| 138 | fi |
Suchitra Vemuri | 0903e66 | 2020-09-02 09:24:18 -0700 | [diff] [blame] | 139 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true |
Suchitra Vemuri | e662522 | 2020-09-01 17:12:56 -0700 | [diff] [blame] | 140 | fi |
Suchitra Vemuri | e662522 | 2020-09-01 17:12:56 -0700 | [diff] [blame] | 141 | """ |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | stage('Dataplane Tests') { |
| 146 | environment { |
| 147 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 148 | ROBOT_FILE="Voltha_PODTests.robot" |
| 149 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DataplaneTests" |
| 150 | } |
| 151 | steps { |
| 152 | sh """ |
| 153 | mkdir -p $ROBOT_LOGS_DIR |
Suchitra Vemuri | 0d96672 | 2020-09-08 21:03:58 -0700 | [diff] [blame] | 154 | if [ "${params.testType}" == "Dataplane" ]; then |
Suchitra Vemuri | e662522 | 2020-09-01 17:12:56 -0700 | [diff] [blame] | 155 | export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplane -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE" |
| 156 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true |
| 157 | fi |
| 158 | """ |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | post { |
| 164 | always { |
| 165 | sh returnStdout: false, script: ''' |
| 166 | set +e |
| 167 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 168 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 169 | kubectl get nodes -o wide |
| 170 | kubectl get pods -n voltha -o wide |
| 171 | |
| 172 | sleep 60 # Wait for log-collector and log-combine to complete |
| 173 | |
| 174 | # Clean up "announcer" pod used by the tests if present |
| 175 | kubectl delete pod announcer || true |
| 176 | |
| 177 | ## Pull out errors from log files |
| 178 | extract_errors_go() { |
| 179 | echo |
| 180 | echo "Error summary for $1:" |
| 181 | grep '"level":"error"' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1* |
| 182 | echo |
| 183 | } |
| 184 | |
| 185 | extract_errors_python() { |
| 186 | echo |
| 187 | echo "Error summary for $1:" |
| 188 | grep 'ERROR' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1* |
| 189 | echo |
| 190 | } |
| 191 | |
| 192 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 193 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 194 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 195 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 196 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 197 | |
| 198 | cd $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/ |
| 199 | tar czf $WORKSPACE/container-logs.tgz * |
| 200 | |
| 201 | cd $WORKSPACE |
| 202 | gzip *-combined.log || true |
| 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 | e662522 | 2020-09-01 17:12:56 -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 | e662522 | 2020-09-01 17:12:56 -0700 | [diff] [blame] | 232 | ]); |
| 233 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log' |
| 234 | } |
| 235 | unstable { |
| 236 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 237 | } |
| 238 | } |
| 239 | } |