You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2019/04/03 20:51:01 UTC

[kudu] 02/04: build: enable Java flaky test reporting

This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 8532311f2739de0ebcfa68666f6a2d7ece3ef226
Author: Mike Percy <mp...@apache.org>
AuthorDate: Wed Dec 5 21:39:50 2018 -0800

    build: enable Java flaky test reporting
    
    This patch moves flaky test environment setup out of report-test.sh and
    into build-and-test.sh so that those environment variables can be
    inherited by the Java build environment. That change enables flaky test
    reporting for Java tests.
    
    This was tested in a RHEL6 DEBUG build environment. Example:
    
    http://dist-test.cloudera.org:8080/test_drilldown?test_name=testHiveMetastoreIntegration%28org.apache.kudu.test.TestMiniKuduCluster%29
    
    Change-Id: Ifef74fc9bf5453105c267418fa24daf4c33f73f3
    Reviewed-on: http://gerrit.cloudera.org:8080/12043
    Tested-by: Kudu Jenkins
    Reviewed-by: Grant Henke <gr...@apache.org>
---
 build-support/jenkins/build-and-test.sh | 34 ++++++++++++++++++++++
 build-support/report-test.sh            | 51 ++++++++++++---------------------
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/build-support/jenkins/build-and-test.sh b/build-support/jenkins/build-and-test.sh
index 9c0c956..23b20e4 100755
--- a/build-support/jenkins/build-and-test.sh
+++ b/build-support/jenkins/build-and-test.sh
@@ -74,6 +74,9 @@
 #
 #   ERROR_ON_TEST_FAILURE    Default: 1
 #     Whether test failures will cause this script to return an error.
+#
+#   KUDU_REPORT_TEST_RESULTS Default: 0
+#     If non-zero, tests are reported to the central test server.
 
 # If a commit messages contains a line that says 'DONT_BUILD', exit
 # immediately.
@@ -292,6 +295,37 @@ $CMAKE
 mkdir -p Testing/Temporary
 mkdir -p $TEST_LOGDIR
 
+if [ -n "$KUDU_REPORT_TEST_RESULTS" ] && [ "$KUDU_REPORT_TEST_RESULTS" -ne 0 ]; then
+  # Export environment variables needed for flaky test reporting.
+  #
+  # The actual reporting happens in the test runners themselves.
+
+  # On Jenkins, we'll have this variable set. Otherwise,
+  # report the build tag as non-jenkins.
+  export BUILD_TAG=${BUILD_TAG:-non-jenkins}
+
+  # Figure out the current git revision, and append a "-dirty" tag if it's
+  # not a pristine checkout.
+  GIT_REVISION=$(cd $SOURCE_ROOT && git rev-parse HEAD)
+  if ! ( cd $SOURCE_ROOT && git diff --quiet .  && git diff --cached --quiet . ) ; then
+    GIT_REVISION="${GIT_REVISION}-dirty"
+  fi
+  export GIT_REVISION
+
+  # Parse out our "build config" - a space-separated list of tags
+  # which include the cmake build type as well as the list of configured
+  # sanitizers.
+
+  # Define BUILD_CONFIG for flaky test reporting.
+  BUILD_CONFIG="$CMAKE_BUILD"
+  if [ "$BUILD_TYPE" = "ASAN" ]; then
+    BUILD_CONFIG="$BUILD_CONFIG asan ubsan"
+  elif [ "$BUILD_TYPE" = "TSAN" ]; then
+    BUILD_CONFIG="$BUILD_CONFIG tsan"
+  fi
+  export BUILD_CONFIG
+fi
+
 # Short circuit for LINT builds.
 if [ "$BUILD_TYPE" = "LINT" ]; then
   make lint | tee $TEST_LOGDIR/lint.log
diff --git a/build-support/report-test.sh b/build-support/report-test.sh
index 41351d2..e283c0b 100755
--- a/build-support/report-test.sh
+++ b/build-support/report-test.sh
@@ -24,10 +24,24 @@
 #
 # Note that this may exit with a non-zero code if the network is flaky or the
 # test result server is down.
+#
+# Expects BUILD_TAG, GIT_REVISION, and BUILD_CONFIG environment variables to be set.
 
 set -e
 
-ROOT=$(dirname $BASH_SOURCE)/..
+# Verify required environment variables.
+if [ -z "$BUILD_TAG" ]; then
+  echo "BUILD_TAG environment variable must be set"
+  exit 1
+fi
+if [ -z "$GIT_REVISION" ]; then
+  echo "GIT_REVISION environment variable must be set"
+  exit 1
+fi
+if [ -z "$BUILD_CONFIG" ]; then
+  echo "BUILD_CONFIG environment variable must be set"
+  exit 1
+fi
 
 # Verify and parse command line and options
 if [ $# -ne 3 ]; then
@@ -43,35 +57,6 @@ STATUS=$3
 TEST_RESULT_SERVER=${TEST_RESULT_SERVER:-localhost:8080}
 REPORT_TIMEOUT=${REPORT_TIMEOUT:-10}
 
-# On Jenkins, we'll have this variable set. Otherwise,
-# report the build ID as non-jenkins.
-BUILD_ID=${BUILD_TAG:-non-jenkins}
-
-# Figure out the current git revision, and append a "-dirty" tag if it's
-# not a pristine checkout
-REVISION=$(cd $ROOT && git rev-parse HEAD)
-if ! ( cd $ROOT && git diff --quiet .  && git diff --cached --quiet . ) ; then
-  REVISION="${REVISION}-dirty"
-fi
-
-BUILD_ROOT=$(dirname $TEST_EXECUTABLE)/..
-
-# Parse out our "build config" - a space-separated list of tags
-# which include the cmake build type as well as the list of configured
-# sanitizers
-
-CMAKECACHE=$BUILD_ROOT/CMakeCache.txt
-BUILD_CONFIG=$(grep '^CMAKE_BUILD_TYPE:' $CMAKECACHE | cut -f 2 -d=)
-if grep -q "KUDU_USE_ASAN:UNINITIALIZED=1" $CMAKECACHE ; then
-  BUILD_CONFIG="$BUILD_CONFIG asan"
-fi
-if grep -q "KUDU_USE_TSAN:UNINITIALIZED=1" $CMAKECACHE ; then
-  BUILD_CONFIG="$BUILD_CONFIG tsan"
-fi
-if grep -q "KUDU_USE_UBSAN:UNINITIALIZED=1" $CMAKECACHE ; then
-  BUILD_CONFIG="$BUILD_CONFIG ubsan"
-fi
-
 # We sometimes have flaky infrastructure where NTP is broken. In that case
 # do not report it as a failed test.
 if zgrep -q 'Clock considered unsynchronized' $LOGFILE ; then
@@ -88,13 +73,15 @@ else
   LOG_PARAM=""
 fi
 
+# In the backend, the BUILD_TAG field is called 'build_id', but we can't use
+# that as an env variable because it'd collide with Jenkins' BUILD_ID.
 curl -s \
     --max-time $REPORT_TIMEOUT \
     $LOG_PARAM \
-    -F "build_id=$BUILD_ID" \
+    -F "build_id=$BUILD_TAG" \
     -F "hostname=$(hostname)" \
     -F "test_name=$(basename $TEST_EXECUTABLE)" \
     -F "status=$STATUS" \
-    -F "revision=$REVISION" \
+    -F "revision=$GIT_REVISION" \
     -F "build_config=$BUILD_CONFIG" \
     http://$TEST_RESULT_SERVER/add_result