You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/08/02 17:05:23 UTC

git commit: ACCUMULO-1629 reproduced conetable bug seen in random walk in functional test

Updated Branches:
  refs/heads/master 0608e32f8 -> 4bff142d3


ACCUMULO-1629 reproduced conetable bug seen in random walk in functional test


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

Branch: refs/heads/master
Commit: 4bff142d3a017c220fc1a69adc962535735758f6
Parents: 0608e32
Author: Keith Turner <kt...@apache.org>
Authored: Fri Aug 2 11:04:24 2013 -0400
Committer: Keith Turner <kt...@apache.org>
Committed: Fri Aug 2 11:04:24 2013 -0400

----------------------------------------------------------------------
 .../accumulo/test/functional/CloneTestIT.java   | 94 +++++++++++++++-----
 1 file changed, 72 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/4bff142d/test/src/test/java/org/apache/accumulo/test/functional/CloneTestIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/CloneTestIT.java b/test/src/test/java/org/apache/accumulo/test/functional/CloneTestIT.java
index 1cd2980..ba40b18 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/CloneTestIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/CloneTestIT.java
@@ -25,7 +25,9 @@ import java.util.Set;
 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.MutationsRejectedException;
 import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -40,7 +42,7 @@ import org.junit.Test;
 public class CloneTestIT extends SimpleMacIT {
   
   @Test(timeout = 120 * 1000)
-  public void run() throws Exception {
+  public void testProps() throws Exception {
     String table1 = makeTableName();
     String table2 = makeTableName();
     
@@ -52,20 +54,7 @@ public class CloneTestIT extends SimpleMacIT {
     c.tableOperations().setProperty(table1, Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX.getKey(), "2M");
     c.tableOperations().setProperty(table1, Property.TABLE_FILE_MAX.getKey(), "23");
     
-    BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
-    
-    Mutation m1 = new Mutation("001");
-    m1.put("data", "x", "9");
-    m1.put("data", "y", "7");
-    
-    Mutation m2 = new Mutation("008");
-    m2.put("data", "x", "3");
-    m2.put("data", "y", "4");
-    
-    bw.addMutation(m1);
-    bw.addMutation(m2);
-    
-    bw.flush();
+    BatchWriter bw = writeData(table1, c);
     
     Map<String,String> props = new HashMap<String,String>();
     props.put(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "500K");
@@ -81,6 +70,23 @@ public class CloneTestIT extends SimpleMacIT {
     bw.addMutation(m3);
     bw.close();
     
+    checkData(table2, c);
+    
+    HashMap<String,String> tableProps = new HashMap<String,String>();
+    for (Entry<String,String> prop : c.tableOperations().getProperties(table2)) {
+      tableProps.put(prop.getKey(), prop.getValue());
+    }
+    
+    Assert.assertEquals("500K", tableProps.get(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey()));
+    Assert.assertEquals(Property.TABLE_FILE_MAX.getDefaultValue(), tableProps.get(Property.TABLE_FILE_MAX.getKey()));
+    Assert.assertEquals("2M", tableProps.get(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX.getKey()));
+    
+    c.tableOperations().delete(table1);
+    c.tableOperations().delete(table2);
+    
+  }
+  
+  private void checkData(String table2, Connector c) throws TableNotFoundException {
     Scanner scanner = c.createScanner(table2, Authorizations.EMPTY);
     
     HashMap<String,String> expected = new HashMap<String,String>();
@@ -95,18 +101,62 @@ public class CloneTestIT extends SimpleMacIT {
       actual.put(entry.getKey().getRowData().toString() + ":" + entry.getKey().getColumnQualifierData().toString(), entry.getValue().toString());
     
     Assert.assertEquals(expected, actual);
+  }
+  
+  private BatchWriter writeData(String table1, Connector c) throws TableNotFoundException, MutationsRejectedException {
+    BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
     
-    HashMap<String,String> tableProps = new HashMap<String,String>();
-    for (Entry<String,String> prop : c.tableOperations().getProperties(table2)) {
-      tableProps.put(prop.getKey(), prop.getValue());
-    }
+    Mutation m1 = new Mutation("001");
+    m1.put("data", "x", "9");
+    m1.put("data", "y", "7");
     
-    Assert.assertEquals("500K", tableProps.get(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey()));
-    Assert.assertEquals(Property.TABLE_FILE_MAX.getDefaultValue(), tableProps.get(Property.TABLE_FILE_MAX.getKey()));
-    Assert.assertEquals("2M", tableProps.get(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX.getKey()));
+    Mutation m2 = new Mutation("008");
+    m2.put("data", "x", "3");
+    m2.put("data", "y", "4");
+    
+    bw.addMutation(m1);
+    bw.addMutation(m2);
+    
+    bw.flush();
+    return bw;
+  }
+  
+  @Test(timeout = 120 * 1000)
+  public void testDeleteClone() throws Exception {
+    String table1 = makeTableName();
+    String table2 = makeTableName();
     
+    Connector c = getConnector();
+    
+    c.tableOperations().create(table1);
+    
+    BatchWriter bw = writeData(table1, c);
+
+    Map<String,String> props = new HashMap<String,String>();
+    props.put(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "500K");
+    
+    Set<String> exclude = new HashSet<String>();
+    exclude.add(Property.TABLE_FILE_MAX.getKey());
+    
+    c.tableOperations().clone(table1, table2, true, props, exclude);
+    
+    Mutation m3 = new Mutation("009");
+    m3.put("data", "x", "1");
+    m3.put("data", "y", "2");
+    bw.addMutation(m3);
+    bw.close();
+    
+    // delete source table, should not affect clone
     c.tableOperations().delete(table1);
+    
+    checkData(table2, c);
+    
+    c.tableOperations().compact(table2, null, null, true, true);
+    
+    checkData(table2, c);
+    
     c.tableOperations().delete(table2);
     
   }
+
 }