You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by cr...@apache.org on 2013/10/08 21:59:13 UTC

git commit: SAMZA-54; fix sporadically failing test in blocking envelope map.

Updated Branches:
  refs/heads/master d5478c2a8 -> cb31cb1bf


SAMZA-54; fix sporadically failing test in blocking envelope map.


Project: http://git-wip-us.apache.org/repos/asf/incubator-samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-samza/commit/cb31cb1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/cb31cb1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/cb31cb1b

Branch: refs/heads/master
Commit: cb31cb1bf866f0eb3be35b6d4c59acbffcaaeba7
Parents: d5478c2
Author: Chris Riccomini <cr...@criccomi-ld.linkedin.biz>
Authored: Tue Oct 8 11:22:08 2013 -0700
Committer: Chris Riccomini <cr...@criccomi-ld.linkedin.biz>
Committed: Tue Oct 8 11:22:08 2013 -0700

----------------------------------------------------------------------
 .../samza/util/TestBlockingEnvelopeMap.java     | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/cb31cb1b/samza-api/src/test/java/org/apache/samza/util/TestBlockingEnvelopeMap.java
----------------------------------------------------------------------
diff --git a/samza-api/src/test/java/org/apache/samza/util/TestBlockingEnvelopeMap.java b/samza-api/src/test/java/org/apache/samza/util/TestBlockingEnvelopeMap.java
index 62152d0..e8c2e32 100644
--- a/samza-api/src/test/java/org/apache/samza/util/TestBlockingEnvelopeMap.java
+++ b/samza-api/src/test/java/org/apache/samza/util/TestBlockingEnvelopeMap.java
@@ -126,7 +126,17 @@ public class TestBlockingEnvelopeMap {
   @Test
   public void testShouldPollWithATimeout() throws InterruptedException {
     MockQueue q = new MockQueue();
-    final BlockingEnvelopeMap map = new MockBlockingEnvelopeMap(q);
+    // Always use the same time in this test so that we can be sure we get a
+    // 100ms poll, rather than a 99ms poll (for example). Have to do this
+    // because BlockingEnvelopeMap calls clock.currentTimeMillis twice, and
+    // uses the second call to determine the actual poll time.
+    final BlockingEnvelopeMap map = new MockBlockingEnvelopeMap(q, new Clock() {
+      private final long NOW = System.currentTimeMillis();
+
+      public long currentTimeMillis() {
+        return NOW;
+      }
+    });
 
     map.register(SSP, "0");
 
@@ -182,7 +192,15 @@ public class TestBlockingEnvelopeMap {
     }
 
     public MockBlockingEnvelopeMap(BlockingQueue<IncomingMessageEnvelope> injectedQueue) {
-      super();
+      this(injectedQueue, new Clock() {
+        public long currentTimeMillis() {
+          return System.currentTimeMillis();
+        }
+      });
+    }
+
+    public MockBlockingEnvelopeMap(BlockingQueue<IncomingMessageEnvelope> injectedQueue, Clock clock) {
+      super(new NoOpMetricsRegistry(), clock);
 
       this.injectedQueue = injectedQueue;
     }