OOZIE-1986 addendum fixes

Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/7e7bdc5b
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/7e7bdc5b
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/7e7bdc5b

Branch: refs/heads/oya
Commit: 7e7bdc5bec131c37b8fa2898052639f039008ea5
Parents: 1bf91be
Author: Robert Kanter <[email protected]>
Authored: Wed Oct 26 10:44:47 2016 -0700
Committer: Robert Kanter <[email protected]>
Committed: Wed Oct 26 10:44:47 2016 -0700

----------------------------------------------------------------------
 bin/findbugs-diff-0.1.0-all.jar.md5             |  1 +
 bin/test-patch-11-findbugs-diff                 | 63 ++++++++++++++++++--
 ...est-patch-11-findbugs-diff-0.1.0-all.jar.md5 |  1 -
 pom.xml                                         |  2 +-
 4 files changed, 59 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/7e7bdc5b/bin/findbugs-diff-0.1.0-all.jar.md5
----------------------------------------------------------------------
diff --git a/bin/findbugs-diff-0.1.0-all.jar.md5 
b/bin/findbugs-diff-0.1.0-all.jar.md5
new file mode 100644
index 0000000..28179b6
--- /dev/null
+++ b/bin/findbugs-diff-0.1.0-all.jar.md5
@@ -0,0 +1 @@
+d965fab3dbf678189924ad6d61fc7a3d

