accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [05/16] git commit: ACCUMULO-1936 Make testInstanceOperations a more reliable test.
Date Mon, 10 Mar 2014 22:16:02 GMT
ACCUMULO-1936 Make testInstanceOperations a more reliable test.

Avoid pulling scans for users other than root and compactions for
compactions over tables other than the one we're looking at. Slow down
the slow iterator even more.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 72395e010d3f495507d03664057a63c3d690a206
Parents: e13c273
Author: Josh Elser <elserj@apache.org>
Authored: Mon Mar 10 14:26:19 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Mar 10 14:27:54 2014 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/proxy/SimpleTest.java   | 110 +++++++++++++------
 1 file changed, 75 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/72395e01/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --git a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index 5573d20..77e7b9e 100644
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@ -90,6 +90,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
+import org.apache.log4j.Logger;
 import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TProtocolFactory;
 import org.apache.thrift.server.TServer;
@@ -102,7 +103,8 @@ import org.junit.rules.TemporaryFolder;
  * Call every method on the proxy and try to verify that it works.
  */
 public class SimpleTest {
-  
+  private static final Logger log = Logger.getLogger(SimpleTest.class);
+
   public static TemporaryFolder folder = new TemporaryFolder();
   
   public static final String TABLE_TEST = "test";
@@ -704,7 +706,7 @@ public class SimpleTest {
     assertEquals(0, entries.results.size());
   }
 
-  @Test(timeout = 10000)
+  @Test(timeout = 60000)
   public void testInstanceOperations() throws Exception {
     int tservers = 0;
     for (String tserver : client.getTabletServers(creds)) {
@@ -745,12 +747,14 @@ public class SimpleTest {
     
     // create a table that's very slow, so we can look for scans/compactions
     client.createTable(creds, "slow", true, TimeType.MILLIS);
-    IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(),
Collections.singletonMap("sleepTime", "200"));
+
+    // Should take 5 seconds to read every record
+    for (int i = 0; i < 20; i++) {
+      client.updateAndFlush(creds, "slow", mutation("row" + i, "cf", "cq", "value"));
+    }
+
+    IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(),
Collections.singletonMap("sleepTime", "250"));
     client.attachIterator(creds, "slow", setting, EnumSet.allOf(IteratorScope.class));
-    client.updateAndFlush(creds, "slow", mutation("row", "cf", "cq", "value"));
-    client.updateAndFlush(creds, "slow", mutation("row2", "cf", "cq", "value"));
-    client.updateAndFlush(creds, "slow", mutation("row3", "cf", "cq", "value"));
-    client.updateAndFlush(creds, "slow", mutation("row4", "cf", "cq", "value"));
     
     // scan
     Thread t = new Thread() {
@@ -768,28 +772,45 @@ public class SimpleTest {
       }
     };
     t.start();
+
     // look for the scan
-    List<ActiveScan> scans = Collections.emptyList();
-    loop: for (int i = 0; i < 100; i++) {
+    List<ActiveScan> scans = new ArrayList<ActiveScan>();
+    for (int i = 0; i < 100 && scans.isEmpty(); i++) {
       for (String tserver : client.getTabletServers(creds)) {
-        scans = client.getActiveScans(creds, tserver);
+        List<ActiveScan> scansForServer = client.getActiveScans(creds, tserver);
+        for (ActiveScan scan : scansForServer) {
+          if ("root".equals(scan.getUser())) {
+            scans.add(scan);
+          }
+        }
+
         if (!scans.isEmpty())
-          break loop;
+          break;
         UtilWaitThread.sleep(10);
       }
     }
     t.join();
-    assertFalse(scans.isEmpty());
-    ActiveScan scan = scans.get(0);
-    assertEquals("root", scan.getUser());
-    assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState()));
-    assertEquals(ScanType.SINGLE, scan.getType());
-    assertEquals("slow", scan.getTable());
-    Map<String,String> map = client.tableIdMap(creds);
-    assertEquals(map.get("slow"), scan.getExtent().tableId);
-    assertTrue(scan.getExtent().endRow == null);
-    assertTrue(scan.getExtent().prevEndRow == null);
     
+    assertFalse(scans.isEmpty());
+    boolean found = false;
+    Map<String,String> map = null;
+    for (int i = 0; i < scans.size() && !found; i++) {
+      ActiveScan scan = scans.get(i);
+      if ("root".equals(scan.getUser())) {
+        assertTrue(ScanState.RUNNING.equals(scan.getState()) || ScanState.QUEUED.equals(scan.getState()));
+        assertEquals(ScanType.SINGLE, scan.getType());
+        assertEquals("slow", scan.getTable());
+
+        map = client.tableIdMap(creds);
+        assertEquals(map.get("slow"), scan.getExtent().tableId);
+        assertTrue(scan.getExtent().endRow == null);
+        assertTrue(scan.getExtent().prevEndRow == null);
+        found = true;
+      }
+    }
+
+    assertTrue("Could not find a scan against the 'slow' table", found);
+
     // start a compaction
     t = new Thread() {
       @Override
@@ -803,27 +824,46 @@ public class SimpleTest {
       }
     };
     t.start();
-    
+
+    final String desiredTableId = map.get("slow");
+
     // try to catch it in the act
-    List<ActiveCompaction> compactions = Collections.emptyList();
-    loop2: for (int i = 0; i < 100; i++) {
+    List<ActiveCompaction> compactions = new ArrayList<ActiveCompaction>();
+    for (int i = 0; i < 100 && compactions.isEmpty(); i++) {
+      // Iterate over the tservers
       for (String tserver : client.getTabletServers(creds)) {
-        compactions = client.getActiveCompactions(creds, tserver);
+        // And get the compactions on each
+        List<ActiveCompaction> compactionsOnServer = client.getActiveCompactions(creds,
tserver);
+        for (ActiveCompaction compact : compactionsOnServer) {
+          // There might be other compactions occurring (e.g. on METADATA) in which
+          // case we want to prune out those that aren't for our slow table
+          if (desiredTableId.equals(compact.getExtent().tableId)) {
+            compactions.add(compact);
+          }
+        }
+
+        // If we found a compaction for the table we wanted, so we can stop looking
         if (!compactions.isEmpty())
-          break loop2;
+          break;
       }
       UtilWaitThread.sleep(10);
     }
     t.join();
+
     // verify the compaction information
     assertFalse(compactions.isEmpty());
-    ActiveCompaction c = compactions.get(0);
-    assertEquals(map.get("slow"), c.getExtent().tableId);
-    assertTrue(c.inputFiles.isEmpty());
-    assertEquals(CompactionType.MINOR, c.getType());
-    assertEquals(CompactionReason.USER, c.getReason());
-    assertEquals("", c.localityGroup);
-    assertTrue(c.outputFile.contains("default_tablet"));
+    for (ActiveCompaction c : compactions) {
+      if (desiredTableId.equals(c.getExtent().tableId)) {
+        assertTrue(c.inputFiles.isEmpty());
+        assertEquals(CompactionType.MINOR, c.getType());
+        assertEquals(CompactionReason.USER, c.getReason());
+        assertEquals("", c.localityGroup);
+        assertTrue(c.outputFile.contains("default_tablet"));
+
+        return;
+      }
+    }
+    fail("Expection to find running compaction for table 'slow' but did not find one");
   }
   
   @Test
@@ -1178,5 +1218,5 @@ public class SimpleTest {
     accumulo.stop();
     folder.delete();
   }
-  
-}
+
+}
\ No newline at end of file


Mime
View raw message