This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new f9b2c33d2 [build-and-test] TEST_TMPDIR default setting for Jenkins
f9b2c33d2 is described below
commit f9b2c33d2f2d8f6df848d28a157cac27340911c6
Author: Alexey Serbin <[email protected]>
AuthorDate: Tue Jan 7 11:59:53 2025 -0800
[build-and-test] TEST_TMPDIR default setting for Jenkins
In case of Jenkins builds, TEST_TMPDIR must be created per-build and
cleaned up upon exiting. This patch updates the default setting
for the TEST_TMPDIR in the context of a Jenkins job, and properly
cleans up the TEST_TMPDIR directory upon exit.
This is a follow-up to 8027299167f6f4f0fe586b6c70829054aae31dab.
Change-Id: Ie6115d68526d90f8ef627b7d340f2f11a4e3d3cc
Reviewed-on: http://gerrit.cloudera.org:8080/22308
Reviewed-by: Abhishek Chennaka <[email protected]>
Tested-by: Alexey Serbin <[email protected]>
---
build-support/jenkins/build-and-test.sh | 35 ++++++++++++++++++-------------
build-support/jenkins/post-build-clean.sh | 4 ++++
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/build-support/jenkins/build-and-test.sh
b/build-support/jenkins/build-and-test.sh
index 647275015..e459b9c7b 100755
--- a/build-support/jenkins/build-and-test.sh
+++ b/build-support/jenkins/build-and-test.sh
@@ -28,10 +28,16 @@
# Runs the "slow" version of the unit tests. Set to 0 to
# run the tests more quickly.
#
-# TEST_TMPDIR Default: /tmp/kudutest-$UID
-# Specifies the temporary directory where tests should write their
-# data. It is expected that following the completion of all tests, this
-# directory is empty (i.e. every test cleaned up after itself).
+# TEST_TMPDIR Default: /tmp/$BUILD_TAG if BUILD_TAG is defined (Jenkins),
+# /tmp/kudutest-$UID otherwise
+# Specifies the temporary directory where tests should write their data
+# and logs. It is expected that following successful completion
+# (i.e. no failures) of all the tests, this directory is empty: every
+# successfully completed test cleans up after itself. Failed tests leave
+# relevant data and logs in the temporary directory upon exit: that's for
+# post-mortem troubleshooting and debugging. In case of Jenkins builds
+# (i.e. when the BUILD_TAG environment variable is defined),
+# the whole TEST_TMPDIR directory is removed when this script exists.
#
# RUN_FLAKY_ONLY Default: 0
# Only runs tests which have failed recently, if this is 1.
@@ -155,7 +161,12 @@ BUILD_ROOT=$SOURCE_ROOT/build/$BUILD_TYPE_LOWER
export KUDU_FLAKY_TEST_ATTEMPTS=${KUDU_FLAKY_TEST_ATTEMPTS:-1}
export
KUDU_ALLOW_SLOW_TESTS=${KUDU_ALLOW_SLOW_TESTS:-$DEFAULT_ALLOW_SLOW_TESTS}
export KUDU_COMPRESS_TEST_OUTPUT=${KUDU_COMPRESS_TEST_OUTPUT:-1}
-export TEST_TMPDIR=${TEST_TMPDIR:-/tmp/kudutest-$UID}
+if [ -n "$BUILD_TAG" ]; then
+ export TEST_TMPDIR=${TEST_TMPDIR:-/tmp/$BUILD_TAG}
+else
+ export TEST_TMPDIR=${TEST_TMPDIR:-/tmp/kudutest-$UID}
+fi
+export CLEANUP_TEST_TMPDIR=${CLEANUP_TEST_TMPDIR:-0}
export PARALLEL=${PARALLEL:-$(getconf _NPROCESSORS_ONLN)}
export PARALLEL_TESTS=${PARALLEL_TESTS:-$PARALLEL}
export THIRDPARTY_DIR=${THIRDPARTY_DIR:-$SOURCE_ROOT/thirdparty}
@@ -197,12 +208,13 @@ TEST_LOGDIR="$BUILD_ROOT/test-logs"
TEST_DEBUGDIR="$BUILD_ROOT/test-debug"
cleanup() {
- echo Cleaning up all build artifacts...
+ echo Cleaning up all build artifacts and temporary data...
$SOURCE_ROOT/build-support/jenkins/post-build-clean.sh
}
-# If we're running inside Jenkins (the BUILD_ID is set), then install
-# an exit handler which will clean up all of our build results.
-if [ -n "$BUILD_ID" ]; then
+# If we're running inside Jenkins (the BUILD_TAG is set), then install
+# an exit handler which will clean up all of our build results and temporary
+# data.
+if [ -n "$BUILD_TAG" ]; then
trap cleanup EXIT
fi
@@ -479,11 +491,6 @@ if [ "$BUILD_TYPE" != "ASAN" ]; then
export KUDU_TEST_ULIMIT_CORE=unlimited
fi
-# our tests leave lots of data lying around, clean up before we run
-if [ -d "$TEST_TMPDIR" ]; then
- rm -Rf $TEST_TMPDIR
-fi
-
# actually do the build
echo
echo Building C++ code.
diff --git a/build-support/jenkins/post-build-clean.sh
b/build-support/jenkins/post-build-clean.sh
index 385e4d94d..17f59ffc6 100755
--- a/build-support/jenkins/post-build-clean.sh
+++ b/build-support/jenkins/post-build-clean.sh
@@ -27,6 +27,10 @@
ROOT=$(cd $(dirname "$BASH_SOURCE")/../..; pwd)
cd $ROOT
+# Clean up TEST_TMPDIR: this cleanup script is supposed to run only in the
+# context of Jenkins jobs, where each job has its own TEST_TMPDIR.
+rm -Rf $TEST_TMPDIR
+
# Note that we use simple shell commands instead of "make clean"
# or "gradle clean". This is more foolproof even if something ends
# up partially compiling, etc.