Skip to content

Commit c8d61ff

Browse files
elekadoroszlai
authored andcommitted
HDDS-2030. Generate simplifed reports by the dev-support/checks/*.sh scripts
Signed-off-by: Anu Engineer <aengineer@apache.org> Co-Authored-By: Doroszlai, Attila <6454655+adoroszlai@users.noreply.github.com>
1 parent 56f042c commit c8d61ff

File tree

10 files changed

+174
-40
lines changed

10 files changed

+174
-40
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!---
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License. See accompanying LICENSE file.
13+
-->
14+
15+
# Ozone checks
16+
17+
This directory contains a collection of easy-to-use helper scripts to execute various type of tests on the ozone/hdds codebase.
18+
19+
The contract of the scripts are very simple:
20+
21+
1. Executing the scripts without any parameter will check the hdds/ozone project
22+
2. Shell exit code represents the result of the check (if failed, exits with non-zero code)
23+
3. Detailed information may be saved to the $OUTPUT_DIR (if it's not set, root level ./target will be used).
24+
4. The standard output should contain all the log about the build AND the results.
25+
5. The content of the $OUTPUT_DIR can be:
26+
* `summary.html`/`summary.md`/`summary.txt`: contains a human readable overview about the failed tests (used by reporting)
27+
* `failures`: contains a simple number (used by reporting)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
REPORT_DIR=${REPORT_DIR:-$PWD}
18+
19+
## generate summary txt file
20+
find "." -name 'TEST*.xml' -print0 \
21+
| xargs -n1 -0 "grep" -l -E "<failure|<error" \
22+
| awk -F/ '{sub("'"TEST-"'",""); sub(".xml",""); print $NF}' \
23+
| tee "$REPORT_DIR/summary.txt"
24+
25+
#Copy heap dump and dump leftovers
26+
find "." -name "*.hprof" -exec cp {} "$REPORT_DIR/" \;
27+
find "." -name "*.dump" -exec cp {} "$REPORT_DIR/" \;
28+
29+
## Add the tests where the JVM is crashed
30+
grep -A1 'Crashed tests' "${REPORT_DIR}/output.log" \
31+
| grep -v -e 'Crashed tests' -e '--' \
32+
| cut -f2- -d' ' \
33+
| sort -u >> "${REPORT_DIR}/summary.txt"
34+
35+
#Collect of all of the report failes of FAILED tests
36+
while IFS= read -r -d '' dir; do
37+
while IFS=$'\n' read -r file; do
38+
DIR_OF_TESTFILE=$(dirname "$file")
39+
NAME_OF_TESTFILE=$(basename "$file")
40+
NAME_OF_TEST="${NAME_OF_TESTFILE%.*}"
41+
DESTDIRNAME=$(realpath --relative-to="$PWD" "$DIR_OF_TESTFILE/../..")
42+
mkdir -p "$REPORT_DIR/$DESTDIRNAME"
43+
#shellcheck disable=SC2086
44+
cp -r "$DIR_OF_TESTFILE"/*$NAME_OF_TEST* "$REPORT_DIR/$DESTDIRNAME/"
45+
done < <(grep -l -r FAILURE --include="*.txt" "$dir" | grep -v output.txt)
46+
done < <(find "." -name surefire-reports -print0)
47+
48+
## generate summary markdown file
49+
export SUMMARY_FILE="$REPORT_DIR/summary.md"
50+
for TEST_RESULT_FILE in $(find "$REPORT_DIR" -name "*.txt" | grep -v output); do
51+
52+
FAILURES=$(grep FAILURE "$TEST_RESULT_FILE" | grep "Tests run" | awk '{print $18}' | sort | uniq)
53+
54+
for FAILURE in $FAILURES; do
55+
TEST_RESULT_LOCATION="$(realpath --relative-to="$REPORT_DIR" "$TEST_RESULT_FILE")"
56+
TEST_OUTPUT_LOCATION="${TEST_RESULT_LOCATION//.txt/-output.txt/}"
57+
printf " * [%s](%s) ([output](%s))\n" "$FAILURE" "$TEST_RESULT_LOCATION" "$TEST_OUTPUT_LOCATION" >> "$SUMMARY_FILE"
58+
done
59+
done
60+
61+
if [ -s "$SUMMARY_FILE" ]; then
62+
printf "# Failing tests: \n\n" | cat - "$SUMMARY_FILE" > temp && mv temp "$SUMMARY_FILE"
63+
fi
64+
65+
## generate counter
66+
wc -l "$REPORT_DIR/summary.txt" | awk '{print $1}'> "$REPORT_DIR/failures"

hadoop-ozone/dev-support/checks/acceptance.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,20 @@
1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd "$DIR/../../.." || exit 1
1818

19+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/acceptance"}
20+
mkdir -p "$REPORT_DIR"
21+
1922
OZONE_VERSION=$(grep "<ozone.version>" "$DIR/../../pom.xml" | sed 's/<[^>]*>//g'| sed 's/^[ \t]*//')
20-
cd "$DIR/../../dist/target/ozone-$OZONE_VERSION/compose" || exit 1
23+
DIST_DIR="$DIR/../../dist/target/ozone-$OZONE_VERSION"
24+
25+
if [ ! -d "$DIST_DIR" ]; then
26+
echo "Distribution dir is missing. Doing a full build"
27+
"$DIR/build.sh"
28+
fi
29+
30+
cd "$DIST_DIR/compose" || exit 1
2131
./test-all.sh
22-
exit $?
32+
RES=$?
33+
cp result/* "$REPORT_DIR/"
34+
cp "$REPORT_DIR/log.html" "$REPORT_DIR/summary.html"
35+
exit $RES

hadoop-ozone/dev-support/checks/author.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@
1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd "$DIR/../../.." || exit 1
1818

19-
#hide this tring to not confuse yetus
19+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/author"}
20+
mkdir -p "$REPORT_DIR"
21+
REPORT_FILE="$REPORT_DIR/summary.txt"
22+
23+
#hide this string to not confuse yetus
2024
AUTHOR="uthor"
2125
AUTHOR="@a${AUTHOR}"
2226

23-
if grep -r --include="*.java" "$AUTHOR" .; then
24-
exit 1
25-
else
26-
exit 0
27+
grep -r --include="*.java" "$AUTHOR" . | tee "$REPORT_FILE"
28+
29+
wc -l "$REPORT_FILE" | awk '{print $1}'> "$REPORT_DIR/failures"
30+
31+
if [[ -s "${REPORT_FILE}" ]]; then
32+
exit 1
2733
fi

hadoop-ozone/dev-support/checks/checkstyle.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd "$DIR/../../.." || exit 1
1818

19+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/checkstyle"}
20+
mkdir -p "$REPORT_DIR"
21+
REPORT_FILE="$REPORT_DIR/summary.txt"
22+
1923
mvn -B -fn checkstyle:check -f pom.ozone.xml
2024

2125
#Print out the exact violations with parsing XML results with sed
22-
find "." -name checkstyle-errors.xml -print0 | xargs -0 sed '$!N; /<file.*\n<\/file/d;P;D' | sed '/<\/.*/d;/<checkstyle.*/d;s/<error.*line="\([[:digit:]]*\)".*message="\([^"]\+\).*/ \1: \2/;s/<file name="\([^"]*\)".*/\1/;/<\?xml.*>/d'
26+
find "." -name checkstyle-errors.xml -print0 | xargs -0 sed '$!N; /<file.*\n<\/file/d;P;D' | sed '/<\/.*/d;/<checkstyle.*/d;s/<error.*line="\([[:digit:]]*\)".*message="\([^"]\+\).*/ \1: \2/;s/<file name="\([^"]*\)".*/\1/;/<\?xml.*>/d' | tee "$REPORT_FILE"
27+
28+
## generate counter
29+
wc -l "$REPORT_DIR/summary.txt" | awk '{print $1}'> "$REPORT_DIR/failures"
2330

