From 322ed8ce4d8729ad5230a65913b27f7285578a1e Mon Sep 17 00:00:00 2001 From: Kevin Risden Date: Wed, 11 Dec 2019 22:40:22 -0500 Subject: [PATCH] SOLR-14047: Make sure tests don't pickup other Hadoop installs Signed-off-by: Kevin Risden --- solr/CHANGES.txt | 3 ++- .../org/apache/solr/cloud/hdfs/HdfsTestUtil.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 04f6eacbcf3..0e26813aeab 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -123,7 +123,8 @@ Bug Fixes Other Changes --------------------- -(No changes) + +SOLR-14047: Make sure tests don't pickup other Hadoop installs (Kevin Risden) ================== 8.4.0 ================== diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java index c86db8b5e5f..2afee3598c6 100644 --- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java +++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java @@ -74,11 +74,27 @@ public class HdfsTestUtil { } public static void checkAssumptions() { + ensureHadoopHomeNotSet(); checkHadoopWindows(); checkFastDateFormat(); checkGeneratedIdMatches(); } + /** + * If Hadoop home is set via environment variable HADOOP_HOME or Java system property + * hadoop.home.dir, the behavior of test is undefined. Ensure that these are not set + * before starting. It is not possible to easily unset environment variables so better + * to bail out early instead of trying to test. + */ + private static void ensureHadoopHomeNotSet() { + if (System.getenv("HADOOP_HOME") != null) { + LuceneTestCase.fail("Ensure that HADOOP_HOME environment variable is not set."); + } + if (System.getProperty("hadoop.home.dir") != null) { + LuceneTestCase.fail("Ensure that \"hadoop.home.dir\" Java property is not set."); + } + } + /** * Hadoop integration tests fail on Windows without Hadoop NativeIO */