You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2015/05/28 04:03:56 UTC

[4/6] accumulo git commit: ACCUMULO-3858 Attempt to stabilize WatchTheWatchCountIT

ACCUMULO-3858 Attempt to stabilize WatchTheWatchCountIT

Add some repeated attempts and expand the range to encompass
values I have seen running the test many times.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/98fbe4f1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/98fbe4f1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/98fbe4f1

Branch: refs/heads/1.7
Commit: 98fbe4f14ce51032504989af439e12bc95884626
Parents: bd759af
Author: Josh Elser <el...@apache.org>
Authored: Wed May 27 19:14:51 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Wed May 27 21:18:54 2015 -0400

----------------------------------------------------------------------
 .../test/functional/WatchTheWatchCountIT.java   | 47 ++++++++++++++------
 1 file changed, 33 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/98fbe4f1/test/src/test/java/org/apache/accumulo/test/functional/WatchTheWatchCountIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/WatchTheWatchCountIT.java b/test/src/test/java/org/apache/accumulo/test/functional/WatchTheWatchCountIT.java
index 3b1dd2f..fff5b16 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/WatchTheWatchCountIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/WatchTheWatchCountIT.java
@@ -24,38 +24,57 @@ import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 import org.apache.hadoop.conf.Configuration;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Range;
 import com.google.common.net.HostAndPort;
 
 // ACCUMULO-2757 - make sure we don't make too many more watchers
 public class WatchTheWatchCountIT extends ConfigurableMacIT {
+  private static final Logger log = LoggerFactory.getLogger(WatchTheWatchCountIT.class);
+
+  public int defaultOverrideSeconds() {
+    return 60;
+  }
 
   @Override
   public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
     cfg.setNumTservers(3);
   }
 
-  @Test(timeout = 30 * 1000)
+  @Test
   public void test() throws Exception {
     Connector c = getConnector();
-    for (String tableName : this.getUniqueNames(3)) {
+    String[] tableNames = getUniqueNames(3);
+    for (String tableName : tableNames) {
       c.tableOperations().create(tableName);
     }
     c.tableOperations().list();
     String zooKeepers = c.getInstance().getZooKeepers();
-    HostAndPort hostAndPort = HostAndPort.fromString(zooKeepers);
-    Socket socket = new Socket(hostAndPort.getHostText(), hostAndPort.getPort());
-    try {
-      socket.getOutputStream().write("wchs\n".getBytes(), 0, 5);
-      byte[] buffer = new byte[1024];
-      int n = socket.getInputStream().read(buffer);
-      String response = new String(buffer, 0, n);
-      long total = Long.parseLong(response.split(":")[1].trim());
-      assertTrue("Total watches was not greater than 500, but was " + total, total > 500);
-      assertTrue("Total watches was not less than 650, but was " + total, total < 600);
-    } finally {
-      socket.close();
+    final Range<Long> expectedWatcherRange = Range.open(475l, 700l);
+    long total = 0;
+    final HostAndPort hostAndPort = HostAndPort.fromString(zooKeepers);
+    for (int i = 0; i < 5; i++) {
+      Socket socket = new Socket(hostAndPort.getHostText(), hostAndPort.getPort());
+      try {
+        socket.getOutputStream().write("wchs\n".getBytes(), 0, 5);
+        byte[] buffer = new byte[1024];
+        int n = socket.getInputStream().read(buffer);
+        String response = new String(buffer, 0, n);
+        total = Long.parseLong(response.split(":")[1].trim());
+        log.info("Total: {}", total);
+        if (expectedWatcherRange.contains(total)) {
+          break;
+        }
+        log.debug("Expected number of watchers to be contained in {}, but actually was {}. Sleeping and retrying", expectedWatcherRange, total);
+        Thread.sleep(5000);
+      } finally {
+        socket.close();
+      }
     }
+
+    assertTrue("Expected number of watchers to be contained in " + expectedWatcherRange + ", but actually was " + total, expectedWatcherRange.contains(total));
   }
 
 }