flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject git commit: FLUME-1730: HDFSEventSink testCloseOnIdle appears to be racy
Date Wed, 21 Nov 2012 16:17:41 GMT
Updated Branches:
  refs/heads/flume-1.3.0 b43824a0f -> 54330dcc6


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/54330dcc
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/54330dcc
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/54330dcc

Branch: refs/heads/flume-1.3.0
Commit: 54330dcc62aa91d8c4d27dbf7135d9972ac7af84
Parents: b43824a
Author: Brock Noland <brock@apache.org>
Authored: Wed Nov 21 09:57:24 2012 -0600
Committer: Brock Noland <brock@apache.org>
Committed: Wed Nov 21 09:57:44 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/54330dcc/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();


Mime
View raw message