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/07/17 04:33:06 UTC
[04/50] [abbrv] git commit: ACCUMULO-1537 converted many more
functional tests to integration tests
ACCUMULO-1537 converted many more functional tests to integration tests
git-svn-id: https://svn.apache.org/repos/asf/accumulo/trunk@1499110 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/aea43136
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/aea43136
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/aea43136
Branch: refs/heads/ACCUMULO-1496
Commit: aea4313624e0bbe815c3de2c0a6aa4af4ad82c26
Parents: bca0567
Author: Eric C. Newton <ec...@apache.org>
Authored: Tue Jul 2 20:57:21 2013 +0000
Committer: Eric C. Newton <ec...@apache.org>
Committed: Tue Jul 2 20:57:21 2013 +0000
----------------------------------------------------------------------
.../accumulo/core/conf/SiteConfiguration.java | 2 +-
.../server/util/CheckForMetadataProblems.java | 2 +-
.../accumulo/server/util/MetadataTable.java | 2 +-
.../accumulo/test/GCLotsOfCandidatesTest.java | 53 --
.../test/functional/FateStarvationTest.java | 77 ---
.../accumulo/test/functional/LargeRowTest.java | 185 -------
.../test/functional/LogicalTimeTest.java | 112 -----
.../accumulo/test/functional/MaxOpenTest.java | 127 -----
.../accumulo/test/functional/MergeTest.java | 142 ------
.../test/functional/PermissionsTest.java | 504 -------------------
.../accumulo/test/functional/RowDeleteTest.java | 113 -----
.../test/functional/ScanIteratorTest.java | 136 -----
.../accumulo/test/functional/ScanRangeTest.java | 250 ---------
.../test/functional/ScanSessionTimeOutTest.java | 112 -----
.../test/functional/ServerSideErrorTest.java | 135 -----
.../test/functional/SparseColumnFamilyTest.java | 116 -----
.../accumulo/test/functional/TimeoutTest.java | 132 -----
.../accumulo/test/functional/DeleteIT.java | 11 +-
.../test/functional/DynamicThreadPoolsIT.java | 3 +-
.../test/functional/FateStarvationIT.java | 64 +++
.../test/functional/FunctionalTestUtils.java | 10 +
.../test/functional/GarbageCollectorIT.java | 122 +++++
.../accumulo/test/functional/LargeRowIT.java | 168 +++++++
.../accumulo/test/functional/LogicalTimeIT.java | 99 ++++
.../accumulo/test/functional/MapReduceIT.java | 80 +++
.../accumulo/test/functional/MaxOpenIT.java | 132 +++++
.../accumulo/test/functional/MergeIT.java | 182 +++++++
.../accumulo/test/functional/MergeMetaIT.java | 61 +++
.../accumulo/test/functional/PermissionsIT.java | 475 +++++++++++++++++
.../accumulo/test/functional/ReadWriteIT.java | 14 +-
.../accumulo/test/functional/RowDeleteIT.java | 116 +++++
.../test/functional/ScanIteratorIT.java | 125 +++++
.../accumulo/test/functional/ScanRangeIT.java | 233 +++++++++
.../test/functional/ScanSessionTimeOutIT.java | 104 ++++
.../test/functional/ServerSideErrorIT.java | 119 +++++
.../accumulo/test/functional/ShutdownIT.java | 104 ++++
.../functional/SimpleBalancerFairnessIT.java | 90 ++++
.../test/functional/SparseColumnFamilyIT.java | 102 ++++
.../accumulo/test/functional/SplitIT.java | 103 ++++
.../accumulo/test/functional/StartIT.java | 33 ++
.../accumulo/test/functional/TableIT.java | 75 +++
.../accumulo/test/functional/TabletIT.java | 47 ++
.../accumulo/test/functional/TimeoutIT.java | 115 +++++
test/system/auto/simple/examples.py | 348 -------------
test/system/auto/simple/fateStartvation.py | 30 --
test/system/auto/simple/gc.py | 120 -----
test/system/auto/simple/largeRow.py | 30 --
test/system/auto/simple/logicalTime.py | 30 --
test/system/auto/simple/mapreduce.py | 142 ------
test/system/auto/simple/maxOpen.py | 30 --
test/system/auto/simple/merge.py | 107 ----
test/system/auto/simple/mergeMetadata.py | 73 ---
test/system/auto/simple/range.py | 29 --
test/system/auto/simple/rowDelete.py | 30 --
test/system/auto/simple/scanIter.py | 30 --
test/system/auto/simple/scanSessionTimeout.py | 30 --
test/system/auto/simple/security.py | 39 --
test/system/auto/simple/serverSideError.py | 30 --
test/system/auto/simple/shutdown.py | 108 ----
test/system/auto/simple/simpleBalancer.py | 116 -----
test/system/auto/simple/sparseColumnFamily.py | 30 --
test/system/auto/simple/split.py | 135 -----
test/system/auto/simple/start.py | 40 --
test/system/auto/simple/table.py | 120 -----
test/system/auto/simple/tablets.py | 55 --
test/system/auto/simple/timeout.py | 29 --
66 files changed, 2780 insertions(+), 3938 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index b5017cf..b8e1337 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -49,7 +49,7 @@ public class SiteConfiguration extends AccumuloConfiguration {
xmlConfig = new Configuration(false);
if (SiteConfiguration.class.getClassLoader().getResource(configFile) == null)
- log.warn(configFile + " not found on classpath");
+ log.warn(configFile + " not found on classpath", new Throwable());
else
xmlConfig.addResource(configFile);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java b/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
index dec4733..9c80927 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
@@ -195,7 +195,7 @@ public class CheckForMetadataProblems {
checkMetadataTableEntries(opts, fs);
opts.stopTracing();
if (sawProblems)
- System.exit(-1);
+ throw new RuntimeException();
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java b/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java
index 4531fed..3bd2c5b 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/MetadataTable.java
@@ -64,6 +64,7 @@ import org.apache.accumulo.core.util.StringUtil;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
+import org.apache.accumulo.fate.zookeeper.ZooLock;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
import org.apache.accumulo.server.ServerConstants;
@@ -73,7 +74,6 @@ import org.apache.accumulo.server.fs.VolumeManager;
import org.apache.accumulo.server.fs.VolumeManagerImpl;
import org.apache.accumulo.server.master.state.TServerInstance;
import org.apache.accumulo.server.security.SecurityConstants;
-import org.apache.accumulo.server.zookeeper.ZooLock;
import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/GCLotsOfCandidatesTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/GCLotsOfCandidatesTest.java b/test/src/main/java/org/apache/accumulo/test/GCLotsOfCandidatesTest.java
deleted file mode 100644
index 5b72fcd..0000000
--- a/test/src/main/java/org/apache/accumulo/test/GCLotsOfCandidatesTest.java
+++ /dev/null
@@ -1,53 +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 org.apache.accumulo.core.cli.BatchWriterOpts;
-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.Connector;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.TablePermission;
-import org.apache.accumulo.core.util.MetadataTable;
-import org.apache.accumulo.server.cli.ClientOpts;
-import org.apache.hadoop.io.Text;
-
-public class GCLotsOfCandidatesTest {
- public static void main(String args[]) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException {
- ClientOpts opts = new ClientOpts();
- BatchWriterOpts bwOpts = new BatchWriterOpts();
- opts.parseArgs(GCLotsOfCandidatesTest.class.getName(), args, bwOpts);
-
- Connector conn = opts.getConnector();
- conn.securityOperations().grantTablePermission(conn.whoami(), MetadataTable.NAME, TablePermission.WRITE);
- BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, bwOpts.getBatchWriterConfig());
-
- for (int i = 0; i < 100000; ++i) {
- final Text emptyText = new Text("");
- Text row = new Text(String.format("%s%s%020d%s", MetadataTable.DELETED_RANGE.getStartKey().getRow().toString(), "/", i,
- "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjj"));
- Mutation delFlag = new Mutation(row);
- delFlag.put(emptyText, emptyText, new Value(new byte[] {}));
- bw.addMutation(delFlag);
- }
- bw.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/FateStarvationTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/FateStarvationTest.java b/test/src/main/java/org/apache/accumulo/test/functional/FateStarvationTest.java
deleted file mode 100644
index 01cf658..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/FateStarvationTest.java
+++ /dev/null
@@ -1,77 +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.functional;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.accumulo.test.TestIngest;
-import org.apache.hadoop.io.Text;
-
-/**
- * See ACCUMULO-779
- */
-public class FateStarvationTest extends FunctionalTest {
-
- @Override
- public void cleanup() throws Exception {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.emptyList();
- }
-
- @Override
- public void run() throws Exception {
- getConnector().tableOperations().create("test_ingest");
-
- getConnector().tableOperations().addSplits("test_ingest", TestIngest.getSplitPoints(0, 100000, 50));
-
- TestIngest.main(new String[] {"-random", "89", "-timestamp", "7", "-size", "" + 50, "100000", "0", "1"});
-
- getConnector().tableOperations().flush("test_ingest", null, null, true);
-
- List<Text> splits = new ArrayList<Text>(TestIngest.getSplitPoints(0, 100000, 67));
- Random rand = new Random();
-
- for (int i = 0; i < 100; i++) {
- int idx1 = rand.nextInt(splits.size() - 1);
- int idx2 = rand.nextInt(splits.size() - (idx1 + 1)) + idx1 + 1;
-
- getConnector().tableOperations().compact("test_ingest", splits.get(idx1), splits.get(idx2), false, false);
- }
-
- getConnector().tableOperations().offline("test_ingest");
- }
-
- public static void main(String[] args) throws Exception {
- ArrayList<String> argsList = new ArrayList<String>();
- argsList.addAll(Arrays.asList(args));
- argsList.addAll(Arrays.asList(FateStarvationTest.class.getName(), "run"));
- FunctionalTest.main(argsList.toArray(new String[0]));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/LargeRowTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/LargeRowTest.java b/test/src/main/java/org/apache/accumulo/test/functional/LargeRowTest.java
deleted file mode 100644
index 4e9ded5..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/LargeRowTest.java
+++ /dev/null
@@ -1,185 +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.functional;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.TreeSet;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-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.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.UtilWaitThread;
-import org.apache.accumulo.test.TestIngest;
-import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
-
-public class LargeRowTest extends FunctionalTest {
-
- private static final int SEED = 42;
- private static final String REG_TABLE_NAME = "lr";
- private static final String PRE_SPLIT_TABLE_NAME = "lrps";
- private static final int NUM_ROWS = 100;
- private static final int ROW_SIZE = 1 << 17;
- private static final int NUM_PRE_SPLITS = 9;
- private static final int SPLIT_THRESH = ROW_SIZE * NUM_ROWS / NUM_PRE_SPLITS;
-
- @Override
- public void cleanup() {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return parseConfig(Property.TSERV_MAJC_DELAY + "=10ms");
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
-
- Random r = new Random();
- byte rowData[] = new byte[ROW_SIZE];
- r.setSeed(SEED + 1);
-
- TreeSet<Text> splitPoints = new TreeSet<Text>();
-
- for (int i = 0; i < NUM_PRE_SPLITS; i++) {
- r.nextBytes(rowData);
- TestIngest.toPrintableChars(rowData);
- splitPoints.add(new Text(rowData));
- }
-
- ArrayList<TableSetup> tables = new ArrayList<TableSetup>();
-
- tables.add(new TableSetup(REG_TABLE_NAME));
- tables.add(new TableSetup(PRE_SPLIT_TABLE_NAME, splitPoints));
-
- return tables;
- // return Collections.singletonList(new TableSetup(TABLE_NAME));
- }
-
- @Override
- public void run() throws Exception {
-
- // Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
- // logger.setLevel(Level.TRACE);
-
- test1();
- test2();
- }
-
- private void test1() throws Exception {
-
- basicTest(REG_TABLE_NAME, 0);
-
- getConnector().tableOperations().setProperty(REG_TABLE_NAME, Property.TABLE_SPLIT_THRESHOLD.getKey(), "" + SPLIT_THRESH);
-
- UtilWaitThread.sleep(12000);
- Logger.getLogger(LargeRowTest.class).warn("checking splits");
- checkSplits(REG_TABLE_NAME, NUM_PRE_SPLITS / 2, NUM_PRE_SPLITS * 4);
-
- verify(REG_TABLE_NAME);
- }
-
- private void test2() throws Exception {
- basicTest(PRE_SPLIT_TABLE_NAME, NUM_PRE_SPLITS);
- }
-
- private void basicTest(String table, int expectedSplits) throws Exception {
- BatchWriter bw = getConnector().createBatchWriter(table, new BatchWriterConfig());
-
- Random r = new Random();
- byte rowData[] = new byte[ROW_SIZE];
-
- r.setSeed(SEED);
-
- for (int i = 0; i < NUM_ROWS; i++) {
-
- r.nextBytes(rowData);
- TestIngest.toPrintableChars(rowData);
-
- Mutation mut = new Mutation(new Text(rowData));
- mut.put(new Text(""), new Text(""), new Value(("" + i).getBytes()));
- bw.addMutation(mut);
- }
-
- bw.close();
-
- checkSplits(table, expectedSplits, expectedSplits);
-
- verify(table);
-
- checkSplits(table, expectedSplits, expectedSplits);
-
- getConnector().tableOperations().flush(table, null, null, false);
-
- // verify while table flush is running
- verify(table);
-
- // give split time to complete
- getConnector().tableOperations().flush(table, null, null, true);
-
- checkSplits(table, expectedSplits, expectedSplits);
-
- verify(table);
-
- checkSplits(table, expectedSplits, expectedSplits);
- }
-
- private void verify(String table) throws Exception {
- Random r = new Random();
- byte rowData[] = new byte[ROW_SIZE];
-
- r.setSeed(SEED);
-
- Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY);
-
- for (int i = 0; i < NUM_ROWS; i++) {
-
- r.nextBytes(rowData);
- TestIngest.toPrintableChars(rowData);
-
- scanner.setRange(new Range(new Text(rowData)));
-
- int count = 0;
-
- for (Entry<Key,Value> entry : scanner) {
- if (!entry.getKey().getRow().equals(new Text(rowData))) {
- throw new Exception("verification failed, unexpected row i =" + i);
- }
- if (!entry.getValue().equals(Integer.toString(i).getBytes())) {
- throw new Exception("verification failed, unexpected value i =" + i + " value = " + entry.getValue());
- }
- count++;
- }
-
- if (count != 1) {
- throw new Exception("verification failed, unexpected count i =" + i + " count=" + count);
- }
-
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeTest.java b/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeTest.java
deleted file mode 100644
index 8829b92..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeTest.java
+++ /dev/null
@@ -1,112 +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.functional;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-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.client.admin.TimeType;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-
-public class LogicalTimeTest extends FunctionalTest {
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.emptyList();
- }
-
- @Override
- public void run() throws Exception {
- int tc = 0;
-
- runMergeTest("foo" + tc++, new String[] {"m"}, new String[] {"a"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"m"}, new String[] {"z"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"m"}, new String[] {"a", "z"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"m"}, new String[] {"a", "c", "z"}, null, null, "b", 3l);
- runMergeTest("foo" + tc++, new String[] {"m"}, new String[] {"a", "y", "z"}, null, null, "b", 3l);
-
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"h"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"s"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a", "h", "s"}, null, null, "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a", "c", "h", "s"}, null, null, "b", 3l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a", "h", "s", "i"}, null, null, "b", 3l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"t", "a", "h", "s"}, null, null, "b", 3l);
-
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a"}, null, "h", "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"h"}, null, "h", "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"s"}, null, "h", "b", 1l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a", "h", "s"}, null, "h", "b", 2l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a", "c", "h", "s"}, null, "h", "b", 3l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"a", "h", "s", "i"}, null, "h", "b", 3l);
- runMergeTest("foo" + tc++, new String[] {"g", "r"}, new String[] {"t", "a", "h", "s"}, null, "h", "b", 2l);
-
- }
-
- private void runMergeTest(String table, String[] splits, String[] inserts, String start, String end, String last, long expected) throws Exception {
- Connector conn = super.getConnector();
- conn.tableOperations().create(table, true, TimeType.LOGICAL);
- TreeSet<Text> splitSet = new TreeSet<Text>();
- for (String split : splits) {
- splitSet.add(new Text(split));
- }
- conn.tableOperations().addSplits(table, splitSet);
-
- BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig());
- for (String row : inserts) {
- Mutation m = new Mutation(row);
- m.put("cf", "cq", "v");
- bw.addMutation(m);
- }
-
- bw.flush();
-
- conn.tableOperations().merge(table, start == null ? null : new Text(start), end == null ? null : new Text(end));
-
- Mutation m = new Mutation(last);
- m.put("cf", "cq", "v");
- bw.addMutation(m);
- bw.flush();
-
- Scanner scanner = conn.createScanner(table, Authorizations.EMPTY);
- scanner.setRange(new Range(last));
-
- bw.close();
-
- long time = scanner.iterator().next().getKey().getTimestamp();
- if (time != expected)
- throw new RuntimeException("unexpected time " + time + " " + expected);
- }
-
- @Override
- public void cleanup() throws Exception {}
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/MaxOpenTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MaxOpenTest.java b/test/src/main/java/org/apache/accumulo/test/functional/MaxOpenTest.java
deleted file mode 100644
index 6dea01c..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/MaxOpenTest.java
+++ /dev/null
@@ -1,127 +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.functional;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.test.TestIngest;
-import org.apache.accumulo.test.VerifyIngest;
-
-/**
- * A functional test that excercises hitting the max open file limit on a tablet server. This test assumes there are one or two tablet servers.
- *
- *
- */
-
-public class MaxOpenTest extends FunctionalTest {
-
- private static final int NUM_TABLETS = 16;
- private static final int NUM_TO_INGEST = 10000;
-
- @Override
- public void cleanup() {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return parseConfig(Property.TSERV_SCAN_MAX_OPENFILES + "=4", Property.TSERV_MAJC_MAXCONCURRENT + "=1", Property.TSERV_MAJC_THREAD_MAXOPEN + "=2");
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- Map<String,String> config = parseConfig(Property.TABLE_MAJC_RATIO + "=10");
- TableSetup ts = new TableSetup("test_ingest", config, TestIngest.getSplitPoints(0, NUM_TO_INGEST, NUM_TABLETS));
- return Collections.singletonList(ts);
- }
-
- @Override
- public void run() throws Exception {
-
- // the following loop should create three tablets in each map file
- for (int i = 0; i < 3; i++) {
-
- TestIngest.main(new String[] {"-random", "" + i, "-timestamp", "" + i, "-size", "" + 50, "" + NUM_TO_INGEST, "0", "1"});
-
- getConnector().tableOperations().flush("test_ingest", null, null, true);
- checkRFiles("test_ingest", NUM_TABLETS, NUM_TABLETS, i + 1, i + 1);
- }
-
- List<Range> ranges = new ArrayList<Range>(NUM_TO_INGEST);
-
- for (int i = 0; i < NUM_TO_INGEST; i++) {
- ranges.add(new Range(TestIngest.generateRow(i, 0)));
- }
-
- long time1 = batchScan(ranges, 1);
- // run it again, now that stuff is cached on the client and sever
- time1 = batchScan(ranges, 1);
- long time2 = batchScan(ranges, NUM_TABLETS);
-
- System.out.printf("Single thread scan time %6.2f %n", time1 / 1000.0);
- System.out.printf("Multiple thread scan time %6.2f %n", time2 / 1000.0);
-
- }
-
- private long batchScan(List<Range> ranges, int threads) throws Exception {
- BatchScanner bs = getConnector().createBatchScanner("test_ingest", TestIngest.AUTHS, threads);
-
- bs.setRanges(ranges);
-
- int count = 0;
-
- long t1 = System.currentTimeMillis();
-
- byte rval[] = new byte[50];
- Random random = new Random();
-
- for (Entry<Key,Value> entry : bs) {
- count++;
- int row = VerifyIngest.getRow(entry.getKey());
- int col = VerifyIngest.getCol(entry.getKey());
-
- if (row < 0 || row >= NUM_TO_INGEST) {
- throw new Exception("unexcepted row " + row);
- }
-
- rval = TestIngest.genRandomValue(random, rval, 2, row, col);
-
- if (entry.getValue().compareTo(rval) != 0) {
- throw new Exception("unexcepted value row=" + row + " col=" + col);
- }
- }
-
- long t2 = System.currentTimeMillis();
-
- bs.close();
-
- if (count != NUM_TO_INGEST) {
- throw new Exception("Batch Scan did not return expected number of values " + count);
- }
-
- return t2 - t1;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/MergeTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MergeTest.java b/test/src/main/java/org/apache/accumulo/test/functional/MergeTest.java
deleted file mode 100644
index f997ff2..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/MergeTest.java
+++ /dev/null
@@ -1,142 +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.functional;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-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.client.admin.TimeType;
-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.hadoop.io.Text;
-
-/**
- *
- */
-public class MergeTest extends FunctionalTest {
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.emptyList();
- }
-
- private String[] ns(String... strings) {
- return strings;
- }
-
- @Override
- public void run() throws Exception {
- int tc = 0;
-
- runMergeTest("foo" + tc++, ns(), ns(), ns("l", "m", "n"), ns(null, "l"), ns(null, "n"));
-
- runMergeTest("foo" + tc++, ns("m"), ns(), ns("l", "m", "n"), ns(null, "l"), ns(null, "n"));
- runMergeTest("foo" + tc++, ns("m"), ns("m"), ns("l", "m", "n"), ns("m", "n"), ns(null, "z"));
- runMergeTest("foo" + tc++, ns("m"), ns("m"), ns("l", "m", "n"), ns(null, "b"), ns("l", "m"));
-
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns(), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns(null, "a"), ns(null, "s"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("m", "r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns(null, "a"), ns("c", "m"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns(null, "a"), ns("n", "r"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns("b", "c"), ns(null, "s"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b", "m"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns("m", "n"), ns(null, "s"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b", "r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns("b", "c"), ns("q", "r"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b", "m", "r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns(null, "a"), ns("aa", "b"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b", "m", "r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns("r", "s"), ns(null, "z"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b", "m", "r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns("b", "c"), ns("l", "m"));
- runMergeTest("foo" + tc++, ns("b", "m", "r"), ns("b", "m", "r"), ns("a", "b", "c", "l", "m", "n", "q", "r", "s"), ns("m", "n"), ns("q", "r"));
-
- }
-
- private void runMergeTest(String table, String[] splits, String[] expectedSplits, String[] inserts, String[] start, String[] end) throws Exception {
- int count = 0;
-
- for (String s : start) {
- for (String e : end) {
- runMergeTest(table + "_" + count++, splits, expectedSplits, inserts, s, e);
- }
- }
- }
-
- private void runMergeTest(String table, String[] splits, String[] expectedSplits, String[] inserts, String start, String end) throws Exception {
- System.out.println("Running merge test " + table + " " + Arrays.asList(splits) + " " + start + " " + end);
-
- Connector conn = super.getConnector();
- conn.tableOperations().create(table, true, TimeType.LOGICAL);
- TreeSet<Text> splitSet = new TreeSet<Text>();
- for (String split : splits) {
- splitSet.add(new Text(split));
- }
- conn.tableOperations().addSplits(table, splitSet);
-
- BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig());
- HashSet<String> expected = new HashSet<String>();
- for (String row : inserts) {
- Mutation m = new Mutation(row);
- m.put("cf", "cq", row);
- bw.addMutation(m);
- expected.add(row);
- }
-
- bw.close();
-
- conn.tableOperations().merge(table, start == null ? null : new Text(start), end == null ? null : new Text(end));
-
- Scanner scanner = conn.createScanner(table, Authorizations.EMPTY);
-
- HashSet<String> observed = new HashSet<String>();
- for (Entry<Key,Value> entry : scanner) {
- String row = entry.getKey().getRowData().toString();
- if (!observed.add(row)) {
- throw new Exception("Saw data twice " + table + " " + row);
- }
- }
-
- if (!observed.equals(expected)) {
- throw new Exception("data inconsistency " + table + " " + observed + " != " + expected);
- }
-
- HashSet<Text> currentSplits = new HashSet<Text>(conn.tableOperations().listSplits(table));
- HashSet<Text> ess = new HashSet<Text>();
- for (String es : expectedSplits) {
- ess.add(new Text(es));
- }
-
- if (!currentSplits.equals(ess)) {
- throw new Exception("split inconsistency " + table + " " + currentSplits + " != " + ess);
- }
- }
-
- @Override
- public void cleanup() throws Exception {}
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/PermissionsTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsTest.java b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsTest.java
deleted file mode 100644
index 4dbd966..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsTest.java
+++ /dev/null
@@ -1,504 +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.functional;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-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.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.impl.Tables;
-import org.apache.accumulo.core.client.security.SecurityErrorCode;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-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.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TablePermission;
-import org.apache.accumulo.core.util.MetadataTable;
-import org.apache.accumulo.server.conf.ServerConfiguration;
-import org.apache.hadoop.io.Text;
-import org.apache.log4j.Logger;
-
-public class PermissionsTest {
- private static final String TEST_USER = "test_user";
- private static final PasswordToken TEST_PASS = new PasswordToken("test_password");
-
- public static class SystemPermissionsTest extends FunctionalTest {
- private static final Logger log = Logger.getLogger(SystemPermissionsTest.class);
-
- @Override
- public void cleanup() throws Exception {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.emptyList();
- }
-
- @Override
- public void run() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
- // verify that the test is being run by root
- verifyHasOnlyTheseSystemPermissions(getConnector(), getConnector().whoami(), SystemPermission.values());
-
- // create the test user
- getConnector().securityOperations().createLocalUser(TEST_USER, TEST_PASS);
- Connector test_user_conn = getInstance().getConnector(TEST_USER, TEST_PASS);
- verifyHasNoSystemPermissions(getConnector(), TEST_USER, SystemPermission.values());
-
- // test each permission
- for (SystemPermission perm : SystemPermission.values()) {
- log.debug("Verifying the " + perm + " permission");
-
- // verify GRANT can't be granted
- if (perm.equals(SystemPermission.GRANT)) {
- try {
- getConnector().securityOperations().grantSystemPermission(TEST_USER, perm);
- } catch (AccumuloSecurityException e) {
- verifyHasNoSystemPermissions(getConnector(), TEST_USER, perm);
- continue;
- }
- throw new IllegalStateException("Should NOT be able to grant GRANT");
- }
-
- // test permission before and after granting it
- testMissingSystemPermission(getConnector(), test_user_conn, perm);
- getConnector().securityOperations().grantSystemPermission(TEST_USER, perm);
- verifyHasOnlyTheseSystemPermissions(getConnector(), TEST_USER, perm);
- testGrantedSystemPermission(getConnector(), test_user_conn, perm);
- getConnector().securityOperations().revokeSystemPermission(TEST_USER, perm);
- verifyHasNoSystemPermissions(getConnector(), TEST_USER, perm);
- }
- }
-
- private static void testMissingSystemPermission(Connector root_conn, Connector test_user_conn, SystemPermission perm) throws AccumuloException,
- TableExistsException, AccumuloSecurityException, TableNotFoundException {
- String tableName, tableId, user, password = "password";
- log.debug("Confirming that the lack of the " + perm + " permission properly restricts the user");
-
- // test permission prior to granting it
- switch (perm) {
- case CREATE_TABLE:
- tableName = "__CREATE_TABLE_WITHOUT_PERM_TEST__";
- try {
- test_user_conn.tableOperations().create(tableName);
- throw new IllegalStateException("Should NOT be able to create a table");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || root_conn.tableOperations().list().contains(tableName))
- throw e;
- }
- break;
- case DROP_TABLE:
- tableName = "__DROP_TABLE_WITHOUT_PERM_TEST__";
- root_conn.tableOperations().create(tableName);
- try {
- test_user_conn.tableOperations().delete(tableName);
- throw new IllegalStateException("Should NOT be able to delete a table");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || !root_conn.tableOperations().list().contains(tableName))
- throw e;
- }
- break;
- case ALTER_TABLE:
- tableName = "__ALTER_TABLE_WITHOUT_PERM_TEST__";
- root_conn.tableOperations().create(tableName);
- tableId = Tables.getNameToIdMap(root_conn.getInstance()).get(tableName);
- try {
- test_user_conn.tableOperations().setProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey(), "003.14159%");
- throw new IllegalStateException("Should NOT be able to set a table property");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
- || ServerConfiguration.getTableConfiguration(root_conn.getInstance(), tableId).get(Property.TABLE_BLOOM_ERRORRATE).equals("003.14159%"))
- throw e;
- }
- root_conn.tableOperations().setProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey(), "003.14159%");
- try {
- test_user_conn.tableOperations().removeProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey());
- throw new IllegalStateException("Should NOT be able to remove a table property");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
- || !ServerConfiguration.getTableConfiguration(root_conn.getInstance(), tableId).get(Property.TABLE_BLOOM_ERRORRATE).equals("003.14159%"))
- throw e;
- }
- String table2 = tableName + "2";
- try {
- test_user_conn.tableOperations().rename(tableName, table2);
- throw new IllegalStateException("Should NOT be able to rename a table");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || !root_conn.tableOperations().list().contains(tableName)
- || root_conn.tableOperations().list().contains(table2))
- throw e;
- }
- break;
- case CREATE_USER:
- user = "__CREATE_USER_WITHOUT_PERM_TEST__";
- try {
- test_user_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
- throw new IllegalStateException("Should NOT be able to create a user");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
- || root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
- throw e;
- }
- break;
- case DROP_USER:
- user = "__DROP_USER_WITHOUT_PERM_TEST__";
- root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
- try {
- test_user_conn.securityOperations().dropLocalUser(user);
- throw new IllegalStateException("Should NOT be able to delete a user");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
- || !root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
- throw e;
- }
- break;
- case ALTER_USER:
- user = "__ALTER_USER_WITHOUT_PERM_TEST__";
- root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
- try {
- test_user_conn.securityOperations().changeUserAuthorizations(user, new Authorizations("A", "B"));
- throw new IllegalStateException("Should NOT be able to alter a user");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || !root_conn.securityOperations().getUserAuthorizations(user).isEmpty())
- throw e;
- }
- break;
- case SYSTEM:
- // test for system permission would go here
- break;
- default:
- throw new IllegalArgumentException("Unrecognized System Permission: " + perm);
- }
- }
-
- private static void testGrantedSystemPermission(Connector root_conn, Connector test_user_conn, SystemPermission perm) throws AccumuloException,
- AccumuloSecurityException, TableNotFoundException, TableExistsException {
- String tableName, tableId, user, password = "password";
- log.debug("Confirming that the presence of the " + perm + " permission properly permits the user");
-
- // test permission after granting it
- switch (perm) {
- case CREATE_TABLE:
- tableName = "__CREATE_TABLE_WITH_PERM_TEST__";
- test_user_conn.tableOperations().create(tableName);
- if (!root_conn.tableOperations().list().contains(tableName))
- throw new IllegalStateException("Should be able to create a table");
- break;
- case DROP_TABLE:
- tableName = "__DROP_TABLE_WITH_PERM_TEST__";
- root_conn.tableOperations().create(tableName);
- test_user_conn.tableOperations().delete(tableName);
- if (root_conn.tableOperations().list().contains(tableName))
- throw new IllegalStateException("Should be able to delete a table");
- break;
- case ALTER_TABLE:
- tableName = "__ALTER_TABLE_WITH_PERM_TEST__";
- String table2 = tableName + "2";
- root_conn.tableOperations().create(tableName);
- tableId = Tables.getNameToIdMap(root_conn.getInstance()).get(tableName);
- Instance instance = root_conn.getInstance();
- test_user_conn.tableOperations().setProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey(), "003.14159%");
- if (!ServerConfiguration.getTableConfiguration(instance, tableId).get(Property.TABLE_BLOOM_ERRORRATE).equals("003.14159%"))
- throw new IllegalStateException("Should be able to set a table property");
- test_user_conn.tableOperations().removeProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey());
- if (ServerConfiguration.getTableConfiguration(instance, tableId).get(Property.TABLE_BLOOM_ERRORRATE).equals("003.14159%"))
- throw new IllegalStateException("Should be able to remove a table property");
- test_user_conn.tableOperations().rename(tableName, table2);
- if (root_conn.tableOperations().list().contains(tableName) || !root_conn.tableOperations().list().contains(table2))
- throw new IllegalStateException("Should be able to rename a table");
- break;
- case CREATE_USER:
- user = "__CREATE_USER_WITH_PERM_TEST__";
- test_user_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
- if (!root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
- throw new IllegalStateException("Should be able to create a user");
- break;
- case DROP_USER:
- user = "__DROP_USER_WITH_PERM_TEST__";
- root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
- test_user_conn.securityOperations().dropLocalUser(user);
- if (root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
- throw new IllegalStateException("Should be able to delete a user");
- break;
- case ALTER_USER:
- user = "__ALTER_USER_WITH_PERM_TEST__";
- root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
- test_user_conn.securityOperations().changeUserAuthorizations(user, new Authorizations("A", "B"));
- if (root_conn.securityOperations().getUserAuthorizations(user).isEmpty())
- throw new IllegalStateException("Should be able to alter a user");
- break;
- case SYSTEM:
- // test for system permission would go here
- break;
- default:
- throw new IllegalArgumentException("Unrecognized System Permission: " + perm);
- }
- }
-
- private static void verifyHasOnlyTheseSystemPermissions(Connector root_conn, String user, SystemPermission... perms) throws AccumuloException,
- AccumuloSecurityException {
- List<SystemPermission> permList = Arrays.asList(perms);
- for (SystemPermission p : SystemPermission.values()) {
- if (permList.contains(p)) {
- // should have these
- if (!root_conn.securityOperations().hasSystemPermission(user, p))
- throw new IllegalStateException(user + " SHOULD have system permission " + p);
- } else {
- // should not have these
- if (root_conn.securityOperations().hasSystemPermission(user, p))
- throw new IllegalStateException(user + " SHOULD NOT have system permission " + p);
- }
- }
- }
-
- private static void verifyHasNoSystemPermissions(Connector root_conn, String user, SystemPermission... perms) throws AccumuloException,
- AccumuloSecurityException {
- for (SystemPermission p : perms)
- if (root_conn.securityOperations().hasSystemPermission(user, p))
- throw new IllegalStateException(user + " SHOULD NOT have system permission " + p);
- }
- }
-
- public static class TablePermissionsTest extends FunctionalTest {
- private static final Logger log = Logger.getLogger(SystemPermissionsTest.class);
- private static final String TEST_TABLE = "__TABLE_PERMISSION_TEST__";
-
- @Override
- public void cleanup() throws Exception {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.emptyList();
- }
-
- @Override
- public void run() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, MutationsRejectedException {
- // create the test user
- getConnector().securityOperations().createLocalUser(TEST_USER, TEST_PASS);
- Connector test_user_conn = getInstance().getConnector(TEST_USER, TEST_PASS);
-
- // check for read-only access to metadata table
- verifyHasOnlyTheseTablePermissions(getConnector(), getConnector().whoami(), MetadataTable.NAME, TablePermission.READ,
- TablePermission.ALTER_TABLE);
- verifyHasOnlyTheseTablePermissions(getConnector(), TEST_USER, MetadataTable.NAME, TablePermission.READ);
-
- // test each permission
- for (TablePermission perm : TablePermission.values()) {
- log.debug("Verifying the " + perm + " permission");
-
- // test permission before and after granting it
- createTestTable();
- testMissingTablePermission(getConnector(), test_user_conn, perm);
- getConnector().securityOperations().grantTablePermission(TEST_USER, TEST_TABLE, perm);
- verifyHasOnlyTheseTablePermissions(getConnector(), TEST_USER, TEST_TABLE, perm);
- testGrantedTablePermission(getConnector(), test_user_conn, perm);
-
- createTestTable();
- getConnector().securityOperations().revokeTablePermission(TEST_USER, TEST_TABLE, perm);
- verifyHasNoTablePermissions(getConnector(), TEST_USER, TEST_TABLE, perm);
- }
- }
-
- private void createTestTable() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException,
- MutationsRejectedException {
- if (!getConnector().tableOperations().exists(TEST_TABLE)) {
- // create the test table
- getConnector().tableOperations().create(TEST_TABLE);
- // put in some initial data
- BatchWriter writer = getConnector().createBatchWriter(TEST_TABLE, new BatchWriterConfig());
- Mutation m = new Mutation(new Text("row"));
- m.put(new Text("cf"), new Text("cq"), new Value("val".getBytes()));
- writer.addMutation(m);
- writer.close();
-
- // verify proper permissions for creator and test user
- verifyHasOnlyTheseTablePermissions(getConnector(), getConnector().whoami(), TEST_TABLE, TablePermission.values());
- verifyHasNoTablePermissions(getConnector(), TEST_USER, TEST_TABLE, TablePermission.values());
-
- }
- }
-
- private static void testMissingTablePermission(Connector root_conn, Connector test_user_conn, TablePermission perm) throws AccumuloException,
- AccumuloSecurityException, TableNotFoundException {
- Scanner scanner;
- BatchWriter writer;
- Mutation m;
- log.debug("Confirming that the lack of the " + perm + " permission properly restricts the user");
-
- // test permission prior to granting it
- switch (perm) {
- case READ:
- try {
- scanner = test_user_conn.createScanner(TEST_TABLE, Authorizations.EMPTY);
- int i = 0;
- for (Entry<Key,Value> entry : scanner)
- i += 1 + entry.getKey().getRowData().length();
- if (i != 0)
- throw new IllegalStateException("Should NOT be able to read from the table");
- } catch (RuntimeException e) {
- AccumuloSecurityException se = (AccumuloSecurityException) e.getCause();
- if (se.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
- throw se;
- }
- break;
- case WRITE:
- try {
- writer = test_user_conn.createBatchWriter(TEST_TABLE, new BatchWriterConfig());
- m = new Mutation(new Text("row"));
- m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
- writer.addMutation(m);
- try {
- writer.close();
- } catch (MutationsRejectedException e1) {
- if (e1.getAuthorizationFailuresMap().size() > 0)
- throw new AccumuloSecurityException(test_user_conn.whoami(), org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode.PERMISSION_DENIED,
- e1);
- }
- throw new IllegalStateException("Should NOT be able to write to a table");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
- throw e;
- }
- break;
- case BULK_IMPORT:
- // test for bulk import permission would go here
- break;
- case ALTER_TABLE:
- Map<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
- groups.put("tgroup", new HashSet<Text>(Arrays.asList(new Text("t1"), new Text("t2"))));
- try {
- test_user_conn.tableOperations().setLocalityGroups(TEST_TABLE, groups);
- throw new IllegalStateException("User should not be able to set locality groups");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
- throw e;
- }
- break;
- case DROP_TABLE:
- try {
- test_user_conn.tableOperations().delete(TEST_TABLE);
- throw new IllegalStateException("User should not be able delete the table");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
- throw e;
- }
- break;
- case GRANT:
- try {
- test_user_conn.securityOperations().grantTablePermission("root", TEST_TABLE, TablePermission.GRANT);
- throw new IllegalStateException("User should not be able grant permissions");
- } catch (AccumuloSecurityException e) {
- if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
- throw e;
- }
- break;
- default:
- throw new IllegalArgumentException("Unrecognized table Permission: " + perm);
- }
- }
-
- private static void testGrantedTablePermission(Connector root_conn, Connector test_user_conn, TablePermission perm) throws AccumuloException,
- TableExistsException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException {
- Scanner scanner;
- BatchWriter writer;
- Mutation m;
- log.debug("Confirming that the presence of the " + perm + " permission properly permits the user");
-
- // test permission after granting it
- switch (perm) {
- case READ:
- scanner = test_user_conn.createScanner(TEST_TABLE, Authorizations.EMPTY);
- Iterator<Entry<Key,Value>> iter = scanner.iterator();
- while (iter.hasNext())
- iter.next();
- break;
- case WRITE:
- writer = test_user_conn.createBatchWriter(TEST_TABLE, new BatchWriterConfig());
- m = new Mutation(new Text("row"));
- m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
- writer.addMutation(m);
- writer.close();
- break;
- case BULK_IMPORT:
- // test for bulk import permission would go here
- break;
- case ALTER_TABLE:
- Map<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
- groups.put("tgroup", new HashSet<Text>(Arrays.asList(new Text("t1"), new Text("t2"))));
- break;
- case DROP_TABLE:
- test_user_conn.tableOperations().delete(TEST_TABLE);
- break;
- case GRANT:
- test_user_conn.securityOperations().grantTablePermission("root", TEST_TABLE, TablePermission.GRANT);
- break;
- default:
- throw new IllegalArgumentException("Unrecognized table Permission: " + perm);
- }
- }
-
- private static void verifyHasOnlyTheseTablePermissions(Connector root_conn, String user, String table, TablePermission... perms) throws AccumuloException,
- AccumuloSecurityException {
- List<TablePermission> permList = Arrays.asList(perms);
- for (TablePermission p : TablePermission.values()) {
- if (permList.contains(p)) {
- // should have these
- if (!root_conn.securityOperations().hasTablePermission(user, table, p))
- throw new IllegalStateException(user + " SHOULD have table permission " + p + " for table " + table);
- } else {
- // should not have these
- if (root_conn.securityOperations().hasTablePermission(user, table, p))
- throw new IllegalStateException(user + " SHOULD NOT have table permission " + p + " for table " + table);
- }
- }
- }
-
- private static void verifyHasNoTablePermissions(Connector root_conn, String user, String table, TablePermission... perms) throws AccumuloException,
- AccumuloSecurityException {
- for (TablePermission p : perms)
- if (root_conn.securityOperations().hasTablePermission(user, table, p))
- throw new IllegalStateException(user + " SHOULD NOT have table permission " + p + " for table " + table);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteTest.java b/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteTest.java
deleted file mode 100644
index cbf22d3..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteTest.java
+++ /dev/null
@@ -1,113 +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.functional;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-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.Value;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.accumulo.core.iterators.user.RowDeletingIterator;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.UtilWaitThread;
-
-public class RowDeleteTest extends FunctionalTest {
-
- @Override
- public void cleanup() throws Exception {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- HashMap<String,String> conf = new HashMap<String,String>();
- conf.put(Property.TSERV_MAJC_DELAY.getKey(), "50ms");
- return conf;
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- TableSetup ts1 = new TableSetup("rdel1", parseConfig(Property.TABLE_LOCALITY_GROUPS + "=lg1,dg", Property.TABLE_LOCALITY_GROUP_PREFIX + "lg1=foo",
- Property.TABLE_LOCALITY_GROUP_PREFIX + "dg=",
- Property.TABLE_ITERATOR_PREFIX + "" + IteratorScope.majc + ".rdel=30," + RowDeletingIterator.class.getName(), Property.TABLE_MAJC_RATIO + "=100"));
- return Collections.singletonList(ts1);
- }
-
- @Override
- public void run() throws Exception {
- BatchWriter bw = getConnector().createBatchWriter("rdel1", new BatchWriterConfig());
-
- bw.addMutation(nm("r1", "foo", "cf1", "v1"));
- bw.addMutation(nm("r1", "bar", "cf1", "v2"));
-
- bw.flush();
- getConnector().tableOperations().flush("rdel1", null, null, true);
-
- checkRFiles("rdel1", 1, 1, 1, 1);
-
- int count = 0;
- Scanner scanner = getConnector().createScanner("rdel1", Authorizations.EMPTY);
- for (@SuppressWarnings("unused")
- Entry<Key,Value> entry : scanner) {
- count++;
- }
- if (count != 2)
- throw new Exception("1 count=" + count);
-
- bw.addMutation(nm("r1", "", "", RowDeletingIterator.DELETE_ROW_VALUE));
-
- bw.flush();
- getConnector().tableOperations().flush("rdel1", null, null, true);
-
- // Wait for the files in HDFS to be older than the future compaction date
- UtilWaitThread.sleep(2000);
-
- checkRFiles("rdel1", 1, 1, 2, 2);
-
- count = 0;
- scanner = getConnector().createScanner("rdel1", Authorizations.EMPTY);
- for (@SuppressWarnings("unused")
- Entry<Key,Value> entry : scanner) {
- count++;
- }
- if (count != 3)
- throw new Exception("2 count=" + count);
-
- getConnector().tableOperations().compact("rdel1", null, null, false, true);
-
- checkRFiles("rdel1", 1, 1, 0, 0);
-
- count = 0;
- scanner = getConnector().createScanner("rdel1", Authorizations.EMPTY);
- for (@SuppressWarnings("unused")
- Entry<Key,Value> entry : scanner) {
- count++;
- }
- if (count != 0)
- throw new Exception("3 count=" + count);
-
- bw.close();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorTest.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorTest.java
deleted file mode 100644
index 5e42525..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorTest.java
+++ /dev/null
@@ -1,136 +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.functional;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.ScannerBase;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-
-public class ScanIteratorTest extends FunctionalTest {
-
- @Override
- public void cleanup() throws Exception {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.singletonList(new TableSetup("foo"));
- }
-
- @Override
- public void run() throws Exception {
-
- BatchWriter bw = getConnector().createBatchWriter("foo", new BatchWriterConfig());
-
- for (int i = 0; i < 1000; i++) {
- Mutation m = new Mutation(new Text(String.format("%06d", i)));
- m.put(new Text("cf1"), new Text("cq1"), new Value(("" + (1000 - i)).getBytes()));
- m.put(new Text("cf1"), new Text("cq2"), new Value(("" + (i - 1000)).getBytes()));
-
- bw.addMutation(m);
- }
-
- bw.close();
-
- Scanner scanner = getConnector().createScanner("foo", new Authorizations());
-
- setupIter(scanner);
- verify(scanner, 1, 999);
-
- BatchScanner bscanner = getConnector().createBatchScanner("foo", new Authorizations(), 3);
- bscanner.setRanges(Collections.singleton(new Range((Key) null, null)));
-
- setupIter(bscanner);
- verify(bscanner, 1, 999);
-
- ArrayList<Range> ranges = new ArrayList<Range>();
- ranges.add(new Range(new Text(String.format("%06d", 1))));
- ranges.add(new Range(new Text(String.format("%06d", 6)), new Text(String.format("%06d", 16))));
- ranges.add(new Range(new Text(String.format("%06d", 20))));
- ranges.add(new Range(new Text(String.format("%06d", 23))));
- ranges.add(new Range(new Text(String.format("%06d", 56)), new Text(String.format("%06d", 61))));
- ranges.add(new Range(new Text(String.format("%06d", 501)), new Text(String.format("%06d", 504))));
- ranges.add(new Range(new Text(String.format("%06d", 998)), new Text(String.format("%06d", 1000))));
-
- HashSet<Integer> got = new HashSet<Integer>();
- HashSet<Integer> expected = new HashSet<Integer>();
- for (int i : new int[] {1, 7, 9, 11, 13, 15, 23, 57, 59, 61, 501, 503, 999}) {
- expected.add(i);
- }
-
- bscanner.setRanges(ranges);
-
- for (Entry<Key,Value> entry : bscanner) {
- got.add(Integer.parseInt(entry.getKey().getRow().toString()));
- }
-
- System.out.println("got : " + got);
-
- if (!got.equals(expected)) {
- throw new Exception(got + " != " + expected);
- }
-
- bscanner.close();
-
- }
-
- private void verify(Iterable<Entry<Key,Value>> scanner, int start, int finish) throws Exception {
-
- int expected = start;
- for (Entry<Key,Value> entry : scanner) {
- if (Integer.parseInt(entry.getKey().getRow().toString()) != expected) {
- throw new Exception("Saw unexpexted " + entry.getKey().getRow() + " " + expected);
- }
-
- if (entry.getKey().getColumnQualifier().toString().equals("cq2")) {
- expected += 2;
- }
- }
-
- if (expected != finish + 2) {
- throw new Exception("Ended at " + expected + " not " + (finish + 2));
- }
- }
-
- private void setupIter(ScannerBase scanner) throws Exception {
- IteratorSetting dropMod = new IteratorSetting(50, "dropMod", "org.apache.accumulo.test.functional.DropModIter");
- dropMod.addOption("mod", "2");
- dropMod.addOption("drop", "0");
- scanner.addScanIterator(dropMod);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeTest.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeTest.java
deleted file mode 100644
index f5a6f17..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeTest.java
+++ /dev/null
@@ -1,250 +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.functional;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-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.Scanner;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-
-public class ScanRangeTest extends FunctionalTest {
-
- private static final int TS_LIMIT = 1;
- private static final int CQ_LIMIT = 5;
- private static final int CF_LIMIT = 5;
- private static final int ROW_LIMIT = 100;
-
- @Override
- public void cleanup() {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- return Collections.emptyMap();
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- ArrayList<TableSetup> ts = new ArrayList<TableSetup>();
- ts.add(new TableSetup("table1"));
-
- TreeSet<Text> splitRows = new TreeSet<Text>();
- int splits = 3;
- for (int i = (ROW_LIMIT / splits); i < ROW_LIMIT; i += (ROW_LIMIT / splits))
- splitRows.add(createRow(i));
-
- Map<String,String> empty = Collections.emptyMap();
- ts.add(new TableSetup("table2", empty, splitRows));
-
- return ts;
- }
-
- @Override
- public void run() throws Exception {
- insertData("table1");
- scanTable("table1");
-
- insertData("table2");
- scanTable("table2");
- }
-
- private void scanTable(String table) throws Exception {
- scanRange(table, new IntKey(0, 0, 0, 0), new IntKey(1, 0, 0, 0));
-
- scanRange(table, new IntKey(0, 0, 0, 0), new IntKey(ROW_LIMIT - 1, CF_LIMIT - 1, CQ_LIMIT - 1, 0));
-
- scanRange(table, null, null);
-
- for (int i = 0; i < ROW_LIMIT; i += (ROW_LIMIT / 3)) {
- for (int j = 0; j < CF_LIMIT; j += (CF_LIMIT / 2)) {
- for (int k = 1; k < CQ_LIMIT; k += (CQ_LIMIT / 2)) {
- scanRange(table, null, new IntKey(i, j, k, 0));
- scanRange(table, new IntKey(0, 0, 0, 0), new IntKey(i, j, k, 0));
-
- scanRange(table, new IntKey(i, j, k, 0), new IntKey(ROW_LIMIT - 1, CF_LIMIT - 1, CQ_LIMIT - 1, 0));
-
- scanRange(table, new IntKey(i, j, k, 0), null);
-
- }
- }
- }
-
- for (int i = 0; i < ROW_LIMIT; i++) {
- scanRange(table, new IntKey(i, 0, 0, 0), new IntKey(i, CF_LIMIT - 1, CQ_LIMIT - 1, 0));
-
- if (i > 0 && i < ROW_LIMIT - 1) {
- scanRange(table, new IntKey(i - 1, 0, 0, 0), new IntKey(i + 1, CF_LIMIT - 1, CQ_LIMIT - 1, 0));
- }
- }
-
- }
-
- private static class IntKey {
- private int row;
- private int cf;
- private int cq;
- private long ts;
-
- IntKey(IntKey ik) {
- this.row = ik.row;
- this.cf = ik.cf;
- this.cq = ik.cq;
- this.ts = ik.ts;
- }
-
- IntKey(int row, int cf, int cq, long ts) {
- this.row = row;
- this.cf = cf;
- this.cq = cq;
- this.ts = ts;
- }
-
- Key createKey() {
- Text trow = createRow(row);
- Text tcf = createCF(cf);
- Text tcq = createCQ(cq);
-
- return new Key(trow, tcf, tcq, ts);
- }
-
- IntKey increment() {
-
- IntKey ik = new IntKey(this);
-
- ik.ts++;
- if (ik.ts >= TS_LIMIT) {
- ik.ts = 0;
- ik.cq++;
- if (ik.cq >= CQ_LIMIT) {
- ik.cq = 0;
- ik.cf++;
- if (ik.cf >= CF_LIMIT) {
- ik.cf = 0;
- ik.row++;
- }
- }
- }
-
- return ik;
- }
-
- }
-
- private void scanRange(String table, IntKey ik1, IntKey ik2) throws Exception {
- scanRange(table, ik1, false, ik2, false);
- scanRange(table, ik1, false, ik2, true);
- scanRange(table, ik1, true, ik2, false);
- scanRange(table, ik1, true, ik2, true);
- }
-
- private void scanRange(String table, IntKey ik1, boolean inclusive1, IntKey ik2, boolean inclusive2) throws Exception {
- Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY);
-
- Key key1 = null;
- Key key2 = null;
-
- IntKey expectedIntKey;
- IntKey expectedEndIntKey;
-
- if (ik1 != null) {
- key1 = ik1.createKey();
- expectedIntKey = ik1;
-
- if (!inclusive1) {
- expectedIntKey = expectedIntKey.increment();
- }
- } else {
- expectedIntKey = new IntKey(0, 0, 0, 0);
- }
-
- if (ik2 != null) {
- key2 = ik2.createKey();
- expectedEndIntKey = ik2;
-
- if (inclusive2) {
- expectedEndIntKey = expectedEndIntKey.increment();
- }
- } else {
- expectedEndIntKey = new IntKey(ROW_LIMIT, 0, 0, 0);
- }
-
- Range range = new Range(key1, inclusive1, key2, inclusive2);
-
- scanner.setRange(range);
-
- for (Entry<Key,Value> entry : scanner) {
-
- Key expectedKey = expectedIntKey.createKey();
- if (!expectedKey.equals(entry.getKey())) {
- throw new Exception(" " + expectedKey + " != " + entry.getKey());
- }
-
- expectedIntKey = expectedIntKey.increment();
- }
-
- if (!expectedIntKey.createKey().equals(expectedEndIntKey.createKey())) {
- throw new Exception(" " + expectedIntKey.createKey() + " != " + expectedEndIntKey.createKey());
- }
- }
-
- private static Text createCF(int cf) {
- Text tcf = new Text(String.format("cf_%03d", cf));
- return tcf;
- }
-
- private static Text createCQ(int cf) {
- Text tcf = new Text(String.format("cq_%03d", cf));
- return tcf;
- }
-
- private static Text createRow(int row) {
- Text trow = new Text(String.format("r_%06d", row));
- return trow;
- }
-
- private void insertData(String table) throws Exception {
-
- BatchWriter bw = getConnector().createBatchWriter(table, new BatchWriterConfig());
-
- for (int i = 0; i < ROW_LIMIT; i++) {
- Mutation m = new Mutation(createRow(i));
-
- for (int j = 0; j < CF_LIMIT; j++) {
- for (int k = 0; k < CQ_LIMIT; k++) {
- for (int t = 0; t < TS_LIMIT; t++) {
- m.put(createCF(j), createCQ(k), t, new Value(String.format("%06d_%03d_%03d_%03d", i, j, k, t).getBytes()));
- }
- }
- }
-
- bw.addMutation(m);
- }
-
- bw.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aea43136/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutTest.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutTest.java
deleted file mode 100644
index 1551687..0000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutTest.java
+++ /dev/null
@@ -1,112 +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.functional;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-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.core.util.UtilWaitThread;
-import org.apache.hadoop.io.Text;
-
-public class ScanSessionTimeOutTest extends FunctionalTest {
-
- @Override
- public void cleanup() throws Exception {}
-
- @Override
- public Map<String,String> getInitialConfig() {
- HashMap<String,String> config = new HashMap<String,String>();
- // set the session idle time 3 seconds
- config.put(Property.TSERV_SESSION_MAXIDLE.getKey(), "3");
- return config;
- }
-
- @Override
- public List<TableSetup> getTablesToCreate() {
- return Collections.singletonList(new TableSetup("abc"));
- }
-
- @Override
- public void run() throws Exception {
- BatchWriter bw = getConnector().createBatchWriter("abc", new BatchWriterConfig());
-
- for (int i = 0; i < 100000; i++) {
- Mutation m = new Mutation(new Text(String.format("%08d", i)));
- for (int j = 0; j < 3; j++)
- m.put(new Text("cf1"), new Text("cq" + j), new Value(("" + i + "_" + j).getBytes()));
-
- bw.addMutation(m);
- }
-
- bw.close();
-
- Scanner scanner = getConnector().createScanner("abc", new Authorizations());
- scanner.setBatchSize(1000);
-
- Iterator<Entry<Key,Value>> iter = scanner.iterator();
-
- verify(iter, 0, 200);
-
- // sleep three times the session timeout
- UtilWaitThread.sleep(9000);
-
- verify(iter, 200, 100000);
-
- }
-
- private void verify(Iterator<Entry<Key,Value>> iter, int start, int stop) throws Exception {
- for (int i = start; i < stop; i++) {
-
- Text er = new Text(String.format("%08d", i));
-
- for (int j = 0; j < 3; j++) {
- Entry<Key,Value> entry = iter.next();
-
- if (!entry.getKey().getRow().equals(er)) {
- throw new Exception("row " + entry.getKey().getRow() + " != " + er);
- }
-
- if (!entry.getKey().getColumnFamily().equals(new Text("cf1"))) {
- throw new Exception("cf " + entry.getKey().getColumnFamily() + " != cf1");
- }
-
- if (!entry.getKey().getColumnQualifier().equals(new Text("cq" + j))) {
- throw new Exception("cq " + entry.getKey().getColumnQualifier() + " != cq" + j);
- }
-
- if (!entry.getValue().toString().equals("" + i + "_" + j)) {
- throw new Exception("value " + entry.getValue() + " != " + i + "_" + j);
- }
-
- }
- }
-
- }
-
-}