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/10/11 08:37:09 UTC
[4/4] git commit: ACCUMULO-1599 Move MiniAccumuloCluster output to
target directory
ACCUMULO-1599 Move MiniAccumuloCluster output to target directory
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/aa711023
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/aa711023
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/aa711023
Branch: refs/heads/master
Commit: aa7110234e15a017bb1dbc99b4351f0bf06cc73b
Parents: 741daec
Author: Christopher Tubbs <ct...@apache.org>
Authored: Fri Oct 11 02:21:11 2013 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Fri Oct 11 02:22:29 2013 -0400
----------------------------------------------------------------------
.../mapred/AccumuloFileOutputFormatTest.java | 83 ++-
.../core/client/mapred/TokenFileTest.java | 53 +-
.../mapreduce/AccumuloFileOutputFormatTest.java | 79 ++-
.../core/client/mapreduce/TokenFileTest.java | 51 +-
.../minicluster/MiniAccumuloCluster.java | 6 +-
.../minicluster/MiniAccumuloClusterGCTest.java | 17 +-
.../minicluster/MiniAccumuloClusterTest.java | 31 +-
.../minicluster/MiniAccumuloConfigTest.java | 7 +-
.../org/apache/accumulo/proxy/SimpleTest.java | 294 +++++----
.../tabletserver/log/MultiReaderTest.java | 29 +-
.../tabletserver/log/SortedLogRecoveryTest.java | 109 ++--
.../AccumuloReloadingVFSClassLoaderTest.java | 54 +-
.../vfs/AccumuloVFSClassLoaderTest.java | 15 +-
.../classloader/vfs/ContextManagerTest.java | 32 +-
test/pom.xml | 3 +-
.../accumulo/fate/zookeeper/ZooLockTest.java | 223 +++----
.../apache/accumulo/test/AuditMessageTest.java | 132 ++---
.../org/apache/accumulo/test/BatchWriterIT.java | 12 +-
.../accumulo/test/ConditionalWriterTest.java | 593 ++++++++++---------
.../org/apache/accumulo/test/DumpConfigIT.java | 28 +-
.../org/apache/accumulo/test/MetaSplitTest.java | 19 +-
.../org/apache/accumulo/test/ShellServerIT.java | 20 +-
.../apache/accumulo/test/TableOperationsIT.java | 51 +-
.../test/TestAccumuloSplitRecovery.java | 47 +-
.../org/apache/accumulo/test/VolumeTest.java | 17 +-
.../accumulo/test/functional/AbstractMacIT.java | 81 +--
.../accumulo/test/functional/AddSplitIT.java | 62 +-
.../test/functional/BadIteratorMincIT.java | 41 +-
.../test/functional/BatchScanSplitIT.java | 48 +-
.../test/functional/BatchWriterFlushIT.java | 82 +--
.../accumulo/test/functional/BinaryIT.java | 9 +-
.../accumulo/test/functional/BulkFileIT.java | 46 +-
.../apache/accumulo/test/functional/BulkIT.java | 10 +-
.../functional/BulkSplitOptimizationIT.java | 26 +-
.../accumulo/test/functional/ClassLoaderIT.java | 6 +-
.../accumulo/test/functional/CleanTmpIT.java | 2 +-
.../accumulo/test/functional/CloneTestIT.java | 92 +--
.../accumulo/test/functional/CombinerIT.java | 8 +-
.../accumulo/test/functional/CompactionIT.java | 22 +-
.../test/functional/ConfigurableMacIT.java | 53 +-
.../accumulo/test/functional/ConstraintIT.java | 136 ++---
.../test/functional/CreateAndUseIT.java | 51 +-
.../test/functional/CreateManyScannersIT.java | 6 +-
.../accumulo/test/functional/DeleteRowsIT.java | 12 +-
.../test/functional/DeleteRowsSplitIT.java | 32 +-
.../test/functional/FateStarvationIT.java | 20 +-
.../test/functional/GarbageCollectorIT.java | 21 +-
.../accumulo/test/functional/MapReduceIT.java | 24 +-
.../accumulo/test/functional/MergeIT.java | 56 +-
.../accumulo/test/functional/MetadataIT.java | 2 +-
.../accumulo/test/functional/NativeMapIT.java | 6 +-
.../accumulo/test/functional/PermissionsIT.java | 87 ++-
.../accumulo/test/functional/RenameIT.java | 9 +-
.../test/functional/ScanIteratorIT.java | 48 +-
.../accumulo/test/functional/ScanRangeIT.java | 99 ++--
.../test/functional/ServerSideErrorIT.java | 36 +-
.../accumulo/test/functional/SimpleMacIT.java | 59 +-
.../test/functional/SparseColumnFamilyIT.java | 26 +-
.../test/functional/SplitRecoveryIT.java | 6 +-
.../accumulo/test/functional/StartIT.java | 9 +-
.../accumulo/test/functional/TableIT.java | 6 +-
.../accumulo/test/functional/TimeoutIT.java | 41 +-
.../accumulo/test/functional/VisibilityIT.java | 109 ++--
.../accumulo/test/functional/WriteLotsIT.java | 7 +-
.../accumulo/test/functional/ZooCacheIT.java | 19 +-
65 files changed, 1809 insertions(+), 1711 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormatTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormatTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormatTest.java
index b71ad07..565b618 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloFileOutputFormatTest.java
@@ -46,8 +46,8 @@ import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.lib.IdentityMapper;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -57,15 +57,15 @@ public class AccumuloFileOutputFormatTest {
private static final String BAD_TABLE = PREFIX + "_mapred_bad_table";
private static final String TEST_TABLE = PREFIX + "_mapred_test_table";
private static final String EMPTY_TABLE = PREFIX + "_mapred_empty_table";
-
- public static TemporaryFolder folder = new TemporaryFolder();
+
private static AssertionError e1 = null;
private static AssertionError e2 = null;
-
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
@BeforeClass
public static void setup() throws Exception {
- folder.create();
-
MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
Connector c = mockInstance.getConnector("root", new PasswordToken(""));
c.tableOperations().create(EMPTY_TABLE);
@@ -84,27 +84,22 @@ public class AccumuloFileOutputFormatTest {
bw.addMutation(m);
bw.close();
}
-
- @AfterClass
- public static void teardown() throws IOException {
- folder.delete();
- }
-
+
@Test
public void testEmptyWrite() throws Exception {
handleWriteTests(false);
}
-
+
@Test
public void testRealWrite() throws Exception {
handleWriteTests(true);
}
-
+
private static class MRTester extends Configured implements Tool {
private static class BadKeyMapper implements Mapper<Key,Value,Key,Value> {
-
+
int index = 0;
-
+
@Override
public void map(Key key, Value value, OutputCollector<Key,Value> output, Reporter reporter) throws IOException {
try {
@@ -120,10 +115,10 @@ public class AccumuloFileOutputFormatTest {
}
index++;
}
-
+
@Override
public void configure(JobConf job) {}
-
+
@Override
public void close() throws IOException {
try {
@@ -132,50 +127,50 @@ public class AccumuloFileOutputFormatTest {
e2 = e;
}
}
-
+
}
-
+
@Override
public int run(String[] args) throws Exception {
-
+
if (args.length != 4) {
throw new IllegalArgumentException("Usage : " + MRTester.class.getName() + " <user> <pass> <table> <outputfile>");
}
-
+
String user = args[0];
String pass = args[1];
String table = args[2];
-
+
JobConf job = new JobConf(getConf());
job.setJarByClass(this.getClass());
-
+
job.setInputFormat(AccumuloInputFormat.class);
-
+
AccumuloInputFormat.setConnectorInfo(job, user, new PasswordToken(pass));
AccumuloInputFormat.setInputTableName(job, table);
AccumuloInputFormat.setMockInstance(job, INSTANCE_NAME);
AccumuloFileOutputFormat.setOutputPath(job, new Path(args[3]));
-
+
job.setMapperClass(BAD_TABLE.equals(table) ? BadKeyMapper.class : IdentityMapper.class);
job.setMapOutputKeyClass(Key.class);
job.setMapOutputValueClass(Value.class);
job.setOutputFormat(AccumuloFileOutputFormat.class);
-
+
job.setNumReduceTasks(0);
-
+
return JobClient.runJob(job).isSuccessful() ? 0 : 1;
}
-
+
public static void main(String[] args) throws Exception {
assertEquals(0, ToolRunner.run(CachedConfiguration.getInstance(), new MRTester(), args));
}
}
-
+
public void handleWriteTests(boolean content) throws Exception {
- File f = folder.newFile();
+ File f = folder.newFile("handleWriteTests");
f.delete();
MRTester.main(new String[] {"root", "", content ? TEST_TABLE : EMPTY_TABLE, f.getAbsolutePath()});
-
+
assertTrue(f.exists());
File[] files = f.listFiles(new FileFilter() {
@Override
@@ -190,60 +185,60 @@ public class AccumuloFileOutputFormatTest {
assertEquals(0, files.length);
}
}
-
+
@Test
public void writeBadVisibility() throws Exception {
- File f = folder.newFile();
+ File f = folder.newFile("writeBadVisibility");
f.delete();
MRTester.main(new String[] {"root", "", BAD_TABLE, f.getAbsolutePath()});
assertNull(e1);
assertNull(e2);
}
-
+
@Test
public void validateConfiguration() throws IOException, InterruptedException {
-
+
int a = 7;
long b = 300l;
long c = 50l;
long d = 10l;
String e = "snappy";
-
+
JobConf job = new JobConf();
AccumuloFileOutputFormat.setReplication(job, a);
AccumuloFileOutputFormat.setFileBlockSize(job, b);
AccumuloFileOutputFormat.setDataBlockSize(job, c);
AccumuloFileOutputFormat.setIndexBlockSize(job, d);
AccumuloFileOutputFormat.setCompressionType(job, e);
-
+
AccumuloConfiguration acuconf = AccumuloFileOutputFormat.getAccumuloConfiguration(job);
-
+
assertEquals(7, acuconf.getCount(Property.TABLE_FILE_REPLICATION));
assertEquals(300l, acuconf.getMemoryInBytes(Property.TABLE_FILE_BLOCK_SIZE));
assertEquals(50l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE));
assertEquals(10l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX));
assertEquals("snappy", acuconf.get(Property.TABLE_FILE_COMPRESSION_TYPE));
-
+
a = 17;
b = 1300l;
c = 150l;
d = 110l;
e = "lzo";
-
+
job = new JobConf();
AccumuloFileOutputFormat.setReplication(job, a);
AccumuloFileOutputFormat.setFileBlockSize(job, b);
AccumuloFileOutputFormat.setDataBlockSize(job, c);
AccumuloFileOutputFormat.setIndexBlockSize(job, d);
AccumuloFileOutputFormat.setCompressionType(job, e);
-
+
acuconf = AccumuloFileOutputFormat.getAccumuloConfiguration(job);
-
+
assertEquals(17, acuconf.getCount(Property.TABLE_FILE_REPLICATION));
assertEquals(1300l, acuconf.getMemoryInBytes(Property.TABLE_FILE_BLOCK_SIZE));
assertEquals(150l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE));
assertEquals(110l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX));
assertEquals("lzo", acuconf.get(Property.TABLE_FILE_COMPRESSION_TYPE));
-
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/core/src/test/java/org/apache/accumulo/core/client/mapred/TokenFileTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapred/TokenFileTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapred/TokenFileTest.java
index f1a95a1..0e1fe39 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapred/TokenFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapred/TokenFileTest.java
@@ -39,6 +39,7 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.Credentials;
import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobClient;
@@ -48,7 +49,9 @@ import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
/**
*
@@ -59,13 +62,13 @@ public class TokenFileTest {
private static final String INSTANCE_NAME = PREFIX + "_mapred_instance";
private static final String TEST_TABLE_1 = PREFIX + "_mapred_table_1";
private static final String TEST_TABLE_2 = PREFIX + "_mapred_table_2";
-
+
private static class MRTokenFileTester extends Configured implements Tool {
private static class TestMapper implements Mapper<Key,Value,Text,Mutation> {
Key key = null;
int count = 0;
OutputCollector<Text,Mutation> finalOutput;
-
+
@Override
public void map(Key k, Value v, OutputCollector<Text,Mutation> output, Reporter reporter) throws IOException {
finalOutput = output;
@@ -80,62 +83,67 @@ public class TokenFileTest {
key = new Key(k);
count++;
}
-
+
@Override
public void configure(JobConf job) {}
-
+
@Override
public void close() throws IOException {
Mutation m = new Mutation("total");
m.put("", "", Integer.toString(count));
finalOutput.collect(new Text(), m);
}
-
+
}
-
+
@Override
public int run(String[] args) throws Exception {
-
+
if (args.length != 4) {
throw new IllegalArgumentException("Usage : " + MRTokenFileTester.class.getName() + " <user> <token file> <inputtable> <outputtable>");
}
-
+
String user = args[0];
String tokenFile = args[1];
String table1 = args[2];
String table2 = args[3];
-
+
JobConf job = new JobConf(getConf());
job.setJarByClass(this.getClass());
-
+
job.setInputFormat(AccumuloInputFormat.class);
-
+
AccumuloInputFormat.setConnectorInfo(job, user, tokenFile);
AccumuloInputFormat.setInputTableName(job, table1);
AccumuloInputFormat.setMockInstance(job, INSTANCE_NAME);
-
+
job.setMapperClass(TestMapper.class);
job.setMapOutputKeyClass(Key.class);
job.setMapOutputValueClass(Value.class);
job.setOutputFormat(AccumuloOutputFormat.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Mutation.class);
-
+
AccumuloOutputFormat.setConnectorInfo(job, user, tokenFile);
AccumuloOutputFormat.setCreateTables(job, false);
AccumuloOutputFormat.setDefaultTableName(job, table2);
AccumuloOutputFormat.setMockInstance(job, INSTANCE_NAME);
-
+
job.setNumReduceTasks(0);
-
+
return JobClient.runJob(job).isSuccessful() ? 0 : 1;
}
-
+
public static void main(String[] args) throws Exception {
- assertEquals(0, ToolRunner.run(CachedConfiguration.getInstance(), new MRTokenFileTester(), args));
+ Configuration conf = CachedConfiguration.getInstance();
+ conf.set("hadoop.tmp.dir", new File(args[1]).getParent());
+ assertEquals(0, ToolRunner.run(conf, new MRTokenFileTester(), args));
}
}
-
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
@Test
public void testMR() throws Exception {
MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
@@ -149,17 +157,16 @@ public class TokenFileTest {
bw.addMutation(m);
}
bw.close();
-
- String tokenFile = "root_test.pw";
- File tf = File.createTempFile(tokenFile, "");
+
+ File tf = folder.newFile("root_test.pw");
PrintStream out = new PrintStream(tf);
String outString = new Credentials("root", new PasswordToken("")).serialize();
out.println(outString);
out.close();
-
+
MRTokenFileTester.main(new String[] {"root", tf.getAbsolutePath(), TEST_TABLE_1, TEST_TABLE_2});
assertNull(e1);
-
+
Scanner scanner = c.createScanner(TEST_TABLE_2, new Authorizations());
Iterator<Entry<Key,Value>> iter = scanner.iterator();
assertTrue(iter.hasNext());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
index ae756a5..3746e5b 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
@@ -41,8 +41,8 @@ import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -52,15 +52,15 @@ public class AccumuloFileOutputFormatTest {
private static final String BAD_TABLE = PREFIX + "_mapreduce_bad_table";
private static final String TEST_TABLE = PREFIX + "_mapreduce_test_table";
private static final String EMPTY_TABLE = PREFIX + "_mapreduce_empty_table";
-
- public static TemporaryFolder folder = new TemporaryFolder();
+
private static AssertionError e1 = null;
private static AssertionError e2 = null;
-
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
@BeforeClass
public static void setup() throws Exception {
- folder.create();
-
MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
Connector c = mockInstance.getConnector("root", new PasswordToken(""));
c.tableOperations().create(EMPTY_TABLE);
@@ -79,26 +79,21 @@ public class AccumuloFileOutputFormatTest {
bw.addMutation(m);
bw.close();
}
-
- @AfterClass
- public static void teardown() throws IOException {
- folder.delete();
- }
-
+
@Test
public void testEmptyWrite() throws Exception {
handleWriteTests(false);
}
-
+
@Test
public void testRealWrite() throws Exception {
handleWriteTests(true);
}
-
+
private static class MRTester extends Configured implements Tool {
private static class BadKeyMapper extends Mapper<Key,Value,Key,Value> {
int index = 0;
-
+
@Override
protected void map(Key key, Value value, Context context) throws IOException, InterruptedException {
try {
@@ -114,7 +109,7 @@ public class AccumuloFileOutputFormatTest {
}
index++;
}
-
+
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
try {
@@ -124,50 +119,50 @@ public class AccumuloFileOutputFormatTest {
}
}
}
-
+
@Override
public int run(String[] args) throws Exception {
-
+
if (args.length != 4) {
throw new IllegalArgumentException("Usage : " + MRTester.class.getName() + " <user> <pass> <table> <outputfile>");
}
-
+
String user = args[0];
String pass = args[1];
String table = args[2];
-
+
Job job = new Job(getConf(), this.getClass().getSimpleName() + "_" + System.currentTimeMillis());
job.setJarByClass(this.getClass());
-
+
job.setInputFormatClass(AccumuloInputFormat.class);
-
+
AccumuloInputFormat.setConnectorInfo(job, user, new PasswordToken(pass));
AccumuloInputFormat.setInputTableName(job, table);
AccumuloInputFormat.setMockInstance(job, INSTANCE_NAME);
AccumuloFileOutputFormat.setOutputPath(job, new Path(args[3]));
-
+
job.setMapperClass(BAD_TABLE.equals(table) ? BadKeyMapper.class : Mapper.class);
job.setMapOutputKeyClass(Key.class);
job.setMapOutputValueClass(Value.class);
job.setOutputFormatClass(AccumuloFileOutputFormat.class);
-
+
job.setNumReduceTasks(0);
-
+
job.waitForCompletion(true);
-
+
return job.isSuccessful() ? 0 : 1;
}
-
+
public static void main(String[] args) throws Exception {
assertEquals(0, ToolRunner.run(CachedConfiguration.getInstance(), new MRTester(), args));
}
}
-
+
public void handleWriteTests(boolean content) throws Exception {
- File f = folder.newFile();
+ File f = folder.newFile("handleWriteTests");
f.delete();
MRTester.main(new String[] {"root", "", content ? TEST_TABLE : EMPTY_TABLE, f.getAbsolutePath()});
-
+
assertTrue(f.exists());
File[] files = f.listFiles(new FileFilter() {
@Override
@@ -182,60 +177,60 @@ public class AccumuloFileOutputFormatTest {
assertEquals(0, files.length);
}
}
-
+
@Test
public void writeBadVisibility() throws Exception {
- File f = folder.newFile();
+ File f = folder.newFile("writeBadVisibility");
f.delete();
MRTester.main(new String[] {"root", "", BAD_TABLE, f.getAbsolutePath()});
assertNull(e1);
assertNull(e2);
}
-
+
@Test
public void validateConfiguration() throws IOException, InterruptedException {
-
+
int a = 7;
long b = 300l;
long c = 50l;
long d = 10l;
String e = "snappy";
-
+
Job job = new Job();
AccumuloFileOutputFormat.setReplication(job, a);
AccumuloFileOutputFormat.setFileBlockSize(job, b);
AccumuloFileOutputFormat.setDataBlockSize(job, c);
AccumuloFileOutputFormat.setIndexBlockSize(job, d);
AccumuloFileOutputFormat.setCompressionType(job, e);
-
+
AccumuloConfiguration acuconf = AccumuloFileOutputFormat.getAccumuloConfiguration(job);
-
+
assertEquals(7, acuconf.getCount(Property.TABLE_FILE_REPLICATION));
assertEquals(300l, acuconf.getMemoryInBytes(Property.TABLE_FILE_BLOCK_SIZE));
assertEquals(50l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE));
assertEquals(10l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX));
assertEquals("snappy", acuconf.get(Property.TABLE_FILE_COMPRESSION_TYPE));
-
+
a = 17;
b = 1300l;
c = 150l;
d = 110l;
e = "lzo";
-
+
job = new Job();
AccumuloFileOutputFormat.setReplication(job, a);
AccumuloFileOutputFormat.setFileBlockSize(job, b);
AccumuloFileOutputFormat.setDataBlockSize(job, c);
AccumuloFileOutputFormat.setIndexBlockSize(job, d);
AccumuloFileOutputFormat.setCompressionType(job, e);
-
+
acuconf = AccumuloFileOutputFormat.getAccumuloConfiguration(job);
-
+
assertEquals(17, acuconf.getCount(Property.TABLE_FILE_REPLICATION));
assertEquals(1300l, acuconf.getMemoryInBytes(Property.TABLE_FILE_BLOCK_SIZE));
assertEquals(150l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE));
assertEquals(110l, acuconf.getMemoryInBytes(Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE_INDEX));
assertEquals("lzo", acuconf.get(Property.TABLE_FILE_COMPRESSION_TYPE));
-
+
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/core/src/test/java/org/apache/accumulo/core/client/mapreduce/TokenFileTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/TokenFileTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/TokenFileTest.java
index f0277fc..02c0604 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/TokenFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/TokenFileTest.java
@@ -39,13 +39,16 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.Credentials;
import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
/**
*
@@ -56,12 +59,12 @@ public class TokenFileTest {
private static final String INSTANCE_NAME = PREFIX + "_mapreduce_instance";
private static final String TEST_TABLE_1 = PREFIX + "_mapreduce_table_1";
private static final String TEST_TABLE_2 = PREFIX + "_mapreduce_table_2";
-
+
private static class MRTokenFileTester extends Configured implements Tool {
private static class TestMapper extends Mapper<Key,Value,Text,Mutation> {
Key key = null;
int count = 0;
-
+
@Override
protected void map(Key k, Value v, Context context) throws IOException, InterruptedException {
try {
@@ -75,7 +78,7 @@ public class TokenFileTest {
key = new Key(k);
count++;
}
-
+
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
Mutation m = new Mutation("total");
@@ -83,52 +86,57 @@ public class TokenFileTest {
context.write(new Text(), m);
}
}
-
+
@Override
public int run(String[] args) throws Exception {
-
+
if (args.length != 4) {
throw new IllegalArgumentException("Usage : " + MRTokenFileTester.class.getName() + " <user> <token file> <inputtable> <outputtable>");
}
-
+
String user = args[0];
String tokenFile = args[1];
String table1 = args[2];
String table2 = args[3];
-
+
Job job = new Job(getConf(), this.getClass().getSimpleName() + "_" + System.currentTimeMillis());
job.setJarByClass(this.getClass());
-
+
job.setInputFormatClass(AccumuloInputFormat.class);
-
+
AccumuloInputFormat.setConnectorInfo(job, user, tokenFile);
AccumuloInputFormat.setInputTableName(job, table1);
AccumuloInputFormat.setMockInstance(job, INSTANCE_NAME);
-
+
job.setMapperClass(TestMapper.class);
job.setMapOutputKeyClass(Key.class);
job.setMapOutputValueClass(Value.class);
job.setOutputFormatClass(AccumuloOutputFormat.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Mutation.class);
-
+
AccumuloOutputFormat.setConnectorInfo(job, user, tokenFile);
AccumuloOutputFormat.setCreateTables(job, false);
AccumuloOutputFormat.setDefaultTableName(job, table2);
AccumuloOutputFormat.setMockInstance(job, INSTANCE_NAME);
-
+
job.setNumReduceTasks(0);
-
+
job.waitForCompletion(true);
-
+
return job.isSuccessful() ? 0 : 1;
}
-
+
public static void main(String[] args) throws Exception {
- assertEquals(0, ToolRunner.run(CachedConfiguration.getInstance(), new MRTokenFileTester(), args));
+ Configuration conf = CachedConfiguration.getInstance();
+ conf.set("hadoop.tmp.dir", new File(args[1]).getParent());
+ assertEquals(0, ToolRunner.run(conf, new MRTokenFileTester(), args));
}
}
-
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
@Test
public void testMR() throws Exception {
MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
@@ -142,17 +150,16 @@ public class TokenFileTest {
bw.addMutation(m);
}
bw.close();
-
- String tokenFile = "root_test.pw";
- File tf = File.createTempFile(tokenFile, "");
+
+ File tf = folder.newFile("root_test.pw");
PrintStream out = new PrintStream(tf);
String outString = new Credentials("root", new PasswordToken("")).serialize();
out.println(outString);
out.close();
-
+
MRTokenFileTester.main(new String[] {"root", tf.getAbsolutePath(), TEST_TABLE_1, TEST_TABLE_2});
assertNull(e1);
-
+
Scanner scanner = c.createScanner(TEST_TABLE_2, new Authorizations());
Iterator<Entry<Key,Value>> iter = scanner.iterator();
assertTrue(iter.hasNext());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
index d1ada62..165acad 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloCluster.java
@@ -330,7 +330,7 @@ public class MiniAccumuloCluster {
File siteFile = new File(config.getConfDir(), "accumulo-site.xml");
writeConfig(siteFile, config.getSiteConfig().entrySet());
-
+
FileWriter fileWriter = new FileWriter(siteFile);
fileWriter.append("<configuration>\n");
@@ -513,7 +513,7 @@ public class MiniAccumuloCluster {
if (proc.equals(gcProcess)) {
gcProcess.destroy();
gcProcess = null;
- found= true;
+ found = true;
}
break;
}
@@ -586,7 +586,7 @@ public class MiniAccumuloCluster {
Instance instance = new ZooKeeperInstance(this.getInstanceName(), this.getZooKeepers());
return instance.getConnector(user, new PasswordToken(passwd));
}
-
+
public FileSystem getFileSystem() {
try {
return FileSystem.get(new URI(dfsUri), new Configuration());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterGCTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterGCTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterGCTest.java
index f4a8ca9..1b2481b 100644
--- a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterGCTest.java
+++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterGCTest.java
@@ -38,7 +38,6 @@ import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import com.google.common.collect.ImmutableMap;
@@ -47,17 +46,18 @@ import com.google.common.collect.ImmutableMap;
*/
public class MiniAccumuloClusterGCTest {
- private static TemporaryFolder tmpDir = new TemporaryFolder();
+ private static File testDir = new File(System.getProperty("user.dir") + "/target/" + MiniAccumuloClusterGCTest.class.getName());
private static MiniAccumuloConfig macConfig;
private static MiniAccumuloCluster accumulo;
private static final String passwd = "password";
@BeforeClass
public static void setupMiniCluster() throws Exception {
- tmpDir.create();
+ FileUtils.deleteQuietly(testDir);
+ testDir.mkdir();
Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
- macConfig = new MiniAccumuloConfig(tmpDir.getRoot(), passwd);
+ macConfig = new MiniAccumuloConfig(testDir, passwd);
macConfig.setNumTservers(1);
// Turn on the garbage collector
@@ -74,14 +74,13 @@ public class MiniAccumuloClusterGCTest {
@AfterClass
public static void tearDownMiniCluster() throws Exception {
accumulo.stop();
- tmpDir.delete();
}
@Test(timeout = 20000)
public void testFilesAreGarbageCollected() throws Exception {
ZooKeeperInstance inst = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
Connector c = inst.getConnector("root", new PasswordToken(passwd));
-
+
final String table = "foobar";
c.tableOperations().create(table);
@@ -108,7 +107,7 @@ public class MiniAccumuloClusterGCTest {
c.tableOperations().compact(table, null, null, flush, wait);
c.tableOperations().compact(MetadataTable.NAME, null, null, flush, wait);
- File accumuloDir = new File(tmpDir.getRoot().getAbsolutePath(), "accumulo");
+ File accumuloDir = new File(testDir, "accumulo");
File tables = new File(accumuloDir.getAbsolutePath(), "tables");
int fileCountAfterCompaction = FileUtils.listFiles(tables, new SuffixFileFilter(".rf"), TrueFileFilter.TRUE).size();
@@ -129,12 +128,12 @@ public class MiniAccumuloClusterGCTest {
@Test(timeout = 10000)
public void testAccurateProcessListReturned() throws Exception {
Map<ServerType,Collection<ProcessReference>> procs = accumulo.getProcesses();
-
+
for (ServerType t : new ServerType[] {ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.ZOOKEEPER, ServerType.GARBAGE_COLLECTOR}) {
Assert.assertTrue(procs.containsKey(t));
Collection<ProcessReference> procRefs = procs.get(t);
Assert.assertTrue(1 <= procRefs.size());
-
+
for (ProcessReference procRef : procRefs) {
Assert.assertNotNull(procRef);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
index 3e749ab..26a1546 100644
--- a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
+++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterTest.java
@@ -19,10 +19,10 @@ package org.apache.accumulo.minicluster;
import static org.junit.Assert.assertEquals;
import java.io.File;
-import java.util.Collections;
-import java.util.Map.Entry;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
@@ -50,12 +50,13 @@ import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class MiniAccumuloClusterTest {
- public static TemporaryFolder folder = new TemporaryFolder();
+ public static File testDir;
private static MiniAccumuloCluster accumulo;
@@ -63,8 +64,13 @@ public class MiniAccumuloClusterTest {
public static void setupMiniCluster() throws Exception {
Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
- folder.create();
- MiniAccumuloConfig config = new MiniAccumuloConfig(folder.getRoot(), "superSecret").setJDWPEnabled(true);
+ File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests");
+ baseDir.mkdirs();
+ testDir = new File(baseDir, MiniAccumuloClusterTest.class.getName());
+ FileUtils.deleteQuietly(testDir);
+ testDir.mkdir();
+
+ MiniAccumuloConfig config = new MiniAccumuloConfig(testDir, "superSecret").setJDWPEnabled(true);
accumulo = new MiniAccumuloCluster(config);
accumulo.start();
}
@@ -150,6 +156,9 @@ public class MiniAccumuloClusterTest {
conn.tableOperations().delete("table1");
}
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
@Test(timeout = 60000)
public void testPerTableClasspath() throws Exception {
@@ -158,9 +167,8 @@ public class MiniAccumuloClusterTest {
conn.tableOperations().create("table2");
- File jarFile = File.createTempFile("iterator", ".jar");
+ File jarFile = folder.newFile("iterator.jar");
FileUtils.copyURLToFile(this.getClass().getResource("/FooFilter.jar"), jarFile);
- jarFile.deleteOnExit();
conn.instanceOperations().setProperty(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "cx1", jarFile.toURI().toString());
conn.tableOperations().setProperty("table2", Property.TABLE_CLASSPATH.getKey(), "cx1");
@@ -205,18 +213,18 @@ public class MiniAccumuloClusterTest {
Assert.assertTrue(debugPort.getSecond() > 0);
}
}
-
+
@Test(timeout = 10000)
public void testAccurateProcessListReturned() throws Exception {
Map<ServerType,Collection<ProcessReference>> procs = accumulo.getProcesses();
-
+
Assert.assertFalse(procs.containsKey(ServerType.GARBAGE_COLLECTOR));
-
+
for (ServerType t : new ServerType[] {ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.ZOOKEEPER}) {
Assert.assertTrue(procs.containsKey(t));
Collection<ProcessReference> procRefs = procs.get(t);
Assert.assertTrue(1 <= procRefs.size());
-
+
for (ProcessReference procRef : procRefs) {
Assert.assertNotNull(procRef);
}
@@ -226,7 +234,6 @@ public class MiniAccumuloClusterTest {
@AfterClass
public static void tearDownMiniCluster() throws Exception {
accumulo.stop();
- folder.delete();
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloConfigTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloConfigTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloConfigTest.java
index 7094e21..8a764d2 100644
--- a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloConfigTest.java
+++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloConfigTest.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.minicluster;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -31,7 +32,7 @@ import org.junit.rules.TemporaryFolder;
public class MiniAccumuloConfigTest {
- static TemporaryFolder tempFolder = new TemporaryFolder();
+ static TemporaryFolder tempFolder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
@BeforeClass
public static void setUp() throws IOException {
@@ -39,7 +40,7 @@ public class MiniAccumuloConfigTest {
}
@Test
- public void testZookeeperPort(){
+ public void testZookeeperPort() {
// set specific zookeeper port
MiniAccumuloConfig config = new MiniAccumuloConfig(tempFolder.getRoot(), "password").setZooKeeperPort(5000).initialize();
@@ -54,7 +55,7 @@ public class MiniAccumuloConfigTest {
public void testSiteConfig() {
// constructor site config overrides default props
- Map<String,String> siteConfig = new HashMap<String, String>();
+ Map<String,String> siteConfig = new HashMap<String,String>();
siteConfig.put(Property.INSTANCE_DFS_URI.getKey(), "hdfs://");
MiniAccumuloConfig config = new MiniAccumuloConfig(tempFolder.getRoot(), "password").setSiteConfig(siteConfig).initialize();
assertEquals("hdfs://", config.getSiteConfig().get(Property.INSTANCE_DFS_URI.getKey()));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --git a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index c625ae3..242ef08 100644
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@ -111,9 +111,9 @@ import org.junit.rules.TemporaryFolder;
* Call every method on the proxy and try to verify that it works.
*/
public class SimpleTest {
-
- public static TemporaryFolder folder = new TemporaryFolder();
-
+
+ public static TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
private static MiniAccumuloCluster accumulo;
private static String secret = "superSecret";
private static Random random = new Random();
@@ -129,20 +129,21 @@ public class SimpleTest {
}
};
private static ByteBuffer creds = null;
-
+
private static Class<? extends TProtocolFactory> protocolClass;
-
+
static Class<? extends TProtocolFactory> getRandomProtocol() {
List<Class<? extends TProtocolFactory>> protocolFactories = new ArrayList<Class<? extends TProtocolFactory>>();
protocolFactories.add(org.apache.thrift.protocol.TJSONProtocol.Factory.class);
protocolFactories.add(org.apache.thrift.protocol.TBinaryProtocol.Factory.class);
protocolFactories.add(org.apache.thrift.protocol.TTupleProtocol.Factory.class);
protocolFactories.add(org.apache.thrift.protocol.TCompactProtocol.Factory.class);
-
+
return protocolFactories.get(random.nextInt(protocolFactories.size()));
}
-
+
private static final AtomicInteger tableCounter = new AtomicInteger(0);
+
private static String makeTableName() {
return "test" + tableCounter.getAndIncrement();
}
@@ -150,18 +151,17 @@ public class SimpleTest {
@BeforeClass
public static void setupMiniCluster() throws Exception {
folder.create();
- MiniAccumuloConfig config = new MiniAccumuloConfig (folder.getRoot(), secret)
- .setNumTservers (1);
+ MiniAccumuloConfig config = new MiniAccumuloConfig(folder.getRoot(), secret).setNumTservers(1);
accumulo = new MiniAccumuloCluster(config);
accumulo.start();
-
+
Properties props = new Properties();
props.put("instance", accumulo.getConfig().getInstanceName());
props.put("zookeepers", accumulo.getConfig().getZooKeepers());
props.put("tokenClass", PasswordToken.class.getName());
-
+
protocolClass = getRandomProtocol();
-
+
proxyPort = PortUtils.getRandomFreePort();
proxyServer = Proxy.createProxyServer(org.apache.accumulo.proxy.thrift.AccumuloProxy.class, org.apache.accumulo.proxy.ProxyServer.class, proxyPort,
protocolClass, props);
@@ -177,7 +177,7 @@ public class SimpleTest {
client = new TestProxyClient("localhost", proxyPort, protocolClass.newInstance()).proxy();
creds = client.login(principal, properties);
}
-
+
@Test(timeout = 10000)
public void security() throws Exception {
client.createLocalUser(creds, "user", s2bb(secret));
@@ -185,9 +185,9 @@ public class SimpleTest {
client.dropLocalUser(creds, "user");
final String table = makeTableName();
client.createTable(creds, table, false, TimeType.MILLIS);
-
+
final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
-
+
try {
client.addConstraint(badLogin, table, NumericValueConstraint.class.getName());
fail("exception not thrown");
@@ -451,7 +451,7 @@ public class SimpleTest {
fail("exception not thrown");
} catch (AccumuloSecurityException ex) {}
}
-
+
@Test(timeout = 10000)
public void tableNotFound() throws Exception {
final String doesNotExist = "doesNotExists";
@@ -610,7 +610,7 @@ public class SimpleTest {
client.createConditionalWriter(creds, doesNotExist, new ConditionalWriterOptions());
} catch (TableNotFoundException ex) {}
}
-
+
@Test(timeout = 10000)
public void testExists() throws Exception {
client.createTable(creds, "ett1", false, TimeType.MILLIS);
@@ -628,27 +628,27 @@ public class SimpleTest {
fail("exception not thrown");
} catch (TableExistsException tee) {}
}
-
+
@Test(timeout = 10000)
public void testUnknownScanner() throws Exception {
final String TABLE_TEST = makeTableName();
-
+
client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
-
+
String scanner = client.createScanner(creds, TABLE_TEST, null);
assertFalse(client.hasNext(scanner));
client.closeScanner(scanner);
-
+
try {
client.hasNext(scanner);
fail("exception not thrown");
} catch (UnknownScanner us) {}
-
+
try {
client.closeScanner(scanner);
fail("exception not thrown");
} catch (UnknownScanner us) {}
-
+
try {
client.nextEntry("99999999");
fail("exception not thrown");
@@ -666,22 +666,22 @@ public class SimpleTest {
fail("exception not thrown");
} catch (UnknownScanner us) {}
}
-
+
@Test(timeout = 10000)
public void testUnknownWriter() throws Exception {
final String TABLE_TEST = makeTableName();
-
+
client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
-
+
String writer = client.createWriter(creds, TABLE_TEST, null);
client.update(writer, mutation("row0", "cf", "cq", "value"));
client.flush(writer);
client.update(writer, mutation("row2", "cf", "cq", "value2"));
client.closeWriter(writer);
-
+
// this is a oneway call, so it does not throw exceptions
client.update(writer, mutation("row2", "cf", "cq", "value2"));
-
+
try {
client.flush(writer);
fail("exception not thrown");
@@ -699,7 +699,7 @@ public class SimpleTest {
fail("exception not thrown");
} catch (UnknownWriter uw) {}
}
-
+
@Test(timeout = 10000)
public void testInstanceOperations() throws Exception {
int tservers = 0;
@@ -708,14 +708,14 @@ public class SimpleTest {
tservers++;
}
assertTrue(tservers > 0);
-
+
// get something we know is in the site config
Map<String,String> cfg = client.getSiteConfiguration(creds);
assertTrue(cfg.get("instance.dfs.dir").startsWith(folder.getRoot().toString()));
-
+
// set a property in zookeeper
client.setProperty(creds, "table.split.threshold", "500M");
-
+
// check that we can read it
for (int i = 0; i < 5; i++) {
cfg = client.getSystemConfiguration(creds);
@@ -724,7 +724,7 @@ public class SimpleTest {
UtilWaitThread.sleep(200);
}
assertEquals("500M", cfg.get("table.split.threshold"));
-
+
// unset the setting, check that it's not what it was
client.removeProperty(creds, "table.split.threshold");
for (int i = 0; i < 5; i++) {
@@ -734,11 +734,11 @@ public class SimpleTest {
UtilWaitThread.sleep(200);
}
assertNotEquals("500M", cfg.get("table.split.threshold"));
-
+
// try to load some classes via the proxy
assertTrue(client.testClassLoad(creds, DevNull.class.getName(), SortedKeyValueIterator.class.getName()));
assertFalse(client.testClassLoad(creds, "foo.bar", SortedKeyValueIterator.class.getName()));
-
+
// create a table that's very slow, so we can look for scans/compactions
client.createTable(creds, "slow", true, TimeType.MILLIS);
IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200"));
@@ -747,7 +747,7 @@ public class SimpleTest {
client.updateAndFlush(creds, "slow", mutation("row2", "cf", "cq", "value"));
client.updateAndFlush(creds, "slow", mutation("row3", "cf", "cq", "value"));
client.updateAndFlush(creds, "slow", mutation("row4", "cf", "cq", "value"));
-
+
// scan
Thread t = new Thread() {
@Override
@@ -785,7 +785,7 @@ public class SimpleTest {
assertEquals(map.get("slow"), scan.getExtent().tableId);
assertTrue(scan.getExtent().endRow == null);
assertTrue(scan.getExtent().prevEndRow == null);
-
+
// start a compaction
t = new Thread() {
@Override
@@ -799,7 +799,7 @@ public class SimpleTest {
}
};
t.start();
-
+
// try to catch it in the act
List<ActiveCompaction> compactions = Collections.emptyList();
loop2: for (int i = 0; i < 100; i++) {
@@ -821,15 +821,15 @@ public class SimpleTest {
assertEquals("", c.localityGroup);
assertTrue(c.outputFile.contains("default_tablet"));
}
-
+
@Test
public void testSecurityOperations() throws Exception {
final String TABLE_TEST = makeTableName();
-
+
// check password
assertTrue(client.authenticateUser(creds, "root", s2pp(secret)));
assertFalse(client.authenticateUser(creds, "root", s2pp("")));
-
+
// create a user
client.createLocalUser(creds, "stooge", s2bb("password"));
// change auths
@@ -839,11 +839,11 @@ public class SimpleTest {
client.changeUserAuthorizations(creds, "stooge", auths);
List<ByteBuffer> update = client.getUserAuthorizations(creds, "stooge");
assertEquals(auths, new HashSet<ByteBuffer>(update));
-
+
// change password
client.changeLocalUserPassword(creds, "stooge", s2bb(""));
assertTrue(client.authenticateUser(creds, "stooge", s2pp("")));
-
+
// check permission failure
@SuppressWarnings("serial")
ByteBuffer stooge = client.login("stooge", new TreeMap<String,String>() {
@@ -851,7 +851,7 @@ public class SimpleTest {
put("password", "");
}
});
-
+
try {
client.createTable(stooge, "fail", true, TimeType.MILLIS);
fail("should not create the table");
@@ -864,7 +864,7 @@ public class SimpleTest {
assertTrue(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
client.createTable(stooge, "success", true, TimeType.MILLIS);
client.listTables(creds).contains("succcess");
-
+
// revoke permissions
client.revokeSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE);
assertFalse(client.hasSystemPermission(creds, "stooge", SystemPermission.CREATE_TABLE));
@@ -897,27 +897,27 @@ public class SimpleTest {
client.nextK(scanner, 100);
fail("stooge should not read table test");
} catch (AccumuloSecurityException ex) {}
-
+
// delete user
client.dropLocalUser(creds, "stooge");
users = client.listLocalUsers(creds);
assertEquals(1, users.size());
-
+
}
-
+
@Test
public void testBatchWriter() throws Exception {
final String TABLE_TEST = makeTableName();
-
+
client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
-
+
WriterOptions writerOptions = new WriterOptions();
writerOptions.setLatencyMs(10000);
writerOptions.setMaxMemory(2);
writerOptions.setThreads(1);
writerOptions.setTimeoutMs(100000);
-
+
String batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
@@ -929,44 +929,44 @@ public class SimpleTest {
client.closeWriter(batchWriter);
fail("constraint did not fire");
} catch (MutationsRejectedException e) {}
-
+
client.removeConstraint(creds, TABLE_TEST, 2);
-
+
writerOptions = new WriterOptions();
writerOptions.setLatencyMs(10000);
writerOptions.setMaxMemory(3000);
writerOptions.setThreads(1);
writerOptions.setTimeoutMs(100000);
-
+
batchWriter = client.createWriter(creds, TABLE_TEST, writerOptions);
-
+
client.update(batchWriter, mutation("row1", "cf", "cq", "x"));
client.flush(batchWriter);
client.closeWriter(batchWriter);
-
+
String scanner = client.createScanner(creds, TABLE_TEST, null);
ScanResult more = client.nextK(scanner, 2);
assertEquals(1, more.getResults().size());
client.closeScanner(scanner);
-
+
client.deleteTable(creds, TABLE_TEST);
}
-
+
@Test
public void testTableOperations() throws Exception {
final String TABLE_TEST = makeTableName();
-
+
client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
// constraints
client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
- assertEquals (2, client.listConstraints (creds, TABLE_TEST).size ());
+ assertEquals(2, client.listConstraints(creds, TABLE_TEST).size());
client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "123"));
-
+
try {
client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
fail("constraint did not fire");
} catch (MutationsRejectedException ex) {}
-
+
client.removeConstraint(creds, TABLE_TEST, 2);
assertEquals(1, client.listConstraints(creds, TABLE_TEST).size());
client.updateAndFlush(creds, TABLE_TEST, mutation("row1", "cf", "cq", "x"));
@@ -1024,14 +1024,14 @@ public class SimpleTest {
client.closeScanner(scanner);
assertEquals(10, more.getResults().size());
client.deleteTable(creds, TABLE_TEST2);
-
+
// don't know how to test this, call it just for fun
client.clearLocatorCache(creds, TABLE_TEST);
-
+
// compact
client.compactTable(creds, TABLE_TEST, null, null, null, true, true);
assertEquals(1, countFiles(TABLE_TEST));
-
+
// get disk usage
client.cloneTable(creds, TABLE_TEST, TABLE_TEST2, true, null, null);
Set<String> tablesToScan = new HashSet<String>();
@@ -1051,7 +1051,7 @@ public class SimpleTest {
assertEquals(1, diskUsage.get(2).getTables().size());
client.deleteTable(creds, "foo");
client.deleteTable(creds, TABLE_TEST2);
-
+
// export/import
String dir = folder.getRoot() + "/test";
String destDir = folder.getRoot() + "/test_dest";
@@ -1074,7 +1074,7 @@ public class SimpleTest {
more = client.nextK(scanner, 100);
client.closeScanner(scanner);
assertEquals(10, more.results.size());
-
+
try {
// ACCUMULO-1558 a second import from the same dir should fail, the first import moved the files
client.importTable(creds, "testify2", destDir);
@@ -1125,19 +1125,19 @@ public class SimpleTest {
assertEquals(1, more.results.size());
ByteBuffer maxRow = client.getMaxRow(creds, "bar", null, null, false, null, false);
assertEquals(s2bb("a"), maxRow);
-
+
assertFalse(client.testTableClassLoad(creds, "bar", "abc123", SortedKeyValueIterator.class.getName()));
assertTrue(client.testTableClassLoad(creds, "bar", VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName()));
}
-
+
private Condition newCondition(String cf, String cq) {
return new Condition(new Column(s2bb(cf), s2bb(cq), s2bb("")));
}
-
+
private Condition newCondition(String cf, String cq, String val) {
return newCondition(cf, cq).setValue(s2bb(val));
}
-
+
private Condition newCondition(String cf, String cq, long ts, String val) {
return newCondition(cf, cq).setValue(s2bb(val)).setTimestamp(ts);
}
@@ -1145,7 +1145,7 @@ public class SimpleTest {
private ColumnUpdate newColUpdate(String cf, String cq, String val) {
return new ColumnUpdate(s2bb(cf), s2bb(cq)).setValue(s2bb(val));
}
-
+
private ColumnUpdate newColUpdate(String cf, String cq, long ts, String val) {
return new ColumnUpdate(s2bb(cf), s2bb(cq)).setTimestamp(ts).setValue(s2bb(val));
}
@@ -1153,55 +1153,55 @@ public class SimpleTest {
private void assertScan(String[][] expected, String table) throws Exception {
String scid = client.createScanner(creds, table, new ScanOptions());
ScanResult keyValues = client.nextK(scid, expected.length + 1);
-
+
assertEquals(expected.length, keyValues.results.size());
assertFalse(keyValues.more);
-
+
for (int i = 0; i < keyValues.results.size(); i++) {
checkKey(expected[i][0], expected[i][1], expected[i][2], expected[i][3], keyValues.results.get(i));
}
-
+
client.closeScanner(scid);
}
@Test
public void testConditionalWriter() throws Exception {
final String TABLE_TEST = makeTableName();
-
+
client.createTable(creds, TABLE_TEST, true, TimeType.MILLIS);
-
+
client.addConstraint(creds, TABLE_TEST, NumericValueConstraint.class.getName());
String cwid = client.createConditionalWriter(creds, TABLE_TEST, new ConditionalWriterOptions());
-
+
Map<ByteBuffer,ConditionalUpdates> updates = new HashMap<ByteBuffer,ConditionalUpdates>();
-
+
updates.put(
s2bb("00345"),
new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq")), Arrays.asList(newColUpdate("meta", "seq", 10, "1"),
newColUpdate("data", "img", "73435435"))));
-
+
Map<ByteBuffer,ConditionalStatus> results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00345")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "73435435"}, {"00345", "meta", "seq", "1"}}, TABLE_TEST);
-
+
// test not setting values on conditions
updates.clear();
-
+
updates.put(s2bb("00345"), new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq")), Arrays.asList(newColUpdate("meta", "seq", "2"))));
updates.put(s2bb("00346"), new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq")), Arrays.asList(newColUpdate("meta", "seq", "1"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(2, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00345")));
assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00346")));
assertScan(new String[][] { {"00345", "data", "img", "73435435"}, {"00345", "meta", "seq", "1"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
-
+
// test setting values on conditions
updates.clear();
@@ -1209,66 +1209,63 @@ public class SimpleTest {
s2bb("00345"),
new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", "1")), Arrays.asList(newColUpdate("meta", "seq", 20, "2"),
newColUpdate("data", "img", "567890"))));
-
+
updates.put(s2bb("00346"), new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", "2")), Arrays.asList(newColUpdate("meta", "seq", "3"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(2, results.size());
assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00345")));
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00346")));
-
- assertScan(new String[][] { {"00345", "data", "img", "567890"}, {"00345", "meta", "seq", "2"},
- {"00346", "meta", "seq", "1"}}, TABLE_TEST);
-
+
+ assertScan(new String[][] { {"00345", "data", "img", "567890"}, {"00345", "meta", "seq", "2"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
+
// test setting timestamp on condition to a non-existant version
updates.clear();
-
+
updates.put(
s2bb("00345"),
new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", 10, "2")), Arrays.asList(newColUpdate("meta", "seq", 30, "3"),
newColUpdate("data", "img", "1234567890"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00345")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "567890"}, {"00345", "meta", "seq", "2"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
-
// test setting timestamp to an existing version
-
+
updates.clear();
-
+
updates.put(
s2bb("00345"),
new ConditionalUpdates(Arrays.asList(newCondition("meta", "seq", 20, "2")), Arrays.asList(newColUpdate("meta", "seq", 30, "3"),
newColUpdate("data", "img", "1234567890"))));
-
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00345")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"}}, TABLE_TEST);
-
+
// run test w/ condition that has iterators
// following should fail w/o iterator
client.updateAndFlush(creds, TABLE_TEST, Collections.singletonMap(s2bb("00347"), Arrays.asList(newColUpdate("data", "count", "1"))));
client.updateAndFlush(creds, TABLE_TEST, Collections.singletonMap(s2bb("00347"), Arrays.asList(newColUpdate("data", "count", "1"))));
client.updateAndFlush(creds, TABLE_TEST, Collections.singletonMap(s2bb("00347"), Arrays.asList(newColUpdate("data", "count", "1"))));
-
+
updates.clear();
updates.put(s2bb("00347"),
new ConditionalUpdates(Arrays.asList(newCondition("data", "count", "3")), Arrays.asList(newColUpdate("data", "img", "1234567890"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "1"}}, TABLE_TEST);
@@ -1279,10 +1276,10 @@ public class SimpleTest {
props.put("columns", "data:count");
IteratorSetting is = new IteratorSetting(1, "sumc", SummingCombiner.class.getName(), props);
iterCond.setIterators(Arrays.asList(is));
-
+
updates.clear();
updates.put(s2bb("00347"), new ConditionalUpdates(Arrays.asList(iterCond), Arrays.asList(newColUpdate("data", "img", "1234567890"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
assertEquals(1, results.size());
@@ -1295,12 +1292,12 @@ public class SimpleTest {
updates.clear();
updates.put(s2bb("00347"),
new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "1234567890")), Arrays.asList(newColUpdate("data", "count", "A"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.VIOLATED, results.get(s2bb("00347")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
@@ -1311,56 +1308,56 @@ public class SimpleTest {
s2bb("00347"),
new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "565"), newCondition("data", "count", "2")), Arrays.asList(
newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
-
+
// one condition should fail
updates.clear();
updates.put(
s2bb("00347"),
new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "1234567890"), newCondition("data", "count", "2")), Arrays.asList(
newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
-
+
// one condition should fail
updates.clear();
updates.put(
s2bb("00347"),
new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "565"), newCondition("data", "count", "1")), Arrays.asList(
newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00347")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "1"}, {"00347", "data", "img", "1234567890"}}, TABLE_TEST);
-
+
// both conditions should succeed
-
+
ConditionalStatus result = client.updateRowConditionally(
creds,
TABLE_TEST,
s2bb("00347"),
new ConditionalUpdates(Arrays.asList(newCondition("data", "img", "1234567890"), newCondition("data", "count", "1")), Arrays.asList(
newColUpdate("data", "count", "3"), newColUpdate("data", "img", "0987654321"))));
-
+
assertEquals(ConditionalStatus.ACCEPTED, result);
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}}, TABLE_TEST);
@@ -1375,43 +1372,44 @@ public class SimpleTest {
client.changeUserAuthorizations(creds, "cwuser", Collections.singleton(s2bb("A")));
client.grantTablePermission(creds, "cwuser", TABLE_TEST, TablePermission.WRITE);
client.grantTablePermission(creds, "cwuser", TABLE_TEST, TablePermission.READ);
-
+
ByteBuffer cwuCreds = client.login("cwuser", Collections.singletonMap("password", "bestpasswordever"));
-
+
cwid = client.createConditionalWriter(cwuCreds, TABLE_TEST, new ConditionalWriterOptions().setAuthorizations(Collections.singleton(s2bb("A"))));
-
+
updates.clear();
- updates.put(s2bb("00348"),
+ updates.put(
+ s2bb("00348"),
new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("A")))), Arrays.asList(newColUpdate("data", "seq", "1"),
newColUpdate("data", "c", "1").setColVisibility(s2bb("A")))));
updates.put(s2bb("00349"),
new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("B")))), Arrays.asList(newColUpdate("data", "seq", "1"))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(2, results.size());
assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00348")));
assertEquals(ConditionalStatus.INVISIBLE_VISIBILITY, results.get(s2bb("00349")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}, {"00348", "data", "seq", "1"}}, TABLE_TEST);
updates.clear();
-
+
updates.clear();
updates.put(
s2bb("00348"),
new ConditionalUpdates(Arrays.asList(new Condition(new Column(s2bb("data"), s2bb("c"), s2bb("A"))).setValue(s2bb("0"))), Arrays.asList(
newColUpdate("data", "seq", "2"), newColUpdate("data", "c", "2").setColVisibility(s2bb("A")))));
-
+
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.REJECTED, results.get(s2bb("00348")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}, {"00348", "data", "seq", "1"}}, TABLE_TEST);
-
+
updates.clear();
updates.put(
s2bb("00348"),
@@ -1419,10 +1417,10 @@ public class SimpleTest {
newColUpdate("data", "seq", "2"), newColUpdate("data", "c", "2").setColVisibility(s2bb("A")))));
results = client.updateRowsConditionally(cwid, updates);
-
+
assertEquals(1, results.size());
assertEquals(ConditionalStatus.ACCEPTED, results.get(s2bb("00348")));
-
+
assertScan(new String[][] { {"00345", "data", "img", "1234567890"}, {"00345", "meta", "seq", "3"}, {"00346", "meta", "seq", "1"},
{"00347", "data", "count", "3"}, {"00347", "data", "img", "0987654321"}, {"00348", "data", "seq", "2"}}, TABLE_TEST);
@@ -1466,23 +1464,23 @@ public class SimpleTest {
}
return result;
}
-
+
private Map<ByteBuffer,List<ColumnUpdate>> mutation(String row, String cf, String cq, String value) {
ColumnUpdate upd = new ColumnUpdate(s2bb(cf), s2bb(cq));
upd.setValue(value.getBytes());
return Collections.singletonMap(s2bb(row), Collections.singletonList(upd));
}
-
+
private ByteBuffer s2bb(String cf) {
return ByteBuffer.wrap(cf.getBytes());
}
-
+
private Map<String,String> s2pp(String cf) {
Map<String,String> toRet = new TreeMap<String,String>();
toRet.put("password", cf);
return toRet;
}
-
+
@AfterClass
public static void tearDownMiniCluster() throws Exception {
accumulo.stop();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/server/src/test/java/org/apache/accumulo/server/tabletserver/log/MultiReaderTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/tabletserver/log/MultiReaderTest.java b/server/src/test/java/org/apache/accumulo/server/tabletserver/log/MultiReaderTest.java
index c69baa4..d35ff35 100644
--- a/server/src/test/java/org/apache/accumulo/server/tabletserver/log/MultiReaderTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/tabletserver/log/MultiReaderTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.File;
import java.io.IOException;
import org.apache.accumulo.server.fs.VolumeManager;
@@ -37,10 +38,10 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class MultiReaderTest {
-
+
VolumeManager fs;
- TemporaryFolder root = new TemporaryFolder();
-
+ TemporaryFolder root = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
+
@Before
public void setUp() throws Exception {
// quiet log messages about compress.CodecPool
@@ -66,16 +67,16 @@ public class MultiReaderTest {
}
writer.close();
}
-
+
@After
public void tearDown() throws Exception {
root.create();
}
-
+
private void scan(MultiReader reader, int start) throws IOException {
IntWritable key = new IntWritable();
BytesWritable value = new BytesWritable();
-
+
for (int i = start + 1; i < 1000; i++) {
if (i == 10)
continue;
@@ -83,24 +84,24 @@ public class MultiReaderTest {
assertEquals(i, key.get());
}
}
-
+
private void scanOdd(MultiReader reader, int start) throws IOException {
IntWritable key = new IntWritable();
BytesWritable value = new BytesWritable();
-
+
for (int i = start + 2; i < 1000; i += 2) {
assertTrue(reader.next(key, value));
assertEquals(i, key.get());
}
}
-
+
@Test
public void testMultiReader() throws IOException {
Path manyMaps = new Path("file://" + root.getRoot().getAbsolutePath() + "/manyMaps");
MultiReader reader = new MultiReader(fs, manyMaps);
IntWritable key = new IntWritable();
BytesWritable value = new BytesWritable();
-
+
for (int i = 0; i < 1000; i++) {
if (i == 10)
continue;
@@ -109,7 +110,7 @@ public class MultiReaderTest {
}
assertEquals(value.compareTo(new BytesWritable("someValue".getBytes())), 0);
assertFalse(reader.next(key, value));
-
+
key.set(500);
assertTrue(reader.seek(key));
scan(reader, 500);
@@ -125,7 +126,7 @@ public class MultiReaderTest {
assertTrue(reader.next(key, value));
assertEquals(0, key.get());
reader.close();
-
+
fs.deleteRecursively(new Path(manyMaps, "even"));
reader = new MultiReader(fs, manyMaps);
key.set(501);
@@ -140,7 +141,7 @@ public class MultiReaderTest {
assertTrue(reader.next(key, value));
assertEquals(1, key.get());
reader.close();
-
+
}
-
+
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/aa711023/server/src/test/java/org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java b/server/src/test/java/org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java
index dc15260..62c9f37 100644
--- a/server/src/test/java/org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/tabletserver/log/SortedLogRecoveryTest.java
@@ -22,6 +22,7 @@ import static org.apache.accumulo.server.logger.LogEvents.DEFINE_TABLET;
import static org.apache.accumulo.server.logger.LogEvents.MUTATION;
import static org.apache.accumulo.server.logger.LogEvents.OPEN;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -52,27 +53,27 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class SortedLogRecoveryTest {
-
+
static final KeyExtent extent = new KeyExtent(new Text("table"), null, null);
static final Text cf = new Text("cf");
static final Text cq = new Text("cq");
static final Value value = new Value("value".getBytes());
-
+
static class KeyValue implements Comparable<KeyValue> {
public final LogFileKey key;
public final LogFileValue value;
-
+
KeyValue() {
key = new LogFileKey();
value = new LogFileValue();
}
-
+
@Override
public int compareTo(KeyValue o) {
return key.compareTo(o.key);
}
}
-
+
private static KeyValue createKeyValue(LogEvents type, long seq, int tid, Object fileExtentMutation) {
KeyValue result = new KeyValue();
result.key.event = type;
@@ -94,27 +95,27 @@ public class SortedLogRecoveryTest {
result.value.mutations = Arrays.asList((Mutation) fileExtentMutation);
break;
case MANY_MUTATIONS:
- result.value.mutations = Arrays.asList((Mutation[])fileExtentMutation);
+ result.value.mutations = Arrays.asList((Mutation[]) fileExtentMutation);
}
return result;
}
-
+
private static class CaptureMutations implements MutationReceiver {
public ArrayList<Mutation> result = new ArrayList<Mutation>();
-
+
@Override
public void receive(Mutation m) {
// make a copy of Mutation:
result.add(m);
}
}
-
+
private static List<Mutation> recover(Map<String,KeyValue[]> logs, KeyExtent extent) throws IOException {
return recover(logs, new HashSet<String>(), extent);
}
-
+
private static List<Mutation> recover(Map<String,KeyValue[]> logs, Set<String> files, KeyExtent extent) throws IOException {
- TemporaryFolder root = new TemporaryFolder();
+ TemporaryFolder root = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
root.create();
final String workdir = "file://" + root.getRoot().getAbsolutePath() + "/workdir";
VolumeManager fs = VolumeManagerImpl.getLocal();
@@ -141,7 +142,7 @@ public class SortedLogRecoveryTest {
root.delete();
}
}
-
+
@Test
public void testCompactionCrossesLogs() throws IOException {
Mutation ignored = new ServerMutation(new Text("ignored"));
@@ -161,23 +162,23 @@ public class SortedLogRecoveryTest {
createKeyValue(MUTATION, 2, 3, ignored), createKeyValue(MUTATION, 3, 3, ignored), createKeyValue(MUTATION, 4, 3, ignored),};
KeyValue entries5[] = new KeyValue[] {createKeyValue(OPEN, 0, 4, "70"), createKeyValue(DEFINE_TABLET, 1, 4, extent),
createKeyValue(COMPACTION_START, 3, 4, "thisfile"), createKeyValue(MUTATION, 2, 4, ignored), createKeyValue(MUTATION, 6, 4, m2),};
-
+
Map<String,KeyValue[]> logs = new TreeMap<String,KeyValue[]>();
logs.put("entries", entries);
logs.put("entries2", entries2);
logs.put("entries3", entries3);
logs.put("entries4", entries4);
logs.put("entries5", entries5);
-
+
// Recover
List<Mutation> mutations = recover(logs, extent);
-
+
// Verify recovered data
Assert.assertEquals(2, mutations.size());
Assert.assertEquals(m, mutations.get(0));
Assert.assertEquals(m2, mutations.get(1));
}
-
+
@Test
public void testCompactionCrossesLogs5() throws IOException {
// Create a test log
@@ -215,7 +216,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m3, mutations.get(2));
Assert.assertEquals(m4, mutations.get(3));
}
-
+
@Test
public void testCompactionCrossesLogs6() throws IOException {
// Create a test log
@@ -235,20 +236,20 @@ public class SortedLogRecoveryTest {
createKeyValue(MUTATION, 3, 1, m),};
KeyValue entries2[] = new KeyValue[] {createKeyValue(OPEN, 0, 1, "2"), createKeyValue(DEFINE_TABLET, 1, 1, extent),
createKeyValue(COMPACTION_START, 2, 1, "somefile"), createKeyValue(COMPACTION_FINISH, 3, 1, "somefile"), createKeyValue(MUTATION, 3, 1, m2),};
-
+
Map<String,KeyValue[]> logs = new TreeMap<String,KeyValue[]>();
logs.put("entries", entries);
logs.put("entries2", entries2);
-
+
// Recover
List<Mutation> mutations = recover(logs, extent);
-
+
// Verify recovered data
Assert.assertEquals(2, mutations.size());
Assert.assertEquals(m, mutations.get(0));
Assert.assertEquals(m2, mutations.get(1));
}
-
+
@Test
public void testEmpty() throws IOException {
// Create a test log
@@ -259,9 +260,9 @@ public class SortedLogRecoveryTest {
List<Mutation> mutations = recover(logs, extent);
// Verify recovered data
Assert.assertEquals(0, mutations.size());
-
+
}
-
+
@Test
public void testMissingDefinition() {
// Create a test log
@@ -274,7 +275,7 @@ public class SortedLogRecoveryTest {
Assert.fail("tablet should not have been found");
} catch (Throwable t) {}
}
-
+
@Test
public void testSimple() throws IOException {
// Create a test log
@@ -289,7 +290,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(1, mutations.size());
Assert.assertEquals(m, mutations.get(0));
}
-
+
@Test
public void testSkipSuccessfulCompaction() throws IOException {
// Create a test log
@@ -308,7 +309,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(1, mutations.size());
Assert.assertEquals(m, mutations.get(0));
}
-
+
@Test
public void testSkipSuccessfulCompactionAcrossFiles() throws IOException {
// Create a test log
@@ -329,7 +330,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(1, mutations.size());
Assert.assertEquals(m, mutations.get(0));
}
-
+
@Test
public void testGetMutationsAfterCompactionStart() throws IOException {
// Create a test log
@@ -353,7 +354,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m, mutations.get(0));
Assert.assertEquals(m2, mutations.get(1));
}
-
+
@Test
public void testDoubleFinish() throws IOException {
// Create a test log
@@ -375,7 +376,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m, mutations.get(0));
Assert.assertEquals(m2, mutations.get(1));
}
-
+
@Test
public void testCompactionCrossesLogs2() throws IOException {
// Create a test log
@@ -404,7 +405,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m2, mutations.get(1));
Assert.assertEquals(m3, mutations.get(2));
}
-
+
@Test
public void testBug1() throws IOException {
// this unit test reproduces a bug that occurred, nothing should recover
@@ -422,7 +423,7 @@ public class SortedLogRecoveryTest {
// Verify recovered data
Assert.assertEquals(0, mutations.size());
}
-
+
@Test
public void testBug2() throws IOException {
// Create a test log
@@ -449,7 +450,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m2, mutations.get(1));
Assert.assertEquals(m3, mutations.get(2));
}
-
+
@Test
public void testCompactionCrossesLogs4() throws IOException {
// Create a test log
@@ -487,9 +488,9 @@ public class SortedLogRecoveryTest {
logs.put("entries2", entries2);
logs.put("entries3", entries3);
// Recover
-
+
List<Mutation> mutations = recover(logs, extent);
-
+
// Verify recovered data
Assert.assertEquals(6, mutations.size());
Assert.assertEquals(m, mutations.get(0));
@@ -499,7 +500,7 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m5, mutations.get(4));
Assert.assertEquals(m6, mutations.get(5));
}
-
+
@Test
public void testLookingForBug3() throws IOException {
Mutation ignored = new ServerMutation(new Text("ignored"));
@@ -532,70 +533,70 @@ public class SortedLogRecoveryTest {
Assert.assertEquals(m4, mutations.get(3));
Assert.assertEquals(m5, mutations.get(4));
}
-
+
@Test
public void testMultipleTabletDefinition() throws Exception {
// test for a tablet defined multiple times in a log file
// there was a bug where the oldest tablet id was used instead
// of the newest
-
+
Mutation ignored = new ServerMutation(new Text("row1"));
ignored.put("foo", "bar", "v1");
Mutation m = new ServerMutation(new Text("row1"));
m.put("foo", "bar", "v1");
-
+
KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 1, extent),
createKeyValue(DEFINE_TABLET, 1, 2, extent), createKeyValue(MUTATION, 2, 2, ignored), createKeyValue(COMPACTION_START, 3, 2, "somefile"),
createKeyValue(MUTATION, 4, 2, m), createKeyValue(COMPACTION_FINISH, 6, 2, null),};
-
+
Arrays.sort(entries);
-
+
Map<String,KeyValue[]> logs = new TreeMap<String,KeyValue[]>();
logs.put("entries", entries);
-
+
List<Mutation> mutations = recover(logs, extent);
-
+
Assert.assertEquals(1, mutations.size());
Assert.assertEquals(m, mutations.get(0));
}
-
+
@Test
public void testNoFinish0() throws Exception {
// its possible that a minor compaction finishes successfully, but the process dies before writing the compaction event
-
+
Mutation ignored = new ServerMutation(new Text("row1"));
ignored.put("foo", "bar", "v1");
-
+
KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 2, extent),
createKeyValue(MUTATION, 2, 2, ignored), createKeyValue(COMPACTION_START, 3, 2, "/t/f1")};
-
+
Arrays.sort(entries);
Map<String,KeyValue[]> logs = new TreeMap<String,KeyValue[]>();
logs.put("entries", entries);
-
+
List<Mutation> mutations = recover(logs, Collections.singleton("/t/f1"), extent);
-
+
Assert.assertEquals(0, mutations.size());
}
-
+
@Test
public void testNoFinish1() throws Exception {
// its possible that a minor compaction finishes successfully, but the process dies before writing the compaction event
-
+
Mutation ignored = new ServerMutation(new Text("row1"));
ignored.put("foo", "bar", "v1");
Mutation m = new ServerMutation(new Text("row1"));
m.put("foo", "bar", "v2");
-
+
KeyValue entries[] = new KeyValue[] {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 1, 2, extent),
createKeyValue(MUTATION, 2, 2, ignored), createKeyValue(COMPACTION_START, 3, 2, "/t/f1"), createKeyValue(MUTATION, 4, 2, m),};
-
+
Arrays.sort(entries);
Map<String,KeyValue[]> logs = new TreeMap<String,KeyValue[]>();
logs.put("entries", entries);
-
+
List<Mutation> mutations = recover(logs, Collections.singleton("/t/f1"), extent);
-
+
Assert.assertEquals(1, mutations.size());
Assert.assertEquals(m, mutations.get(0));
}