Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 700A61026B for ; Tue, 15 Oct 2013 21:07:28 +0000 (UTC) Received: (qmail 9278 invoked by uid 500); 15 Oct 2013 21:07:26 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 9065 invoked by uid 500); 15 Oct 2013 21:07:21 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 9019 invoked by uid 99); 15 Oct 2013 21:07:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Oct 2013 21:07:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DAD408B5362; Tue, 15 Oct 2013 21:07:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cjnolet@apache.org To: commits@accumulo.apache.org Date: Tue, 15 Oct 2013 21:07:20 -0000 Message-Id: <11ca2f0c65be46518739c0d1d7f8aa05@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/4] git commit: ACCUMULO-1751 Adding initial SimpleMacIT test for AccumuloInputFormat 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 Authored: Sat Oct 12 22:50:38 2013 -0400 Committer: Corey J. Nolet 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 splitsToAdd = new TreeSet(); + 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 actualSplits = getConnector().tableOperations().listSplits(table); + + List 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(); + } +}