accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [08/18] git commit: ACCUMULO-1957 test cleanup
Date Fri, 05 Sep 2014 21:17:24 GMT
ACCUMULO-1957 test cleanup


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

Branch: refs/heads/master
Commit: c56e300940b694bef845d8847d64e8a7f3aeb4f4
Parents: 549d1c2
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Wed Sep 3 09:27:54 2014 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Fri Sep 5 17:16:59 2014 -0400

----------------------------------------------------------------------
 .../accumulo/test/functional/DurabilityIT.java  | 22 +++++---------
 .../test/functional/SessionDurabilityIT.java    | 32 +++++++++-----------
 2 files changed, 22 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c56e3009/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java b/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
index 74df598..11f61c7 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
@@ -27,9 +27,7 @@ import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.admin.TableOperations;
 import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.UtilWaitThread;
@@ -99,7 +97,7 @@ public class DurabilityIT extends ConfigurableMacIT {
     // sync table should lose nothing
     writeSome(tableNames[0], N);
     restartTServer();
-    assertEquals(N, readSome(tableNames[0], N));
+    assertEquals(N, readSome(tableNames[0]));
     cleanup(tableNames);
   }
 
@@ -109,7 +107,7 @@ public class DurabilityIT extends ConfigurableMacIT {
     // flush table won't lose anything since we're not losing power/dfs
     writeSome(tableNames[1], N);
     restartTServer();
-    assertEquals(N, readSome(tableNames[1], N));
+    assertEquals(N, readSome(tableNames[1]));
     cleanup(tableNames);
   }
 
@@ -119,7 +117,7 @@ public class DurabilityIT extends ConfigurableMacIT {
     // we're probably going to lose something the the log setting
     writeSome(tableNames[2], N);
     restartTServer();
-    assertTrue(N >= readSome(tableNames[2], N));
+    assertTrue(N >= readSome(tableNames[2]));
     cleanup(tableNames);
   }
 
@@ -129,7 +127,7 @@ public class DurabilityIT extends ConfigurableMacIT {
     // probably won't get any data back without logging
     writeSome(tableNames[3], N);
     restartTServer();
-    assertTrue(N > readSome(tableNames[3], N));
+    assertTrue(N > readSome(tableNames[3]));
     cleanup(tableNames);
   }
   
@@ -142,11 +140,11 @@ public class DurabilityIT extends ConfigurableMacIT {
     UtilWaitThread.sleep(1000);
     writeSome(tableName, N);
     restartTServer();
-    assertTrue(N > readSome(tableName, N));
+    assertTrue(N > readSome(tableName));
     c.tableOperations().setProperty(tableName, Property.TABLE_DURABILITY.getKey(), "sync");
     writeSome(tableName, N);
     restartTServer();
-    assertTrue(N == readSome(tableName, N));
+    assertTrue(N == readSome(tableName));
   }
   
   private static Map<String, String> map(Iterable<Entry<String, String>>
entries) {
@@ -170,12 +168,8 @@ public class DurabilityIT extends ConfigurableMacIT {
     
   }
 
-  private long readSome(String table, long n) throws Exception {
-    long count = 0;
-    for (@SuppressWarnings("unused") Entry<Key,Value> entry : getConnector().createScanner(table,
Authorizations.EMPTY)) {
-      count++;
-    }
-    return count;
+  private long readSome(String table) throws Exception {
+    return FunctionalTestUtils.count(getConnector().createScanner(table, Authorizations.EMPTY));
   }
 
   private void restartTServer() throws Exception {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/c56e3009/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
b/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
index 91041a9..d777ee4 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
@@ -1,18 +1,14 @@
 package org.apache.accumulo.test.functional;
 
-import static org.junit.Assert.*;
-
-import java.util.Map.Entry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Durability;
-import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
@@ -30,44 +26,44 @@ public class SessionDurabilityIT extends ConfigurableMacIT {
     cfg.setProperty(Property.INSTANCE_ZK_TIMEOUT, "5s");
   }
   
-  @Test
+  @Test(timeout = 3 * 60 * 1000)
   public void nondurableTableHasDurableWrites() throws Exception {
     Connector c = getConnector();
     String tableName = getUniqueNames(1)[0];
+    // table default has no durability
     c.tableOperations().create(tableName);
     c.tableOperations().setProperty(tableName, Property.TABLE_DURABILITY.getKey(), "none");
+    // send durable writes
     BatchWriterConfig cfg = new BatchWriterConfig();
     cfg.setDurability(Durability.SYNC);
-    write(tableName, 10, cfg);
+    writeSome(tableName, 10, cfg);
     assertEquals(10, count(tableName));
+    // verify writes servive restart
     restartTServer();
     assertEquals(10, count(tableName));
   }
   
-  @Test
+  @Test(timeout = 3 * 60 * 1000)
   public void durableTableLosesNonDurableWrites() throws Exception {
     Connector c = getConnector();
     String tableName = getUniqueNames(1)[0];
+    // table default is durable writes
     c.tableOperations().create(tableName);
     c.tableOperations().setProperty(tableName, Property.TABLE_DURABILITY.getKey(), "sync");
+    // write with no durability
     BatchWriterConfig cfg = new BatchWriterConfig();
     cfg.setDurability(Durability.NONE);
-    write(tableName, 10, cfg);
+    writeSome(tableName, 10, cfg);
+    // verify writes are lost on restart
     restartTServer();
     assertTrue(10 > count(tableName));
   }
   
   private int count(String tableName) throws Exception {
-    Connector c = getConnector();
-    Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);
-    int result = 0;
-    for (@SuppressWarnings("unused") Entry<Key,Value> entry :scanner) {
-      result++;
-    }
-    return result;
+    return FunctionalTestUtils.count(getConnector().createScanner(tableName, Authorizations.EMPTY));
   }
 
-  private void write(String tableName, int n, BatchWriterConfig cfg) throws Exception {
+  private void writeSome(String tableName, int n, BatchWriterConfig cfg) throws Exception
{
     Connector c = getConnector();
     BatchWriter bw = c.createBatchWriter(tableName, cfg);
     for (int i = 0; i < 10; i++) {


Mime
View raw message