http://git-wip-us.apache.org/repos/asf/oozie/blob/7e7bdc5b/bin/test-patch-11-findbugs-diff
----------------------------------------------------------------------
diff --git a/bin/test-patch-11-findbugs-diff b/bin/test-patch-11-findbugs-diff
index 0376ab0..e8bfb3b 100755
--- a/bin/test-patch-11-findbugs-diff
+++ b/bin/test-patch-11-findbugs-diff
@@ -107,14 +107,15 @@ verify_and_save_findbugs_output() {
   REPORT_SUFFIX=$3
 
   echo "[TRACE] Verifying and saving FindBugs output in ${BRANCH_LABEL}"
+  echo "[TRACE] mvn clean verify -DskipTests ${MVNPASSTHRU} | tee 
${REPORTDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt >> ${STDOUT}"
 
-  mvn clean verify -DskipTests "${MVNPASSTHRU}" | tee 
"${REPORTDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" >> ${STDOUT}
+  mvn clean verify -DskipTests ${MVNPASSTHRU} | tee 
${REPORTDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt >> ${STDOUT}
 
   if [ ! -d "$FINDBUGS_OUTPUT_DIR" ]; then
     mkdir -p "${FINDBUGS_OUTPUT_DIR}"
   fi
 
-  find . -name ${FINDBUGS_XML_NAME} -exec rsync -avqR {} 
"${FINDBUGS_OUTPUT_DIR}" ";"
+  find . -name ${FINDBUGS_XML_NAME} ! -path '*/test-patch/*' -exec rsync -avqR 
{} "${FINDBUGS_OUTPUT_DIR}" ";"
 
   if [ "$(ls -A "${FINDBUGS_OUTPUT_DIR}")" ] ; then
     echo "{color:green}+1{color} ${BRANCH_LABEL} produces FindBugs output" >> 
"${TEMPDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt"
@@ -126,6 +127,41 @@ verify_and_save_findbugs_output() {
 }
 
 
+create_missing_findbugs_files() {
+  PRE_DIR=$1
+  POST_DIR=$2
+
+  create_missing_xml ${PRE_DIR} "pre" "post"
+  create_missing_xml ${POST_DIR} "post" "pre"
+}
+
+create_missing_xml() {
+  sourceFolder=$1
+  sourcePart=$2
+  targetPart=$3
+
+  sourceXmlFiles=()
+  while IFS= read -r -d '' fn; do
+    sourceXmlFiles+=(${fn})
+  done <   <(find "${sourceFolder}" -name ${FINDBUGS_XML_NAME} -print0)
+
+  for index in "${!sourceXmlFiles[@]}"; do
+    targetXmlFile=${sourceXmlFiles[index]/${sourcePart}/${targetPart}}
+    targetFolder=${targetXmlFile%${FINDBUGS_XML_NAME}}
+
+    if [ ! -d ${targetFolder} ]; then
+      echo "[TRACE] Folder [${targetFolder}] does not exist, creating"
+      mkdir -p "${targetFolder}"
+    fi
+
+    if [ ! -f ${targetXmlFile} ]; then
+      echo "[TRACE] XML file [${targetXmlFile}] does not exist, creating"
+      echo "<BugCollection />" > "${targetXmlFile}"
+    fi
+  done
+}
+
+
 download_and_check_findbugs_diff_jar() {
   DIFF_DIR=$1
   BASH_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -148,7 +184,7 @@ download_and_check_findbugs_diff_jar() {
     cleanup_and_exit 1
   fi
 
-  jarMd5DiffCount=$(grep -Fxvf "${BASH_DIR}/test-patch-11-${FINDBUGS_JAR}.md5" 
"${DIFF_DIR}/${FINDBUGS_JAR}.md5" | wc -l)
+  jarMd5DiffCount=$(grep -Fxvf "${BASH_DIR}/${FINDBUGS_JAR}.md5" 
"${DIFF_DIR}/${FINDBUGS_JAR}.md5" | wc -l)
 
   if [ ${jarMd5DiffCount} -gt "0" ]; then
     echo "[ERROR] FindBugs diff JAR has a weird MD5 sum, rejecting"
@@ -168,7 +204,7 @@ perform_findbugs_diffs() {
 
   echo "[TRACE] Performing FindBugs diffs"
 
-  preFindbugsDiffs=()
+  sourceXmlFiles=()
   while IFS= read -r -d '' fn; do
     preFindbugsDiffs+=(${fn})
   done <   <(find "${PRE_DIR}" -name ${FINDBUGS_XML_NAME} -print0)
@@ -184,14 +220,28 @@ perform_findbugs_diffs() {
     diffDirPostfix=${diffDirPostfix:18}
     diffDirPostfix=${diffDirPostfix%%/target/findbugs/findbugsXml.xml}
 
-    java -jar -Dorg.slf4j.simpleLogger.defaultLogLevel=ERROR 
"${DIFF_DIR}/${FINDBUGS_JAR}" \
-        --outDir="${DIFF_DIR}/${diffDirPostfix}" "${preFindbugsDiffs[index]}" 
"${postFindbugsDiffs[index]}"
+    check_minimum_file_size ${preFindbugsDiffs[index]}
+    check_minimum_file_size ${postFindbugsDiffs[index]}
+
+    java -jar -Dorg.slf4j.simpleLogger.defaultLogLevel=ERROR 
${DIFF_DIR}/${FINDBUGS_JAR} --outDir=${DIFF_DIR}/${diffDirPostfix} 
${preFindbugsDiffs[index]} ${postFindbugsDiffs[index]}
   done
 
   echo "[TRACE] FindBugs diffs performed"
 }
 
 
+check_minimum_file_size() {
+  FILE_NAME=$1
+
+  actualSize=$(wc -c < "${FILE_NAME}")
+  minimumSize=10
+  if [ ${actualSize} -le ${minimumSize} ]; then
+    echo "[ERROR] File [${FILE_NAME}] is below minimum size (has only 
[${actualSize}] bytes), cannot perform FindBugs diff"
+    cleanup_and_exit 1
+  fi
+}
+
+
 check_findbugs_diffs_and_create_reports() {
   DIFF_DIR=$1
   REPORT=()
@@ -265,6 +315,7 @@ case ${OP} in
     verify_and_save_findbugs_output "${TEMPDIR}/${TASKNAME}/post" PATCH patch
     ;;
   report)
+    create_missing_findbugs_files "${TEMPDIR}/${TASKNAME}/pre" 
"${TEMPDIR}/${TASKNAME}/post"
     download_and_check_findbugs_diff_jar "${TEMPDIR}/${TASKNAME}/diff"
     perform_findbugs_diffs "${TEMPDIR}/${TASKNAME}/pre" 
"${TEMPDIR}/${TASKNAME}/post" "${TEMPDIR}/${TASKNAME}/diff"
     check_findbugs_diffs_and_create_reports "${TEMPDIR}/${TASKNAME}/diff"

http://git-wip-us.apache.org/repos/asf/oozie/blob/7e7bdc5b/bin/test-patch-11-findbugs-diff-0.1.0-all.jar.md5
----------------------------------------------------------------------
diff --git a/bin/test-patch-11-findbugs-diff-0.1.0-all.jar.md5 
b/bin/test-patch-11-findbugs-diff-0.1.0-all.jar.md5
deleted file mode 100644
index 28179b6..0000000
--- a/bin/test-patch-11-findbugs-diff-0.1.0-all.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-d965fab3dbf678189924ad6d61fc7a3d

http://git-wip-us.apache.org/repos/asf/oozie/blob/7e7bdc5b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ade1f25..a3db3da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1866,7 +1866,7 @@
                         <exclude>**/.idea/**</exclude>
                         <exclude>*.patch</exclude>
                         <exclude>**/*.json</exclude>
-                        <exclude>bin/test-patch-*</exclude>
+                        <exclude>bin/*</exclude>
                     </excludes>
                 </configuration>
             </plugin>

Reply via email to