Repository: flume Updated Branches: refs/heads/trunk fca8c5b97 -> 27c725802
FLUME-3003. Fix flaky testSourceCounter in TestSyslogUdpSource The event processing in SyslogUDPSource is handled on a separate thread by Netty so message delivery, thus the sourceCounter's increment can be delayed resulting in a flaky test. This patch fixes that issue by adding more delay when necessary. Reviewers: Lior Zeno, Bessenyei Balázs Donát (Denes Arvay via Bessenyei Balázs Donát) Project: http://git-wip-us.apache.org/repos/asf/flume/repo Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/27c72580 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/27c72580 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/27c72580 Branch: refs/heads/trunk Commit: 27c725802b16915acaa3ea05cdac0236972af1f0 Parents: fca8c5b Author: Denes Arvay <[email protected]> Authored: Fri Oct 7 11:49:27 2016 +0200 Committer: Bessenyei Balázs Donát <[email protected]> Committed: Fri Oct 7 12:08:37 2016 +0200 ---------------------------------------------------------------------- .../java/org/apache/flume/source/TestSyslogUdpSource.java | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/27c72580/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java ---------------------------------------------------------------------- diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java b/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java index 6ba7512..cb3860d 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java +++ b/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java @@ -195,6 +195,13 @@ public class TestSyslogUdpSource { channel.take(); commitAndCloseTransaction(txn); + // Retrying up to 10 times while the acceptedCount == 0 because the event processing in + // SyslogUDPSource is handled on a separate thread by Netty so message delivery, + // thus the sourceCounter's increment can be delayed resulting in a flaky test + for (int i = 0; i < 10 && source.getSourceCounter().getEventAcceptedCount() == 0; i++) { + Thread.sleep(100); + } + Assert.assertEquals(1, source.getSourceCounter().getEventAcceptedCount()); Assert.assertEquals(1, source.getSourceCounter().getEventReceivedCount()); }
