Updated Branches: refs/heads/flume-1.4 31043fb05 -> 90280e96d
FLUME-1730: HDFSEventSink testCloseOnIdle appears to be racy (Brock Noland via Brock Noland Project: http://git-wip-us.apache.org/repos/asf/flume/repo Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/90280e96 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/90280e96 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/90280e96 Branch: refs/heads/flume-1.4 Commit: 90280e96def00d4384ad851c88703b3ddc96a271 Parents: 31043fb Author: Brock Noland <[email protected]> Authored: Wed Nov 21 09:57:24 2012 -0600 Committer: Brock Noland <[email protected]> Committed: Wed Nov 21 09:57:40 2012 -0600 ---------------------------------------------------------------------- .../apache/flume/sink/hdfs/TestHDFSEventSink.java | 19 ++++++-------- 1 files changed, 8 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/90280e96/flume-ng-sinks/flume-hdfs-sink/src/test/java/org/apache/flume/sink/hdfs/TestHDFSEventSink.java ---------------------------------------------------------------------- diff --git a/flume-ng-sinks/flume-hdfs-sink/src/test/java/org/apache/flume/sink/hdfs/TestHDFSEventSink.java b/flume-ng-sinks/flume-hdfs-sink/src/test/java/org/apache/flume/sink/hdfs/TestHDFSEventSink.java index f93cfca..d23f09d 100644 --- a/flume-ng-sinks/flume-hdfs-sink/src/test/java/org/apache/flume/sink/hdfs/TestHDFSEventSink.java +++ b/flume-ng-sinks/flume-hdfs-sink/src/test/java/org/apache/flume/sink/hdfs/TestHDFSEventSink.java @@ -23,8 +23,10 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.charset.CharsetDecoder; +import java.util.Arrays; import java.util.Calendar; import java.util.List; +import java.util.UUID; import org.apache.avro.file.DataFileStream; import org.apache.avro.generic.GenericData; @@ -98,6 +100,7 @@ public class TestHDFSEventSink { + Thread.currentThread().getId(); sink = new HDFSEventSink(); + sink.setName("HDFSEventSink-" + UUID.randomUUID().toString()); dirCleanup(); } @@ -979,7 +982,6 @@ public class TestHDFSEventSink { LOG.debug("Starting..."); slowAppendTestHelper(0); } - @Test public void testCloseOnIdle() throws IOException, EventDeliveryException, InterruptedException { String hdfsPath = testPath + "/idleClose"; @@ -989,9 +991,12 @@ public class TestHDFSEventSink { Path dirPath = new Path(hdfsPath); fs.delete(dirPath, true); fs.mkdirs(dirPath); - sink = new HDFSEventSink(new HDFSWriterFactory()); Context context = new Context(); context.put("hdfs.path", hdfsPath); + /* + * All three rolling methods are disabled so the only + * way a file can roll is through the idle timeout. + */ context.put("hdfs.rollCount", "0"); context.put("hdfs.rollSize", "0"); context.put("hdfs.rollInterval", "0"); @@ -1028,18 +1033,10 @@ public class TestHDFSEventSink { Thread.sleep(500); // shouldn't be enough for a timeout to occur sink.process(); sink.process(); - + sink.stop(); FileStatus[] dirStat = fs.listStatus(dirPath); Path[] fList = FileUtil.stat2Paths(dirStat); Assert.assertEquals(2, fList.length); - // one should be tmp and the other not - Assert.assertTrue(fList[0].getName().endsWith(".tmp") ^ - fList[1].getName().endsWith(".tmp")); - - sink.stop(); - dirStat = fs.listStatus(dirPath); - fList = FileUtil.stat2Paths(dirStat); - Assert.assertEquals(2, fList.length); Assert.assertTrue(!fList[0].getName().endsWith(".tmp") && !fList[1].getName().endsWith(".tmp")); fs.close();
