Skip to content

Commit 9fd7a2f

Browse files
committed
[SPARK-10359][PROJECT-INFRA] Use more random number in dev/test-dependencies.sh; fix version switching
This patch aims to fix another potential source of flakiness in the `dev/test-dependencies.sh` script. pwendell's original patch and my version used `$(date +%s | tail -c6)` to generate a suffix to use when installing temporary Spark versions into the local Maven cache, but this value only changes once per second and thus is highly collision-prone when concurrent builds launch on AMPLab Jenkins. In order to reduce the potential for conflicts, this patch updates the script to call Python's random number generator instead. I also fixed a bug in how we captured the original project version; the bug was causing the exit handler code to fail. Author: Josh Rosen <joshrosen@databricks.com> Closes apache#10558 from JoshRosen/build-dep-tests-round-3.
1 parent 0d165ec commit 9fd7a2f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

dev/run-tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ def run_python_tests(test_modules, parallelism):
419419

420420

421421
def run_build_tests():
422-
# set_title_and_block("Running build tests", "BLOCK_BUILD_TESTS")
423-
# run_cmd([os.path.join(SPARK_HOME, "dev", "test-dependencies.sh")])
422+
set_title_and_block("Running build tests", "BLOCK_BUILD_TESTS")
423+
run_cmd([os.path.join(SPARK_HOME, "dev", "test-dependencies.sh")])
424424
pass
425425

426426

dev/test-dependencies.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,19 @@ HADOOP_PROFILES=(
4242
# the old version. We need to do this because the `dependency:build-classpath` task needs to
4343
# resolve Spark's internal submodule dependencies.
4444

45-
# See http://stackoverflow.com/a/3545363 for an explanation of this one-liner:
46-
OLD_VERSION=$($MVN help:evaluate -Dexpression=project.version|grep -Ev '(^\[|Download\w+:)')
47-
TEMP_VERSION="spark-$(date +%s | tail -c6)"
45+
# From http://stackoverflow.com/a/26514030
46+
set +e
47+
OLD_VERSION=$($MVN -q \
48+
-Dexec.executable="echo" \
49+
-Dexec.args='${project.version}' \
50+
--non-recursive \
51+
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
52+
if [ $? != 0 ]; then
53+
echo -e "Error while getting version string from Maven:\n$OLD_VERSION"
54+
exit 1
55+
fi
56+
set -e
57+
TEMP_VERSION="spark-$(python -S -c "import random; print(random.randrange(100000, 999999))")"
4858

4959
function reset_version {
5060
# Delete the temporary POMs that we wrote to the local Maven repo:

0 commit comments

Comments
 (0)