FLUME-1504: Test file channel times out randomly (Hari Shreedharan 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/de5cb138 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/de5cb138 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/de5cb138 Branch: refs/heads/cdh-1.2.0+24_intuit Commit: de5cb138af20febc34820d13ee839da0b72580fc Parents: 2a98ebd Author: Brock Noland <[email protected]> Authored: Wed Aug 22 13:19:54 2012 -0500 Committer: Mike Percy <[email protected]> Committed: Fri Sep 7 14:03:05 2012 -0700 ---------------------------------------------------------------------- .../apache/flume/channel/file/TestFileChannel.java | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/de5cb138/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java ---------------------------------------------------------------------- diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java index 720fa27..3dededf 100644 --- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java +++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java @@ -791,7 +791,9 @@ public class TestFileChannel { */ @Test public void testTakeTransactionCrossingCheckpoint() throws Exception { - channel = createFileChannel(); + Map<String, String> overrides = Maps.newHashMap(); + overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL, "10000"); + channel = createFileChannel(overrides); channel.start(); Assert.assertTrue(channel.isOpen()); List<String> in = Lists.newArrayList(); @@ -822,7 +824,7 @@ public class TestFileChannel { tx.commit(); tx.close(); channel.stop(); - channel = createFileChannel(); + channel = createFileChannel(overrides); channel.start(); Assert.assertTrue(channel.isOpen()); // we should not geet the item we took of the queue above @@ -852,6 +854,7 @@ public class TestFileChannel { Set<String> set = Sets.newHashSet(); Map<String, String> overrides = Maps.newHashMap(); overrides.put(FileChannelConfiguration.CAPACITY, String.valueOf(2)); + overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL, "10000"); FileChannel channel = createFileChannel(overrides); channel.start(); //Force a checkpoint by committing a transaction @@ -899,6 +902,7 @@ public class TestFileChannel { Set<String> set = Sets.newHashSet(); Map<String, String> overrides = Maps.newHashMap(); overrides.put(FileChannelConfiguration.CAPACITY, String.valueOf(2)); + overrides.put(FileChannelConfiguration.CHECKPOINT_INTERVAL, "10000"); FileChannel channel = createFileChannel(overrides); channel.start(); //Force a checkpoint by committing a transaction @@ -916,7 +920,7 @@ public class TestFileChannel { long t1 = System.currentTimeMillis(); while (checkpoint.lastModified() < t1) { TimeUnit.MILLISECONDS.sleep(500); - if(t1 - checkpoint.lastModified() > 15000){ + if(System.currentTimeMillis() - checkpoint.lastModified() > 15000){ throw new TimeoutException("Checkpoint was expected," + " but did not happen"); }
