2020-12-16 18:34:59 +00: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.
|
|
|
|
|
2022-10-20 17:07:04 +00:00
|
|
|
resourceDir=src/test/resources/
|
|
|
|
accountSettingsFolderName=accountSettings
|
|
|
|
combtestfile=$resourceDir
|
|
|
|
combtestfile+=abfs-combination-test-configs.xml
|
|
|
|
logdir=dev-support/testlogs/
|
2020-12-16 18:34:59 +00:00
|
|
|
|
2024-04-12 16:52:47 +00:00
|
|
|
# Regex to filter out final test stats
|
|
|
|
testresultsregex="Tests run: [0-9]+, Failures: [0-9]+, Errors: [0-9]+, Skipped: [0-9]+$"
|
|
|
|
|
|
|
|
# Regex to filter out the test that failed due to unexpected output or error.
|
|
|
|
failedTestRegex1="<<< FAILURE!$"
|
|
|
|
|
|
|
|
# Regex to filter out the test that failed due to runtime exception.
|
|
|
|
failedTestRegex2="<<< ERROR!$"
|
|
|
|
|
|
|
|
# Regex to remove the formatting used by mvn output for better regex matching.
|
|
|
|
removeFormattingRegex="s/\x1b\[[0-9;]*m//g"
|
2022-10-20 17:07:04 +00:00
|
|
|
accountConfigFileSuffix="_settings.xml"
|
2024-04-12 16:52:47 +00:00
|
|
|
separatorbar1="============================================================"
|
|
|
|
separatorbar2="------------------------------"
|
2022-10-20 17:07:04 +00:00
|
|
|
testOutputLogFolder=$logdir
|
|
|
|
testlogfilename=combinationTestLogFile
|
|
|
|
|
|
|
|
fullRunStartTime=$(date +%s)
|
|
|
|
STARTTIME=$(date +%s)
|
|
|
|
ENDTIME=$(date +%s)
|
|
|
|
|
|
|
|
outputFormatOn="\033[0;95m"
|
|
|
|
outputFormatOff="\033[0m"
|
|
|
|
|
|
|
|
triggerRun()
|
|
|
|
{
|
|
|
|
echo ' '
|
|
|
|
combination=$1
|
|
|
|
accountName=$2
|
|
|
|
runTest=$3
|
|
|
|
processcount=$4
|
|
|
|
cleanUpTestContainers=$5
|
|
|
|
|
|
|
|
if [ -z "$accountName" ]; then
|
|
|
|
logOutput "ERROR: Test account not configured. Re-run the script and choose SET_OR_CHANGE_TEST_ACCOUNT to configure the test account."
|
|
|
|
exit 1;
|
2020-12-16 18:34:59 +00:00
|
|
|
fi
|
2022-10-20 17:07:04 +00:00
|
|
|
accountConfigFile=$accountSettingsFolderName/$accountName$accountConfigFileSuffix
|
|
|
|
rm -rf $combtestfile
|
|
|
|
cat > $combtestfile << ENDOFFILE
|
2020-12-16 18:34:59 +00:00
|
|
|
<configuration>
|
|
|
|
|
|
|
|
</configuration>
|
|
|
|
ENDOFFILE
|
2022-10-20 17:07:04 +00:00
|
|
|
propertiessize=${#PROPERTIES[@]}
|
|
|
|
valuessize=${#VALUES[@]}
|
2020-12-16 18:34:59 +00:00
|
|
|
if [ "$propertiessize" -ne "$valuessize" ]; then
|
2022-10-20 17:07:04 +00:00
|
|
|
logOutput "Exiting. Number of properties and values differ for $combination"
|
|
|
|
exit 1
|
2020-12-16 18:34:59 +00:00
|
|
|
fi
|
2024-04-12 16:52:47 +00:00
|
|
|
echo "$separatorbar1"
|
|
|
|
echo "$combination"
|
|
|
|
echo "$separatorbar1"
|
|
|
|
|
|
|
|
# First include the account specific configurations.
|
|
|
|
xmlstarlet ed -P -L -s /configuration -t elem -n include -v "" $combtestfile
|
|
|
|
xmlstarlet ed -P -L -i /configuration/include -t attr -n href -v "$accountConfigFile" $combtestfile
|
|
|
|
xmlstarlet ed -P -L -i /configuration/include -t attr -n xmlns -v "http://www.w3.org/2001/XInclude" $combtestfile
|
|
|
|
|
|
|
|
# Override the combination specific configurations.
|
2020-12-16 18:34:59 +00:00
|
|
|
for ((i = 0; i < propertiessize; i++)); do
|
2022-10-20 17:07:04 +00:00
|
|
|
key=${PROPERTIES[$i]}
|
|
|
|
val=${VALUES[$i]}
|
|
|
|
echo "Combination specific property setting: [ key=$key , value=$val ]"
|
2020-12-16 18:34:59 +00:00
|
|
|
changeconf "$key" "$val"
|
|
|
|
done
|
2022-10-20 17:07:04 +00:00
|
|
|
formatxml "$combtestfile"
|
|
|
|
echo ' '
|
|
|
|
echo "Activated [$combtestfile] - for account: $accountName for combination $combination"
|
|
|
|
testlogfilename="$testOutputLogFolder/Test-Logs-$combination.txt"
|
|
|
|
touch "$testlogfilename"
|
2020-12-16 18:34:59 +00:00
|
|
|
|
2022-10-20 17:07:04 +00:00
|
|
|
if [ "$runTest" == true ]
|
2020-12-16 18:34:59 +00:00
|
|
|
then
|
2022-10-20 17:07:04 +00:00
|
|
|
STARTTIME=$(date +%s)
|
|
|
|
echo "Running test for combination $combination on account $accountName [ProcessCount=$processcount]"
|
|
|
|
logOutput "Test run report can be seen in $testlogfilename"
|
|
|
|
mvn -T 1C -Dparallel-tests=abfs -Dscale -DtestsThreadCount="$processcount" verify >> "$testlogfilename" || true
|
2024-04-12 16:52:47 +00:00
|
|
|
# Remove the formatting used by mvn output for better regex matching.
|
|
|
|
sed -i "$removeFormattingRegex" "$testlogfilename"
|
2022-10-20 17:07:04 +00:00
|
|
|
ENDTIME=$(date +%s)
|
|
|
|
summary
|
2020-12-16 18:34:59 +00:00
|
|
|
fi
|
2022-10-20 17:07:04 +00:00
|
|
|
|
|
|
|
if [ "$cleanUpTestContainers" == true ]
|
|
|
|
then
|
|
|
|
mvn test -Dtest=org.apache.hadoop.fs.azurebfs.utils.CleanupTestContainers >> "$testlogfilename" || true
|
|
|
|
if grep -q "There are test failures" "$testlogfilename";
|
|
|
|
then logOutput "ERROR: All test containers could not be deleted. Detailed error cause in $testlogfilename"
|
|
|
|
pcregrep -M "$testresultsregex" "$testlogfilename"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
logOutput "Delete test containers - complete. Test run logs in - $testlogfilename"
|
|
|
|
fi
|
|
|
|
|
2020-12-16 18:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
summary() {
|
|
|
|
{
|
|
|
|
echo ""
|
2024-04-12 16:52:47 +00:00
|
|
|
echo "$separatorbar1"
|
2020-12-16 18:34:59 +00:00
|
|
|
echo "$combination"
|
2024-04-12 16:52:47 +00:00
|
|
|
echo "$separatorbar1"
|
|
|
|
summarycontent
|
2022-10-20 17:07:04 +00:00
|
|
|
} >> "$aggregatedTestResult"
|
2020-12-16 18:34:59 +00:00
|
|
|
printf "\n----- Test results -----\n"
|
2024-04-12 16:52:47 +00:00
|
|
|
summarycontent
|
2020-12-16 18:34:59 +00:00
|
|
|
secondstaken=$((ENDTIME - STARTTIME))
|
|
|
|
mins=$((secondstaken / 60))
|
|
|
|
secs=$((secondstaken % 60))
|
|
|
|
printf "\nTime taken: %s mins %s secs.\n" "$mins" "$secs"
|
2024-04-12 16:52:47 +00:00
|
|
|
logOutput "For Error details refer to Test run report in: $testlogfilename"
|
2022-10-20 17:07:04 +00:00
|
|
|
logOutput "Consolidated test result is saved in: $aggregatedTestResult"
|
2024-04-12 16:52:47 +00:00
|
|
|
echo "$separatorbar2"
|
|
|
|
}
|
|
|
|
|
|
|
|
summarycontent() {
|
|
|
|
output=$(pcregrep -M "$failedTestRegex1" "$testlogfilename" || true)
|
|
|
|
if [ -n "$output" ]; then
|
|
|
|
echo "$output"
|
|
|
|
fi
|
|
|
|
output=$(pcregrep -M "$failedTestRegex2" "$testlogfilename" || true)
|
|
|
|
if [ -n "$output" ]; then
|
|
|
|
echo ""
|
|
|
|
echo "$output"
|
|
|
|
fi
|
|
|
|
output=$(pcregrep -M "$testresultsregex" "$testlogfilename" || true)
|
|
|
|
if [ -n "$output" ]; then
|
|
|
|
echo ""
|
|
|
|
echo "$output"
|
|
|
|
fi
|
2020-12-16 18:34:59 +00:00
|
|
|
}
|
|
|
|
|
2022-10-20 17:07:04 +00:00
|
|
|
checkdependencies() {
|
|
|
|
if ! [ "$(command -v pcregrep)" ]; then
|
|
|
|
logOutput "Exiting. pcregrep is required to run the script."
|
|
|
|
exit 1
|
2020-12-16 18:34:59 +00:00
|
|
|
fi
|
2022-10-20 17:07:04 +00:00
|
|
|
if ! [ "$(command -v xmlstarlet)" ]; then
|
|
|
|
logOutput "Exiting. xmlstarlet is required to run the script."
|
|
|
|
exit 1
|
2020-12-16 18:34:59 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-10-20 17:07:04 +00:00
|
|
|
formatxml() {
|
|
|
|
xmlstarlet fo -s 2 "$1" > "$1.tmp"
|
|
|
|
mv "$1.tmp" "$1"
|
2020-12-16 18:34:59 +00:00
|
|
|
}
|
|
|
|
|
2022-10-20 17:07:04 +00:00
|
|
|
changeconf() {
|
|
|
|
xmlstarlet ed -P -L -d "/configuration/property[name='$1']" "$combtestfile"
|
|
|
|
xmlstarlet ed -P -L -s /configuration -t elem -n propertyTMP -v "" -s /configuration/propertyTMP -t elem -n name -v "$1" -r /configuration/propertyTMP -v property "$combtestfile"
|
|
|
|
if ! xmlstarlet ed -P -L -s "/configuration/property[name='$1']" -t elem -n value -v "$2" "$combtestfile"
|
|
|
|
then
|
|
|
|
logOutput "Exiting. Changing config property failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-16 18:34:59 +00:00
|
|
|
}
|
|
|
|
|
2022-10-20 17:07:04 +00:00
|
|
|
init() {
|
|
|
|
checkdependencies
|
|
|
|
if ! mvn clean install -DskipTests
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "Exiting. Build failed."
|
2020-12-16 18:34:59 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-10-20 17:07:04 +00:00
|
|
|
starttime=$(date +"%Y-%m-%d_%H-%M-%S")
|
|
|
|
testOutputLogFolder+=$starttime
|
|
|
|
mkdir -p "$testOutputLogFolder"
|
|
|
|
aggregatedTestResult="$testOutputLogFolder/Test-Results.txt"
|
|
|
|
}
|
|
|
|
|
|
|
|
printAggregate() {
|
|
|
|
echo :::: AGGREGATED TEST RESULT ::::
|
|
|
|
cat "$aggregatedTestResult"
|
|
|
|
fullRunEndTime=$(date +%s)
|
|
|
|
fullRunTimeInSecs=$((fullRunEndTime - fullRunStartTime))
|
|
|
|
mins=$((fullRunTimeInSecs / 60))
|
|
|
|
secs=$((fullRunTimeInSecs % 60))
|
|
|
|
printf "\nTime taken: %s mins %s secs.\n" "$mins" "$secs"
|
|
|
|
}
|
|
|
|
|
|
|
|
logOutput() {
|
|
|
|
echo -e "$outputFormatOn" "$1" "$outputFormatOff"
|
2020-12-16 18:34:59 +00:00
|
|
|
}
|