24-
violations=$(grep -r error --include checkstyle-errors.xml .| wc -l)
25-
if [[ $violations -gt 0 ]]; then
26-
echo "There are $violations checkstyle violations"
27-
exit 1
31+
if [[ -s "${REPORT_FILE}" ]]; then
32+
exit 1
2833
fi
29-
exit 0

hadoop-ozone/dev-support/checks/findbugs.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@
1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd "$DIR/../../.." || exit 1
1818

19-
FINDBUGS_ALL_FILE=./target/findbugs-all.txt
19+
mvn -B compile -fn findbugs:check -Dfindbugs.failOnError=false -f pom.ozone.xml
2020

21-
mkdir -p ./target
22-
rm "$FINDBUGS_ALL_FILE" || true
23-
touch "$FINDBUGS_ALL_FILE"
21+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/findbugs"}
22+
mkdir -p "$REPORT_DIR"
23+
REPORT_FILE="$REPORT_DIR/summary.txt"
2424

25-
mvn -B compile -fn findbugs:check -Dfindbugs.failOnError=false -f pom.ozone.xml
25+
touch "$REPORT_FILE"
2626

27-
find hadoop-ozone -name findbugsXml.xml -print0 | xargs -0 -n1 convertXmlToText | tee -a "${FINDBUGS_ALL_FILE}"
28-
find hadoop-hdds -name findbugsXml.xml -print0 | xargs -0 -n1 convertXmlToText | tee -a "${FINDBUGS_ALL_FILE}"
27+
find hadoop-ozone -name findbugsXml.xml -print0 | xargs -0 -n1 convertXmlToText | tee -a "${REPORT_FILE}"
28+
find hadoop-hdds -name findbugsXml.xml -print0 | xargs -0 -n1 convertXmlToText | tee -a "${REPORT_FILE}"
2929

30-
bugs=$(wc -l < "$FINDBUGS_ALL_FILE")
30+
wc -l "$REPORT_FILE" | awk '{print $1}'> "$REPORT_DIR/failures"
3131

32-
if [[ ${bugs} -gt 0 ]]; then
32+
if [[ -s "${REPORT_FILE}" ]]; then
3333
exit 1
34-
else
35-
exit 0
3634
fi

