accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjno...@apache.org
Subject [2/4] git commit: ACCUMULO-1751 Adding initial SimpleMacIT test for AccumuloInputFormat
Date Tue, 15 Oct 2013 21:07:20 GMT
ACCUMULO-1751 Adding initial SimpleMacIT test for AccumuloInputFormat


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

Branch: refs/heads/master
Commit: eb7d45ba28a054771818cd34fbd91e63f0604d35
Parents: 5d1e7b8
Author: Corey J. Nolet <cjnolet@gmail.com>
Authored: Sat Oct 12 22:50:38 2013 -0400
Committer: Corey J. Nolet <cjnolet@gmail.com>
Committed: Tue Oct 15 16:58:40 2013 -0400

----------------------------------------------------------------------
 .../test/functional/AccumuloInputFormatIT.java  | 75 ++++++++++++++++++++
 1 file changed, 75 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/eb7d45ba/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
b/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
new file mode 100644
index 0000000..bfb7b86
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/functional/AccumuloInputFormatIT.java
@@ -0,0 +1,75 @@
+package org.apache.accumulo.test.functional;
+
+import static java.lang.System.currentTimeMillis;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.Job;
+import org.junit.Test;
+
+public class AccumuloInputFormatIT extends SimpleMacIT {
+
+  @Test
+  public void testGetSplits() throws IOException, AccumuloSecurityException, AccumuloException,
TableNotFoundException, TableExistsException {
+
+    String table = getTableNames(1)[0];
+    getConnector().tableOperations().create(table);
+
+    // add data
+
+    // add splits
+
+    Job job = new Job();
+
+    // set up the job here
+    AccumuloInputFormat.setInputTableName(job, table);
+    AccumuloInputFormat.setZooKeeperInstance(job, getConnector().getInstance().getInstanceName(),
getConnector().getInstance().getZooKeepers());
+    AccumuloInputFormat.setConnectorInfo(job, "root", new PasswordToken(ROOT_PASSWORD));
+
+    AccumuloInputFormat inputFormat = new AccumuloInputFormat();
+
+    insertData(table, currentTimeMillis());
+
+    TreeSet<Text> splitsToAdd = new TreeSet<Text>();
+    for (int i = 0; i < 10000; i += 1000)
+      splitsToAdd.add(new Text(String.format("%09d", i)));
+
+    getConnector().tableOperations().addSplits(table, splitsToAdd);
+
+    UtilWaitThread.sleep(5000);
+    Collection<Text> actualSplits = getConnector().tableOperations().listSplits(table);
+
+    List<InputSplit> splits = inputFormat.getSplits(job);
+    assertEquals(actualSplits.size(), splits.size());
+
+  }
+
+  private void insertData(String tableName, long ts) throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
+    BatchWriter bw = getConnector().createBatchWriter(tableName, null);
+
+    for (int i = 0; i < 10000; i++) {
+      String row = String.format("%09d", i);
+
+      Mutation m = new Mutation(new Text(row));
+      m.put(new Text("cf1"), new Text("cq1"), ts, new Value(("" + i).getBytes()));
+      bw.addMutation(m);
+    }
+    bw.close();
+  }
+}


Mime
View raw message