Repository: flume Updated Branches: refs/heads/trunk 2ef2055d4 -> 0c5b87a5d
FLUME-1920. Remove Hadoop dependency from integration tests The file channel no longer actually depends on Hadoop, and this test was exhibiting failures when Flume is built from paths containing the string "hadoop". Since hadoop is not required for any of these tests, the straightforward thing to do was to remove the now unnecessary Hadoop JAR detection code completely. (Li Xiang via Mike Percy) Project: http://git-wip-us.apache.org/repos/asf/flume/repo Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/0c5b87a5 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/0c5b87a5 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/0c5b87a5 Branch: refs/heads/trunk Commit: 0c5b87a5dfd53bcdcf8e2d8c570735573cd274ad Parents: 2ef2055 Author: Mike Percy <[email protected]> Authored: Wed Aug 6 11:55:19 2014 -0700 Committer: Mike Percy <[email protected]> Committed: Wed Aug 6 11:55:19 2014 -0700 ---------------------------------------------------------------------- .../flume/test/agent/TestFileChannel.java | 41 -------------------- .../apache/flume/test/util/StagedInstall.java | 9 ----- 2 files changed, 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/0c5b87a5/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestFileChannel.java ---------------------------------------------------------------------- diff --git a/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestFileChannel.java b/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestFileChannel.java index 2feb506..4a80b8c 100644 --- a/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestFileChannel.java +++ b/flume-ng-tests/src/test/java/org/apache/flume/test/agent/TestFileChannel.java @@ -122,18 +122,10 @@ public class TestFileChannel { public void testInOut() throws Exception { LOGGER.debug("testInOut() started."); - /* Find hadoop jar and append it to the flume agent's classpath */ - - String hadoopJarPath = findHadoopJar(); - Assert.assertNotNull("Hadoop jar not found in classpath.", - hadoopJarPath); - StagedInstall.getInstance().setAgentClasspath(hadoopJarPath); StagedInstall.getInstance().startAgent("a1", agentProps); TimeUnit.SECONDS.sleep(10); // Wait for source and sink to finish // TODO make this more deterministic - LOGGER.info("Started flume agent with hadoop in classpath"); - /* Create expected output */ StringBuffer sb = new StringBuffer(); @@ -161,37 +153,4 @@ public class TestFileChannel { LOGGER.debug("testInOut() ended."); } - /** - * Search for and return the first path element found that includes hadoop. - * We search the class path of the current JVM process to grab the same - * hadoop jar that's depended on by the file channel. - * - * TODO Add all deps of hadoop jar to classpath - * - * @return path to the first hadoop jar found, null if not found - */ - private String findHadoopJar() { - //Grab classpath - String classpath = System.getProperty("java.class.path"); - String trimmedClasspath = classpath.trim(); - - //parse classpath into path elements - Iterable<String> pathElements = Splitter.on(Pattern.compile("[;:]")) - .omitEmptyStrings() - .trimResults() - .split(trimmedClasspath); - - //find the first path element that includes the hadoop jar - for (String pathElement : pathElements) { - if (Pattern.compile("(?i)hadoop").matcher(pathElement).find()) { - return pathElement; - } - } - - LOGGER.error("Hadoop not found in classpath: |" + classpath - + "|"); - - return null; - } - } http://git-wip-us.apache.org/repos/asf/flume/blob/0c5b87a5/flume-ng-tests/src/test/java/org/apache/flume/test/util/StagedInstall.java ---------------------------------------------------------------------- diff --git a/flume-ng-tests/src/test/java/org/apache/flume/test/util/StagedInstall.java b/flume-ng-tests/src/test/java/org/apache/flume/test/util/StagedInstall.java index 336ffc4..a6bd5e9 100644 --- a/flume-ng-tests/src/test/java/org/apache/flume/test/util/StagedInstall.java +++ b/flume-ng-tests/src/test/java/org/apache/flume/test/util/StagedInstall.java @@ -70,7 +70,6 @@ public class StagedInstall { private Process process; private ProcessShutdownHook shutdownHook; private ProcessInputStreamConsumer consumer; - private String agentClasspath; private static StagedInstall INSTANCE; @@ -96,7 +95,6 @@ public class StagedInstall { consumer.interrupt(); consumer = null; configFilePath = null; - agentClasspath = null; Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; @@ -141,9 +139,6 @@ public class StagedInstall { builder.add(launchScriptPath); builder.add("agent"); builder.add("--conf", confDirPath); - if (agentClasspath != null) { - builder.add("--classpath", agentClasspath); - } builder.add("--conf-file", configFilePath); builder.add("--name", agentName); builder.add("-D" + ENV_FLUME_LOG_DIR + "=" + logDirPath); @@ -173,10 +168,6 @@ public class StagedInstall { Thread.sleep(3000); // sleep for 3s to let system initialize } - public synchronized void setAgentClasspath(String agentClasspath) { - this.agentClasspath = agentClasspath; - } - public synchronized void reconfigure(Properties properties) throws Exception { File configFile = createConfigurationFile(agentName, properties); Files.copy(configFile, new File(configFilePath));