hadoop-ozone/dev-support/checks/integration.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ export MAVEN_OPTS="-Xmx4096m"
2020
mvn -B install -f pom.ozone.xml -DskipTests
2121
mvn -B -fn test -f pom.ozone.xml -pl :hadoop-ozone-integration-test,:hadoop-ozone-filesystem,:hadoop-ozone-tools \
2222
-Dtest=\!TestMiniChaosOzoneCluster
23-
module_failed_tests=$(find "." -name 'TEST*.xml' -print0 \
24-
| xargs -0 -n1 "grep" -l -E "<failure|<error"\
25-
| awk -F/ '{sub("'"TEST-JUNIT_TEST_OUTPUT_DIR"'",""); sub(".xml",""); print $NF}')
26-
if [[ -n "${module_failed_tests}" ]] ; then
23+
24+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/integration"}
25+
mkdir -p "$REPORT_DIR"
26+
27+
# shellcheck source=hadoop-ozone/dev-support/checks/_mvn_unit_report.sh
28+
source "$DIR/_mvn_unit_report.sh"
29+
30+
if [[ -s "$REPORT_DIR/summary.txt" ]] ; then
2731
exit 1
2832
fi
2933
exit 0

hadoop-ozone/dev-support/checks/rat.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@
1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd "$DIR/../../.." || exit 1
1818

19-
mkdir -p target
20-
REPORT_FILE="$DIR/../../../target/rat-aggregated.txt"
21-
mkdir -p "$(dirname "$REPORT_FILE")"
19+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/rat"}
20+
mkdir -p "$REPORT_DIR"
21+
22+
REPORT_FILE="$REPORT_DIR/summary.txt"
2223

2324
cd hadoop-hdds || exit 1
2425
mvn -B -fn org.apache.rat:apache-rat-plugin:0.13:check
2526
cd ../hadoop-ozone || exit 1
2627
mvn -B -fn org.apache.rat:apache-rat-plugin:0.13:check
2728

2829
cd "$DIR/../../.." || exit 1
30+
2931
grep -r --include=rat.txt "!????" hadoop-hdds hadoop-ozone | tee "$REPORT_FILE"
32+
33+
wc -l "$REPORT_FILE" | awk '{print $1}'> "$REPORT_DIR/failures"
34+
3035
if [[ -s "${REPORT_FILE}" ]]; then
3136
exit 1
3237
fi

hadoop-ozone/dev-support/checks/shellcheck.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd "$DIR/../../.." || exit 1
1818

19-
OUTPUT_FILE="$DIR/../../../target/shell-problems.txt"
20-
mkdir -p "$(dirname "$OUTPUT_FILE")"
19+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/shellcheck"}
20+
mkdir -p "$REPORT_DIR"
21+
REPORT_FILE="$REPORT_DIR/summary.txt"
22+
2123
echo "" > "$OUTPUT_FILE"
2224
if [[ "$(uname -s)" = "Darwin" ]]; then
2325
find hadoop-hdds hadoop-ozone -type f -perm '-500'
@@ -26,8 +28,10 @@ else
2628
fi \
2729
| grep -v -e target/ -e node_modules/ -e '\.\(ico\|py\|yml\)$' \
2830
| xargs -n1 shellcheck \
29-
| tee "$OUTPUT_FILE"
31+
| tee "$REPORT_FILE"
32+
33+
wc -l "$REPORT_FILE" | awk '{print $1}'> "$REPORT_DIR/failures"
3034

31-
if [ "$(cat "$OUTPUT_FILE")" ]; then
35+
if [[ -s "${REPORT_FILE}" ]]; then
3236
exit 1
3337
fi

hadoop-ozone/dev-support/checks/unit.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
17+
cd "$DIR/../../.." || exit 1
18+
1619
export MAVEN_OPTS="-Xmx4096m"
17-
mvn -fn test -f pom.ozone.xml -pl \!:hadoop-ozone-integration-test,\!:hadoop-ozone-filesystem,\!:hadoop-ozone-tools
18-
module_failed_tests=$(find "." -name 'TEST*.xml' -print0 \
19-
| xargs -n1 -0 "grep" -l -E "<failure|<error"\
20-
| awk -F/ '{sub("'"TEST-JUNIT_TEST_OUTPUT_DIR"'",""); sub(".xml",""); print $NF}')
21-
if [[ -n "${module_failed_tests}" ]] ; then
20+
mvn -B -fn test -f pom.ozone.xml -pl \!:hadoop-ozone-integration-test,\!:hadoop-ozone-filesystem,\!:hadoop-ozone-tools
21+
22+
REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/unit"}
23+
mkdir -p "$REPORT_DIR"
24+
25+
# shellcheck source=hadoop-ozone/dev-support/checks/_mvn_unit_report.sh
26+
source "$DIR/_mvn_unit_report.sh"
27+
28+
if [[ -s "$REPORT_DIR/summary.txt" ]] ; then
2229
exit 1
2330
fi
2431
exit 0

0 commit comments

Comments
 (0)