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 | |
| 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: 180, 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}-TT.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 | |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 81 | |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 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 | if [ "${params.branch}" == "master" ]; then |
| 86 | set +e |
| 87 | |
| 88 | |
| 89 | # Remove noise from voltha-core logs |
| 90 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model |
| 91 | voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 92 | # Remove noise from openolt logs |
| 93 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db |
| 94 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe |
| 95 | voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka |
| 96 | fi |
| 97 | """ |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | stage('Functional Tests') { |
| 102 | environment { |
| 103 | ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 104 | ROBOT_FILE="Voltha_TT_PODTests.robot" |
| 105 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests" |
| 106 | } |
| 107 | steps { |
| 108 | sh """ |
| 109 | cd $WORKSPACE/voltha/kind-voltha/scripts |
| 110 | ./log-collector.sh > /dev/null & |
| 111 | ./log-combine.sh > /dev/null & |
| 112 | |
| 113 | mkdir -p $ROBOT_LOGS_DIR |
| 114 | if ( ${powerSwitch} ); then |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 115 | export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanityTT -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 | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 116 | else |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 117 | export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanityTT -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 | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 118 | fi |
| 119 | make -C $WORKSPACE/voltha/voltha-system-tests voltha-tt-test || true |
| 120 | """ |
| 121 | } |
| 122 | } |
Suchitra Vemuri | 6cd5423 | 2020-07-09 16:06:55 -0700 | [diff] [blame] | 123 | } |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 124 | post { |
| 125 | always { |
| 126 | sh returnStdout: false, script: ''' |
| 127 | set +e |
| 128 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 129 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 130 | kubectl get nodes -o wide |
| 131 | kubectl get pods -n voltha -o wide |
| 132 | |
| 133 | sleep 60 # Wait for log-collector and log-combine to complete |
| 134 | |
| 135 | # Clean up "announcer" pod used by the tests if present |
| 136 | kubectl delete pod announcer || true |
| 137 | |
| 138 | ## Pull out errors from log files |
| 139 | extract_errors_go() { |
| 140 | echo |
| 141 | echo "Error summary for $1:" |
| 142 | grep '"level":"error"' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1* |
| 143 | echo |
| 144 | } |
| 145 | |
| 146 | extract_errors_python() { |
| 147 | echo |
| 148 | echo "Error summary for $1:" |
| 149 | grep 'ERROR' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1* |
| 150 | echo |
| 151 | } |
| 152 | |
| 153 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 154 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 155 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 156 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 157 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 158 | |
| 159 | cd $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/ |
| 160 | tar czf $WORKSPACE/container-logs.tgz * |
| 161 | |
| 162 | cd $WORKSPACE |
| 163 | gzip *-combined.log || true |
| 164 | ''' |
| 165 | script { |
| 166 | deployment_config.olts.each { olt -> |
| 167 | sh returnStdout: false, script: """ |
Suchitra Vemuri | a069566 | 2020-07-17 09:41:49 -0700 | [diff] [blame] | 168 | sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true |
| 169 | sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences |
Suchitra Vemuri | 376859a | 2020-07-08 17:04:44 -0700 | [diff] [blame] | 170 | """ |
| 171 | } |
| 172 | } |
| 173 | step([$class: 'RobotPublisher', |
| 174 | disableArchiveOutput: false, |
| 175 | logFileName: '**/log*.html', |
| 176 | otherFiles: '', |
| 177 | outputFileName: '**/output*.xml', |
| 178 | outputPath: 'RobotLogs', |
| 179 | passThreshold: 100, |
| 180 | reportFileName: '**/report*.html', |
| 181 | unstableThreshold: 0 |
| 182 | ]); |
| 183 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz' |
| 184 | } |
| 185 | unstable { |
| 186 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 187 | } |
| 188 | } |
| 189 | } |