You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2013/11/27 19:32:50 UTC
git commit: ACCUMULO-1941 Fix TabletIT test
Updated Branches:
refs/heads/1.6.0-SNAPSHOT edae90f59 -> 40a007a2d
ACCUMULO-1941 Fix TabletIT test
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/40a007a2
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/40a007a2
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/40a007a2
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 40a007a2d57f53f4430164eda95f513444ac2897
Parents: edae90f
Author: Christopher Tubbs <ct...@apache.org>
Authored: Wed Nov 27 13:30:52 2013 -0500
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Nov 27 13:30:52 2013 -0500
----------------------------------------------------------------------
.../apache/accumulo/test/CreateTestTable.java | 90 --------------------
.../accumulo/test/functional/TabletIT.java | 63 ++++++++++++--
2 files changed, 55 insertions(+), 98 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/40a007a2/test/src/main/java/org/apache/accumulo/test/CreateTestTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/CreateTestTable.java b/test/src/main/java/org/apache/accumulo/test/CreateTestTable.java
deleted file mode 100644
index 14c5cef..0000000
--- a/test/src/main/java/org/apache/accumulo/test/CreateTestTable.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.test;
-
-import java.util.Map.Entry;
-import java.util.TreeSet;
-
-import org.apache.accumulo.server.cli.ClientOnDefaultTable;
-import org.apache.accumulo.core.cli.BatchWriterOpts;
-import org.apache.accumulo.core.cli.ScannerOpts;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
-import org.apache.hadoop.io.Text;
-
-import com.beust.jcommander.Parameter;
-
-public class CreateTestTable {
-
- static class Opts extends ClientOnDefaultTable {
- @Parameter(names={"-readonly", "--readonly"}, description="read only")
- boolean readOnly = false;
- @Parameter(names={"-count", "--count"}, description="count", required = true)
- int count = 10000;
- Opts() { super("mrtest1"); }
- }
-
- private static void readBack(Connector conn, Opts opts, ScannerOpts scanOpts) throws Exception {
- Scanner scanner = conn.createScanner("mrtest1", opts.auths);
- scanner.setBatchSize(scanOpts.scanBatchSize);
- int count = 0;
- for (Entry<Key,Value> elt : scanner) {
- String expected = String.format("%05d", count);
- assert (elt.getKey().getRow().toString().equals(expected));
- count++;
- }
- assert (opts.count == count);
- }
-
- public static void main(String[] args) throws Exception {
- String program = CreateTestTable.class.getName();
- Opts opts = new Opts();
- BatchWriterOpts bwOpts = new BatchWriterOpts();
- ScannerOpts scanOpts = new ScannerOpts();
- opts.parseArgs(program, args, bwOpts, scanOpts);
-
- // create the test table within accumulo
- Connector connector = opts.getConnector();
-
- if (!opts.readOnly) {
- TreeSet<Text> keys = new TreeSet<Text>();
- for (int i = 0; i < opts.count / 100; i++) {
- keys.add(new Text(String.format("%05d", i * 100)));
- }
-
- // presplit
- connector.tableOperations().create(opts.getTableName());
- connector.tableOperations().addSplits(opts.getTableName(), keys);
- BatchWriter b = connector.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());
-
- // populate
- for (int i = 0; i < opts.count; i++) {
- Mutation m = new Mutation(new Text(String.format("%05d", i)));
- m.put(new Text("col" + Integer.toString((i % 3) + 1)), new Text("qual"), new Value("junk".getBytes()));
- b.addMutation(m);
- }
- b.close();
- }
-
- readBack(connector, opts, scanOpts);
- opts.stopTracing();
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/40a007a2/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java b/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java
index f87a856..cf4c35c 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/TabletIT.java
@@ -20,28 +20,75 @@ import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeSet;
+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.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.MemoryUnit;
import org.apache.accumulo.minicluster.MiniAccumuloConfig;
-import org.apache.accumulo.test.CreateTestTable;
+import org.apache.hadoop.io.Text;
import org.junit.Test;
public class TabletIT extends ConfigurableMacIT {
-
+
private static final int N = 1000;
@Override
public void configure(MiniAccumuloConfig cfg) {
- Map<String, String> siteConfig = new HashMap<String,String>();
+ Map<String,String> siteConfig = new HashMap<String,String>();
siteConfig.put(Property.TABLE_SPLIT_THRESHOLD.getKey(), "200");
siteConfig.put(Property.TSERV_MAXMEM.getKey(), "128M");
+ cfg.setDefaultMemory(256, MemoryUnit.MEGABYTE);
cfg.setSiteConfig(siteConfig);
}
- @Test(timeout = 30 * 1000)
- public void test() throws Exception {
- assertEquals(0, cluster.exec(CreateTestTable.class, "" + N).waitFor());
- assertEquals(0, cluster.exec(CreateTestTable.class, "-readonly", "" + N).waitFor());
+ @Test(timeout = 2 * 60 * 1000)
+ public void createTableTest() throws Exception {
+ String tableName = getTableNames(1)[0];
+ createTableTest(tableName, false);
+ createTableTest(tableName, true);
+ }
+
+ public void createTableTest(String tableName, boolean readOnly) throws Exception {
+ // create the test table within accumulo
+ Connector connector = getConnector();
+
+ if (!readOnly) {
+ TreeSet<Text> keys = new TreeSet<Text>();
+ for (int i = N / 100; i < N; i += N / 100) {
+ keys.add(new Text(String.format("%05d", i)));
+ }
+
+ // presplit
+ connector.tableOperations().create(tableName);
+ connector.tableOperations().addSplits(tableName, keys);
+ BatchWriter b = connector.createBatchWriter(tableName, new BatchWriterConfig());
+
+ // populate
+ for (int i = 0; i < N; i++) {
+ Mutation m = new Mutation(new Text(String.format("%05d", i)));
+ m.put(new Text("col" + Integer.toString((i % 3) + 1)), new Text("qual"), new Value("junk".getBytes()));
+ b.addMutation(m);
+ }
+ b.close();
+ }
+
+ Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
+ int count = 0;
+ for (Entry<Key,Value> elt : scanner) {
+ String expected = String.format("%05d", count);
+ assert (elt.getKey().getRow().toString().equals(expected));
+ count++;
+ }
+ assertEquals(N, count);
}
-
+
}