Andrea Campanella | edf6183 | 2020-11-12 15:47:18 +0100 | [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: 380, 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 | stages { |
| 35 | stage('Clone kind-voltha') { |
| 36 | steps { |
| 37 | step([$class: 'WsCleanup']) |
| 38 | checkout([ |
| 39 | $class: 'GitSCM', |
| 40 | userRemoteConfigs: [[ |
| 41 | url: "https://gerrit.opencord.org/kind-voltha", |
| 42 | refspec: "${kindVolthaChange}" |
| 43 | ]], |
| 44 | branches: [[ name: "master", ]], |
| 45 | extensions: [ |
| 46 | [$class: 'WipeWorkspace'], |
| 47 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 48 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 49 | ], |
| 50 | ]) |
| 51 | } |
| 52 | } |
| 53 | stage('Clone voltha-system-tests') { |
| 54 | steps { |
| 55 | checkout([ |
| 56 | $class: 'GitSCM', |
| 57 | userRemoteConfigs: [[ |
| 58 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 59 | refspec: "${volthaSystemTestsChange}" |
| 60 | ]], |
Suchitra Vemuri | 53ee148 | 2021-03-25 15:16:30 -0700 | [diff] [blame] | 61 | branches: [[ name: "master", ]], |
Andrea Campanella | edf6183 | 2020-11-12 15:47:18 +0100 | [diff] [blame] | 62 | extensions: [ |
| 63 | [$class: 'WipeWorkspace'], |
| 64 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 65 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 66 | ], |
| 67 | ]) |
| 68 | } |
| 69 | } |
| 70 | stage('Clone cord-tester') { |
| 71 | steps { |
| 72 | checkout([ |
| 73 | $class: 'GitSCM', |
| 74 | userRemoteConfigs: [[ |
| 75 | url: "https://gerrit.opencord.org/cord-tester", |
| 76 | refspec: "${cordTesterChange}" |
| 77 | ]], |
| 78 | branches: [[ name: "master", ]], |
| 79 | extensions: [ |
| 80 | [$class: 'WipeWorkspace'], |
| 81 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"], |
| 82 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 83 | ], |
| 84 | ]) |
| 85 | } |
| 86 | } |
| 87 | stage('Download All the VOLTHA repos') { |
| 88 | when { |
| 89 | expression { |
| 90 | return "${branch}" == 'master'; |
| 91 | } |
| 92 | } |
| 93 | steps { |
| 94 | checkout(changelog: true, |
| 95 | poll: false, |
| 96 | scm: [$class: 'RepoScm', |
| 97 | manifestRepositoryUrl: "${params.manifestUrl}", |
| 98 | manifestBranch: "${params.branch}", |
| 99 | currentBranch: true, |
| 100 | destinationDir: 'voltha', |
| 101 | forceSync: true, |
| 102 | resetFirst: true, |
| 103 | quiet: true, |
| 104 | jobs: 4, |
| 105 | showAllChanges: true] |
| 106 | ) |
| 107 | } |
| 108 | } |
| 109 | stage ('Initialize') { |
| 110 | steps { |
| 111 | sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}" |
| 112 | script { |
| 113 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 114 | } |
| 115 | sh returnStdout: false, script: """ |
| 116 | mkdir -p $WORKSPACE/bin |
| 117 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin" |
| 118 | cd $WORKSPACE |
| 119 | if [ "${params.branch}" != "master" ]; then |
| 120 | cd $WORKSPACE/kind-voltha |
| 121 | source releases/${params.branch} |
| 122 | else |
| 123 | VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 124 | fi |
| 125 | |
| 126 | HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 127 | HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 128 | if [ \$HOSTARCH == "x86_64" ]; then |
| 129 | HOSTARCH="amd64" |
| 130 | fi |
| 131 | curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH} |
| 132 | chmod 755 $WORKSPACE/bin/voltctl |
| 133 | voltctl version --clientonly |
| 134 | |
| 135 | if [ "${params.branch}" == "master" ]; then |
| 136 | # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore. |
| 137 | # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work. |
| 138 | # We should change this. In the meantime here is a workaround. |
| 139 | set +e |
| 140 | |
| 141 | # Remove noise from voltha-core logs |
| 142 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 143 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 144 | # Remove noise from openolt logs |
| 145 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 146 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 147 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 148 | fi |
| 149 | """ |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | stage('Functional Tests') { |
| 154 | environment { |
| 155 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 156 | ROBOT_FILE="Voltha_PODTests.robot" |
| 157 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests" |
| 158 | } |
| 159 | steps { |
| 160 | sh """ |
| 161 | cd $WORKSPACE/kind-voltha/scripts |
| 162 | ./log-collector.sh > /dev/null & |
| 163 | ./log-combine.sh > /dev/null & |
| 164 | |
| 165 | mkdir -p $ROBOT_LOGS_DIR |
| 166 | if ( ${powerSwitch} ); then |
| 167 | export ROBOT_MISC_ARGS="--removekeywords wuks -i 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" |
| 168 | else |
| 169 | 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" |
| 170 | fi |
| 171 | make -C $WORKSPACE/voltha-system-tests voltha-test || true |
| 172 | """ |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | stage('Dataplane Tests') { |
| 177 | environment { |
| 178 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 179 | ROBOT_FILE="Voltha_PODTests.robot" |
| 180 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DataplaneTests" |
| 181 | } |
| 182 | steps { |
| 183 | sh """ |
| 184 | mkdir -p $ROBOT_LOGS_DIR |
| 185 | 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" |
| 186 | make -C $WORKSPACE/voltha-system-tests voltha-test || true |
| 187 | """ |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | } |
| 192 | post { |
| 193 | always { |
| 194 | sh returnStdout: false, script: ''' |
| 195 | set +e |
| 196 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 197 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 198 | kubectl get nodes -o wide |
| 199 | kubectl get pods -n voltha -o wide |
| 200 | kubectl get pods -o wide |
| 201 | |
| 202 | sleep 60 # Wait for log-collector and log-combine to complete |
| 203 | |
| 204 | # Clean up "announcer" pod used by the tests if present |
| 205 | kubectl delete pod announcer || true |
| 206 | |
| 207 | ## Pull out errors from log files |
| 208 | extract_errors_go() { |
| 209 | echo |
| 210 | echo "Error summary for $1:" |
| 211 | grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
| 212 | echo |
| 213 | } |
| 214 | |
| 215 | extract_errors_python() { |
| 216 | echo |
| 217 | echo "Error summary for $1:" |
| 218 | grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
| 219 | echo |
| 220 | } |
| 221 | |
| 222 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 223 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 224 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 225 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 226 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 227 | |
| 228 | gzip error-report.log || true |
| 229 | rm error-report.log || true |
| 230 | |
| 231 | cd $WORKSPACE/kind-voltha/scripts/logger/combined/ |
| 232 | tar czf $WORKSPACE/container-logs.tgz * |
| 233 | rm * || true |
| 234 | |
| 235 | cd $WORKSPACE |
| 236 | gzip *-combined.log || true |
| 237 | rm *-combined.log || true |
| 238 | |
| 239 | # collect ETCD cluster logs |
| 240 | mkdir -p $WORKSPACE/etcd |
| 241 | printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I% bash -c "kubectl logs % > $WORKSPACE/etcd/%.log" |
| 242 | ''' |
| 243 | script { |
| 244 | deployment_config.olts.each { olt -> |
| 245 | sh returnStdout: false, script: """ |
| 246 | 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 |
| 247 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
| 248 | 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 |
| 249 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences |
| 250 | 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 |
| 251 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences |
| 252 | 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 |
| 253 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences |
| 254 | """ |
| 255 | } |
| 256 | } |
| 257 | step([$class: 'RobotPublisher', |
| 258 | disableArchiveOutput: false, |
| 259 | logFileName: '**/log*.html', |
| 260 | otherFiles: '', |
| 261 | outputFileName: '**/output*.xml', |
| 262 | outputPath: 'RobotLogs', |
| 263 | passThreshold: 100, |
| 264 | reportFileName: '**/report*.html', |
| 265 | unstableThreshold: 0 |
| 266 | ]); |
| 267 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log' |
| 268 | } |
| 269 | unstable { |
| 270 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 271 | } |
| 272 | } |
| 273 | } |