2019-02-23 14:43:47 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2019-05-16 19:45:53 -04:00
|
|
|
set -e -o pipefail
|
2019-02-23 14:43:47 -05:00
|
|
|
|
|
|
|
usage() {
|
|
|
|
SCRIPT=$(basename "${BASH_SOURCE[@]}")
|
|
|
|
|
|
|
|
cat << __EOF
|
|
|
|
hbase-vote. A script for standard vote which verifies the following items
|
|
|
|
1. Checksum of sources and binaries
|
|
|
|
2. Signature of sources and binaries
|
|
|
|
3. Rat check
|
|
|
|
4. Built from source
|
|
|
|
5. Unit tests
|
|
|
|
|
2020-09-22 17:48:45 -04:00
|
|
|
Usage: ${SCRIPT} -s | --source <url> [-k | --key <signature>] [-f | --keys-file-url <url>] [-o | --output-dir </path/to/use>] [-P runSmallTests] [-D property[=value]]
|
2019-02-23 14:43:47 -05:00
|
|
|
${SCRIPT} -h | --help
|
|
|
|
|
|
|
|
-h | --help Show this screen.
|
|
|
|
-s | --source '<url>' A URL pointing to the release candidate sources and binaries
|
|
|
|
e.g. https://dist.apache.org/repos/dist/dev/hbase/hbase-<version>RC0/
|
|
|
|
-k | --key '<signature>' A signature of the public key, e.g. 9AD2AE49
|
|
|
|
-f | --keys-file-url '<url>' the URL of the key file, default is
|
2020-09-18 16:20:44 -04:00
|
|
|
https://downloads.apache.org/hbase/KEYS
|
2019-02-23 14:43:47 -05:00
|
|
|
-o | --output-dir '</path>' directory which has the stdout and stderr of each verification target
|
2019-05-30 12:55:24 -04:00
|
|
|
-P | list of maven profiles to activate for test UT/IT, i.e. <-P runSmallTests> Defaults to runAllTests
|
2020-12-09 02:34:18 -05:00
|
|
|
-D | list of maven properties to set for the mvn invocations, i.e. <-D hadoop.profile=3.0 -D skipTests> Defaults to unset
|
2019-02-23 14:43:47 -05:00
|
|
|
__EOF
|
|
|
|
}
|
|
|
|
|
2020-12-09 02:34:18 -05:00
|
|
|
MVN_PROFILES=()
|
|
|
|
MVN_PROPERTIES=()
|
|
|
|
|
2019-02-23 14:43:47 -05:00
|
|
|
while ((${#})); do
|
|
|
|
case "${1}" in
|
|
|
|
-h | --help )
|
2020-09-22 17:48:45 -04:00
|
|
|
usage; exit 0 ;;
|
|
|
|
-s | --source )
|
|
|
|
SOURCE_URL="${2}"; shift 2 ;;
|
|
|
|
-k | --key )
|
|
|
|
SIGNING_KEY="${2}"; shift 2 ;;
|
2019-02-23 14:43:47 -05:00
|
|
|
-f | --keys-file-url )
|
2020-09-22 17:48:45 -04:00
|
|
|
KEY_FILE_URL="${2}"; shift 2 ;;
|
2019-02-23 14:43:47 -05:00
|
|
|
-o | --output-dir )
|
2020-09-22 17:48:45 -04:00
|
|
|
OUTPUT_DIR="${2}"; shift 2 ;;
|
2019-05-30 12:55:24 -04:00
|
|
|
-P )
|
2020-12-09 02:34:18 -05:00
|
|
|
MVN_PROFILES+=("-P ${2}"); shift 2 ;;
|
2020-09-22 17:48:45 -04:00
|
|
|
-D )
|
2020-12-09 02:34:18 -05:00
|
|
|
MVN_PROPERTIES+=("-D ${2}"); shift 2 ;;
|
2020-09-22 17:48:45 -04:00
|
|
|
* )
|
2019-02-23 14:43:47 -05:00
|
|
|
usage >&2; exit 1 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Source url must be provided
|
|
|
|
if [ -z "${SOURCE_URL}" ]; then
|
|
|
|
usage;
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat << __EOF
|
|
|
|
Although This tool helps verifying HBase RC build and unit tests,
|
|
|
|
operator may still consider to verify the following manually
|
|
|
|
1. Verify the compat-check-report.html
|
|
|
|
2. Any on cluster Integration test or performance test, e.g. LTT load 100M or
|
|
|
|
ITBLL 1B rows with serverKilling monkey
|
|
|
|
3. Other concerns if any
|
|
|
|
__EOF
|
|
|
|
|
2019-05-16 19:43:27 -04:00
|
|
|
[[ "${SOURCE_URL}" != */ ]] && SOURCE_URL="${SOURCE_URL}/"
|
2019-02-23 14:43:47 -05:00
|
|
|
HBASE_RC_VERSION=$(tr "/" "\n" <<< "${SOURCE_URL}" | tail -n2)
|
|
|
|
HBASE_VERSION=$(echo "${HBASE_RC_VERSION}" | sed -e 's/RC[0-9]//g' | sed -e 's/hbase-//g')
|
|
|
|
JAVA_VERSION=$(java -version 2>&1 | cut -f3 -d' ' | head -n1 | sed -e 's/"//g')
|
|
|
|
OUTPUT_DIR="${OUTPUT_DIR:-$(pwd)}"
|
|
|
|
|
|
|
|
if [ ! -d "${OUTPUT_DIR}" ]; then
|
|
|
|
echo "Output directory ${OUTPUT_DIR} does not exist, please create it before running this script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-30 12:55:24 -04:00
|
|
|
# Maven profile must be provided
|
2020-12-09 02:34:18 -05:00
|
|
|
if [ ${#MVN_PROFILES[@]} -eq 0 ]; then
|
|
|
|
MVN_PROFILES=("-P runAllTests")
|
2019-05-30 12:55:24 -04:00
|
|
|
fi
|
|
|
|
|
2019-02-23 14:43:47 -05:00
|
|
|
OUTPUT_PATH_PREFIX="${OUTPUT_DIR}"/"${HBASE_RC_VERSION}"
|
|
|
|
|
|
|
|
# default value for verification targets, 0 = failed
|
|
|
|
SIGNATURE_PASSED=0
|
|
|
|
CHECKSUM_PASSED=0
|
|
|
|
RAT_CHECK_PASSED=0
|
|
|
|
BUILD_FROM_SOURCE_PASSED=0
|
|
|
|
UNIT_TEST_PASSED=0
|
|
|
|
|
|
|
|
function download_and_import_keys() {
|
2020-09-18 16:20:44 -04:00
|
|
|
KEY_FILE_URL="${KEY_FILE_URL:-https://downloads.apache.org/hbase/KEYS}"
|
2019-02-23 14:43:47 -05:00
|
|
|
echo "Obtain and import the publisher key(s) from ${KEY_FILE_URL}"
|
|
|
|
# download the keys file into file KEYS
|
|
|
|
wget -O KEYS "${KEY_FILE_URL}"
|
|
|
|
gpg --import KEYS
|
|
|
|
if [ -n "${SIGNING_KEY}" ]; then
|
|
|
|
gpg --list-keys "${SIGNING_KEY}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function download_release_candidate () {
|
|
|
|
# get all files from release candidate repo
|
2019-05-30 12:55:24 -04:00
|
|
|
wget -r -np -N -nH --cut-dirs 4 "${SOURCE_URL}"
|
2019-02-23 14:43:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function verify_signatures() {
|
|
|
|
rm -f "${OUTPUT_PATH_PREFIX}"_verify_signatures
|
|
|
|
for file in *.tar.gz; do
|
2019-05-16 19:45:53 -04:00
|
|
|
gpg --verify "${file}".asc "${file}" 2>&1 | tee -a "${OUTPUT_PATH_PREFIX}"_verify_signatures && SIGNATURE_PASSED=1 || SIGNATURE_PASSED=0
|
2019-02-23 14:43:47 -05:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function verify_checksums() {
|
|
|
|
rm -f "${OUTPUT_PATH_PREFIX}"_verify_checksums
|
|
|
|
SHA_EXT=$(find . -name "*.sha*" | awk -F '.' '{ print $NF }' | head -n 1)
|
|
|
|
for file in *.tar.gz; do
|
|
|
|
gpg --print-md SHA512 "${file}" > "${file}"."${SHA_EXT}".tmp
|
2019-05-16 19:45:53 -04:00
|
|
|
diff "${file}"."${SHA_EXT}".tmp "${file}"."${SHA_EXT}" 2>&1 | tee -a "${OUTPUT_PATH_PREFIX}"_verify_checksums && CHECKSUM_PASSED=1 || CHECKSUM_PASSED=0
|
2019-02-23 14:43:47 -05:00
|
|
|
rm -f "${file}"."${SHA_EXT}".tmp
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function unzip_from_source() {
|
|
|
|
tar -zxvf hbase-"${HBASE_VERSION}"-src.tar.gz
|
|
|
|
cd hbase-"${HBASE_VERSION}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function rat_test() {
|
|
|
|
rm -f "${OUTPUT_PATH_PREFIX}"_rat_test
|
2020-12-09 02:34:18 -05:00
|
|
|
mvn clean apache-rat:check "${MVN_PROPERTIES[@]}" 2>&1 | tee "${OUTPUT_PATH_PREFIX}"_rat_test && RAT_CHECK_PASSED=1
|
2019-02-23 14:43:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function build_from_source() {
|
|
|
|
rm -f "${OUTPUT_PATH_PREFIX}"_build_from_source
|
2020-12-09 02:34:18 -05:00
|
|
|
# Hardcode skipTests for faster build. Testing is covered later.
|
|
|
|
mvn clean install "${MVN_PROPERTIES[@]}" -DskipTests 2>&1 | tee "${OUTPUT_PATH_PREFIX}"_build_from_source && BUILD_FROM_SOURCE_PASSED=1
|
2019-02-23 14:43:47 -05:00
|
|
|
}
|
|
|
|
|
2019-05-30 12:55:24 -04:00
|
|
|
function run_tests() {
|
|
|
|
rm -f "${OUTPUT_PATH_PREFIX}"_run_tests
|
2022-11-10 07:27:58 -05:00
|
|
|
mvn clean package "${MVN_PROFILES[@]}" "${MVN_PROPERTIES[@]}" -Dsurefire.rerunFailingTestsCount=3 2>&1 | tee "${OUTPUT_PATH_PREFIX}"_run_tests && UNIT_TEST_PASSED=1
|
2019-02-23 14:43:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function execute() {
|
|
|
|
${1} || print_when_exit
|
|
|
|
}
|
|
|
|
|
|
|
|
function print_when_exit() {
|
|
|
|
cat << __EOF
|
|
|
|
* Signature: $( ((SIGNATURE_PASSED)) && echo "ok" || echo "failed" )
|
|
|
|
* Checksum : $( ((CHECKSUM_PASSED)) && echo "ok" || echo "failed" )
|
|
|
|
* Rat check (${JAVA_VERSION}): $( ((RAT_CHECK_PASSED)) && echo "ok" || echo "failed" )
|
2020-12-09 02:34:18 -05:00
|
|
|
- mvn clean apache-rat:check ${MVN_PROPERTIES[@]}
|
2019-02-23 14:43:47 -05:00
|
|
|
* Built from source (${JAVA_VERSION}): $( ((BUILD_FROM_SOURCE_PASSED)) && echo "ok" || echo "failed" )
|
2020-12-09 02:34:18 -05:00
|
|
|
- mvn clean install ${MVN_PROPERTIES[@]} -DskipTests
|
2019-02-23 14:43:47 -05:00
|
|
|
* Unit tests pass (${JAVA_VERSION}): $( ((UNIT_TEST_PASSED)) && echo "ok" || echo "failed" )
|
2022-11-10 07:27:58 -05:00
|
|
|
- mvn clean package ${MVN_PROFILES[@]} ${MVN_PROPERTIES[@]} -Dsurefire.rerunFailingTestsCount=3
|
2019-02-23 14:43:47 -05:00
|
|
|
__EOF
|
|
|
|
if ((CHECKSUM_PASSED)) && ((SIGNATURE_PASSED)) && ((RAT_CHECK_PASSED)) && ((BUILD_FROM_SOURCE_PASSED)) && ((UNIT_TEST_PASSED)) ; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
download_and_import_keys
|
|
|
|
download_release_candidate
|
2019-05-16 19:43:27 -04:00
|
|
|
pushd "${HBASE_RC_VERSION}"
|
2019-02-23 14:43:47 -05:00
|
|
|
|
|
|
|
execute verify_signatures
|
|
|
|
execute verify_checksums
|
|
|
|
execute unzip_from_source
|
|
|
|
execute rat_test
|
|
|
|
execute build_from_source
|
2019-05-30 12:55:24 -04:00
|
|
|
execute run_tests
|
2019-02-23 14:43:47 -05:00
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
print_when_exit
|