You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bh...@apache.org on 2014/02/24 17:01:33 UTC
[2/3] ACCUMULO-841 Refactor randomwalk State class
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
index d9a12fb..d468614 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
@@ -25,14 +25,15 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class RenameTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getConnector();
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getConnector();
Random rand = (Random) state.get("rand");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java
index 1b22f4a..8dd24f7 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java
@@ -31,14 +31,15 @@ import org.apache.accumulo.core.client.TableOfflineException;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class ScanTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getConnector();
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getConnector();
Random rand = (Random) state.get("rand");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
index 502e9e3..142287d 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
@@ -21,13 +21,14 @@ import java.util.List;
import java.util.Properties;
import java.util.Random;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class Setup extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
Random rand = new Random();
state.set("rand", rand);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java
index 657a604..36464e1 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java
@@ -26,6 +26,7 @@ import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.master.state.SetGoalState;
import org.apache.accumulo.server.client.HdfsZooInstance;
import org.apache.accumulo.server.security.SystemCredentials;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.accumulo.trace.instrument.Tracer;
@@ -33,11 +34,11 @@ import org.apache.accumulo.trace.instrument.Tracer;
public class Shutdown extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
log.debug("shutting down");
SetGoalState.main(new String[] {MasterGoalState.CLEAN_STOP.name()});
- while (!state.getConnector().instanceOperations().getTabletServers().isEmpty()) {
+ while (!env.getConnector().instanceOperations().getTabletServers().isEmpty()) {
UtilWaitThread.sleep(1000);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StartAll.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StartAll.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StartAll.java
index 2427d1e..4fc94d8 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StartAll.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StartAll.java
@@ -27,6 +27,7 @@ import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.master.state.SetGoalState;
import org.apache.accumulo.server.client.HdfsZooInstance;
import org.apache.accumulo.server.security.SystemCredentials;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.accumulo.trace.instrument.Tracer;
@@ -34,7 +35,7 @@ import org.apache.accumulo.trace.instrument.Tracer;
public class StartAll extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
log.info("Starting all servers");
SetGoalState.main(new String[] {MasterGoalState.NORMAL.name()});
Process exec = Runtime.getRuntime().exec(new String[] {System.getenv().get("ACCUMULO_HOME") + "/bin/start-all.sh"});
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java
index c8da3d8..f42241f 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/StopTabletServer.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.zookeeper.ZooUtil;
import org.apache.accumulo.fate.zookeeper.ZooReader;
import org.apache.accumulo.server.master.state.TServerInstance;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.zookeeper.KeeperException;
@@ -59,9 +60,9 @@ public class StopTabletServer extends Test {
}
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
- Instance instance = state.getInstance();
+ Instance instance = env.getInstance();
List<TServerInstance> currentServers = new ArrayList<TServerInstance>(getTServers(instance));
Collections.shuffle(currentServers);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
index 66acc86..df9803f 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
@@ -20,6 +20,7 @@ import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -29,10 +30,10 @@ import org.apache.hadoop.io.Text;
*/
public class Compact extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String table = state.getString("tableName");
Random rand = (Random) state.get("rand");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
@@ -44,4 +45,4 @@ public class Compact extends Test {
log.debug("compacting " + row1 + " " + row2);
conn.tableOperations().compact(table, row1, row2, rand.nextBoolean(), rand.nextBoolean());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
index c4923de..37c8c91 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
@@ -20,6 +20,7 @@ import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -29,10 +30,10 @@ import org.apache.hadoop.io.Text;
*/
public class Flush extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String table = state.getString("tableName");
Random rand = (Random) state.get("rand");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
index bfad730..3a2ea6c 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
@@ -26,6 +26,7 @@ import org.apache.accumulo.core.client.ConditionalWriter;
import org.apache.accumulo.core.client.ConditionalWriter.Status;
import org.apache.accumulo.core.data.Condition;
import org.apache.accumulo.core.data.ConditionalMutation;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -36,7 +37,7 @@ import org.apache.hadoop.io.Text;
public class Init extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
int numBanks = (Integer) state.get("numBanks");
int numAccts = (Integer) state.get("numAccts");
@@ -45,7 +46,7 @@ public class Init extends Test {
TreeSet<Text> splits = new TreeSet<Text>();
for (int i = 1; i < 10; i++)
splits.add(new Text(Utils.getBank((int) (numBanks * .1 * i))));
- state.getConnector().tableOperations().addSplits((String) state.get("tableName"), splits);
+ env.getConnector().tableOperations().addSplits((String) state.get("tableName"), splits);
log.debug("Added splits " + splits);
ArrayList<Integer> banks = new ArrayList<Integer>();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
index bb3cf60..a6318d5 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
@@ -20,6 +20,7 @@ import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -29,10 +30,10 @@ import org.apache.hadoop.io.Text;
*/
public class Merge extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String table = state.getString("tableName");
Random rand = (Random) state.get("rand");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
index 0aa36c4..90c2978 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
@@ -23,13 +23,14 @@ import org.apache.accumulo.core.client.ConditionalWriter;
import org.apache.accumulo.core.client.ConditionalWriterConfig;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class Setup extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
Random rand = new Random();
state.set("rand", rand);
@@ -45,15 +46,15 @@ public class Setup extends Test {
state.set("tableName", tableName);
try {
- state.getConnector().tableOperations().create(tableName);
+ env.getConnector().tableOperations().create(tableName);
log.debug("created table " + tableName);
boolean blockCache = rand.nextBoolean();
- state.getConnector().tableOperations().setProperty(tableName, Property.TABLE_BLOCKCACHE_ENABLED.getKey(), blockCache + "");
+ env.getConnector().tableOperations().setProperty(tableName, Property.TABLE_BLOCKCACHE_ENABLED.getKey(), blockCache + "");
log.debug("set " + Property.TABLE_BLOCKCACHE_ENABLED.getKey() + " " + blockCache);
} catch (TableExistsException tee) {}
- ConditionalWriter cw = state.getConnector()
+ ConditionalWriter cw = env.getConnector()
.createConditionalWriter(tableName, new ConditionalWriterConfig().setMaxWriteThreads(1));
state.set("cw", cw);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
index 3b47762..c6665b9 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
@@ -22,6 +22,7 @@ import java.util.Random;
import java.util.TreeSet;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -31,10 +32,10 @@ import org.apache.hadoop.io.Text;
*/
public class Split extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String table = state.getString("tableName");
Random rand = (Random) state.get("rand");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
String row = Utils.getBank(rand.nextInt((Integer) state.get("numBanks")));
log.debug("adding split " + row);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
index 1624371..3f326c0 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.test.randomwalk.conditional;
import java.util.Properties;
import org.apache.accumulo.core.client.ConditionalWriter;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
@@ -27,7 +28,7 @@ import org.apache.accumulo.test.randomwalk.Test;
*/
public class TearDown extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
ConditionalWriter cw = (ConditionalWriter) state.get("cw");
cw.close();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
index 93f0d55..4d0e751 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
@@ -31,6 +31,7 @@ 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.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.commons.math.distribution.ZipfDistributionImpl;
@@ -59,10 +60,10 @@ public class Transfer extends Test {
}
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String table = state.getString("tableName");
Random rand = (Random) state.get("rand");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
int numAccts = (Integer) state.get("numAccts");
// note: non integer exponents are slow
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
index e3314f7..043ea71 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
@@ -33,4 +33,4 @@ public class Utils {
static String getSeq(int s) {
return String.format("%06d", s);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
index 86a5768..8acc3ed 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.user.ColumnSliceFilter;
import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
@@ -38,9 +39,9 @@ import org.apache.accumulo.test.randomwalk.Test;
public class Verify extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String table = state.getString("tableName");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
int numAccts = (Integer) state.get("numAccts");
@@ -83,4 +84,4 @@ public class Verify extends Test {
log.debug("Verified " + row + " count = " + count + " sum = " + sum + " min = " + min + " max = " + max);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Commit.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Commit.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Commit.java
index 3a805ef..26b69cd 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Commit.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Commit.java
@@ -18,14 +18,15 @@ package org.apache.accumulo.test.randomwalk.image;
import java.util.Properties;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class Commit extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- state.getMultiTableBatchWriter().flush();
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ env.getMultiTableBatchWriter().flush();
log.debug("Committed " + state.getLong("numWrites") + " writes. Total writes: " + state.getLong("totalWrites"));
state.set("numWrites", Long.valueOf(0));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
index 723bfa8..bcf7cad 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ImageFixture.java
@@ -32,6 +32,7 @@ import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.test.randomwalk.Fixture;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.hadoop.io.Text;
@@ -41,10 +42,10 @@ public class ImageFixture extends Fixture {
String indexTableName;
@Override
- public void setUp(State state) throws Exception {
+ public void setUp(State state, Environment env) throws Exception {
- Connector conn = state.getConnector();
- Instance instance = state.getInstance();
+ Connector conn = env.getConnector();
+ Instance instance = env.getInstance();
SortedSet<Text> splits = new TreeSet<Text>();
for (int i = 1; i < 256; i++) {
@@ -52,7 +53,7 @@ public class ImageFixture extends Fixture {
}
String hostname = InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_");
- String pid = state.getPid();
+ String pid = env.getPid();
imageTableName = String.format("img_%s_%s_%d", hostname, pid, System.currentTimeMillis());
state.set("imageTableName", imageTableName);
@@ -106,10 +107,10 @@ public class ImageFixture extends Fixture {
}
@Override
- public void tearDown(State state) throws Exception {
+ public void tearDown(State state, Environment env) throws Exception {
// We have resources we need to clean up
- if (state.isMultiTableBatchWriterInitialized()) {
- MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+ if (env.isMultiTableBatchWriterInitialized()) {
+ MultiTableBatchWriter mtbw = env.getMultiTableBatchWriter();
try {
mtbw.close();
} catch (MutationsRejectedException e) {
@@ -117,13 +118,13 @@ public class ImageFixture extends Fixture {
}
// Reset the MTBW on the state to null
- state.resetMultiTableBatchWriter();
+ env.resetMultiTableBatchWriter();
}
// Now we can safely delete the tables
log.debug("Dropping tables: " + imageTableName + " " + indexTableName);
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
conn.tableOperations().delete(imageTableName);
conn.tableOperations().delete(indexTableName);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ScanMeta.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ScanMeta.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ScanMeta.java
index 77c66ed..6946b6d 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ScanMeta.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/ScanMeta.java
@@ -32,6 +32,7 @@ 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.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -39,7 +40,7 @@ import org.apache.hadoop.io.Text;
public class ScanMeta extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
// scan just the metadata of the images table to find N hashes... use the batch scanner to lookup those N hashes in the index table
// this scan will test locality groups....
@@ -49,7 +50,7 @@ public class ScanMeta extends Test {
String uuid = UUID.randomUUID().toString();
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
Scanner imageScanner = conn.createScanner(imageTableName, new Authorizations());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/image/TableOp.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/TableOp.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/TableOp.java
index 5f65180..bf3ff17 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/TableOp.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/TableOp.java
@@ -24,6 +24,7 @@ import java.util.Set;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.admin.TableOperations;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -31,7 +32,7 @@ import org.apache.hadoop.io.Text;
public class TableOp extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
// choose a table
Random rand = new Random();
@@ -43,7 +44,7 @@ public class TableOp extends Test {
}
// check if chosen table exists
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
TableOperations tableOps = conn.tableOperations();
if (tableOps.exists(tableName) == false) {
log.error("Table " + tableName + " does not exist!");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java
index ba0ed73..08b306c 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Verify.java
@@ -30,6 +30,7 @@ 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.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -40,7 +41,7 @@ public class Verify extends Test {
String imageTableName;
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
Random rand = new Random();
@@ -50,7 +51,7 @@ public class Verify extends Test {
indexTableName = state.getString("indexTableName");
imageTableName = state.getString("imageTableName");
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
Scanner indexScanner = conn.createScanner(indexTableName, new Authorizations());
Scanner imageScanner = conn.createScanner(imageTableName, new Authorizations());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java
index 53dfe21..cb7281a 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/image/Write.java
@@ -26,6 +26,7 @@ import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.MultiTableBatchWriter;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -40,9 +41,9 @@ public class Write extends Test {
static final Text CONTENT_COLUMN_FAMILY = new Text("content");
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
- MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+ MultiTableBatchWriter mtbw = env.getMultiTableBatchWriter();
BatchWriter imagesBW = mtbw.getBatchWriter(state.getString("imageTableName"));
BatchWriter indexBW = mtbw.getBatchWriter(state.getString("indexTableName"));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Commit.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Commit.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Commit.java
index 1153634..106de52 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Commit.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Commit.java
@@ -18,14 +18,15 @@ package org.apache.accumulo.test.randomwalk.multitable;
import java.util.Properties;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class Commit extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- state.getMultiTableBatchWriter().flush();
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ env.getMultiTableBatchWriter().flush();
Long numWrites = state.getLong("numWrites");
Long totalWrites = state.getLong("totalWrites") + numWrites;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
index 5a2172d..36f497c 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
@@ -22,6 +22,7 @@ import java.util.Random;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.util.ToolRunner;
@@ -29,7 +30,7 @@ import org.apache.hadoop.util.ToolRunner;
public class CopyTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
@@ -44,29 +45,29 @@ public class CopyTable extends Test {
String[] args = new String[8];
args[0] = "-libjars";
- args[1] = state.getMapReduceJars();
- args[2] = state.getProperty("USERNAME");
- args[3] = state.getProperty("PASSWORD");
+ args[1] = getMapReduceJars();
+ args[2] = env.getUserName();
+ args[3] = env.getPassword();
args[4] = srcTableName;
- args[5] = state.getInstance().getInstanceName();
- args[6] = state.getProperty("ZOOKEEPERS");
+ args[5] = env.getInstance().getInstanceName();
+ args[6] = env.getConfigProperty("ZOOKEEPERS");
args[7] = dstTableName;
log.debug("copying " + srcTableName + " to " + dstTableName);
- state.getConnector().tableOperations().create(dstTableName);
+ env.getConnector().tableOperations().create(dstTableName);
if (ToolRunner.run(CachedConfiguration.getInstance(), new CopyTool(), args) != 0) {
log.error("Failed to run map/red verify");
return;
}
- String tableId = Tables.getNameToIdMap(state.getInstance()).get(dstTableName);
+ String tableId = Tables.getNameToIdMap(env.getInstance()).get(dstTableName);
log.debug("copied " + srcTableName + " to " + dstTableName + " (id - " + tableId + " )");
tables.add(dstTableName);
- state.getConnector().tableOperations().delete(srcTableName);
+ env.getConnector().tableOperations().delete(srcTableName);
log.debug("dropped " + srcTableName);
nextId++;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
index 5f37913..3875a0b 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
@@ -22,20 +22,21 @@ import java.util.Properties;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.impl.Tables;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class CreateTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getConnector();
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getConnector();
int nextId = ((Integer) state.get("nextId")).intValue();
String tableName = String.format("%s_%d", state.getString("tableNamePrefix"), nextId);
try {
conn.tableOperations().create(tableName);
- String tableId = Tables.getNameToIdMap(state.getInstance()).get(tableName);
+ String tableId = Tables.getNameToIdMap(env.getInstance()).get(tableName);
log.debug("created " + tableName + " (id:" + tableId + ")");
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/DropTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/DropTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/DropTable.java
index b6cdb43..9a670dc 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/DropTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/DropTable.java
@@ -21,13 +21,14 @@ import java.util.Properties;
import java.util.Random;
import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class DropTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
@@ -41,7 +42,7 @@ public class DropTable extends Test {
String tableName = tables.remove(rand.nextInt(tables.size()));
try {
- state.getConnector().tableOperations().delete(tableName);
+ env.getConnector().tableOperations().delete(tableName);
log.debug("Dropped " + tableName);
} catch (TableNotFoundException e) {
log.error("Tried to drop table " + tableName + " but could not be found!");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
index 8b209b3..536de08 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/MultiTableFixture.java
@@ -24,16 +24,17 @@ import org.apache.accumulo.core.client.MultiTableBatchWriter;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.test.randomwalk.Fixture;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
public class MultiTableFixture extends Fixture {
@Override
- public void setUp(State state) throws Exception {
+ public void setUp(State state, Environment env) throws Exception {
String hostname = InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_");
- state.set("tableNamePrefix", String.format("multi_%s_%s_%d", hostname, state.getPid(), System.currentTimeMillis()));
+ state.set("tableNamePrefix", String.format("multi_%s_%s_%d", hostname, env.getPid(), System.currentTimeMillis()));
state.set("nextId", Integer.valueOf(0));
state.set("numWrites", Long.valueOf(0));
state.set("totalWrites", Long.valueOf(0));
@@ -41,10 +42,10 @@ public class MultiTableFixture extends Fixture {
}
@Override
- public void tearDown(State state) throws Exception {
+ public void tearDown(State state, Environment env) throws Exception {
// We have resources we need to clean up
- if (state.isMultiTableBatchWriterInitialized()) {
- MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
+ if (env.isMultiTableBatchWriterInitialized()) {
+ MultiTableBatchWriter mtbw = env.getMultiTableBatchWriter();
try {
mtbw.close();
} catch (MutationsRejectedException e) {
@@ -52,10 +53,10 @@ public class MultiTableFixture extends Fixture {
}
// Reset the MTBW on the state to null
- state.resetMultiTableBatchWriter();
+ env.resetMultiTableBatchWriter();
}
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/OfflineTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/OfflineTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/OfflineTable.java
index 3e16f4d..bc54ada 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/OfflineTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/OfflineTable.java
@@ -20,13 +20,14 @@ import java.util.ArrayList;
import java.util.Properties;
import java.util.Random;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class OfflineTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
@@ -38,9 +39,9 @@ public class OfflineTable extends Test {
Random rand = new Random();
String tableName = tables.get(rand.nextInt(tables.size()));
- state.getConnector().tableOperations().offline(tableName, rand.nextBoolean());
+ env.getConnector().tableOperations().offline(tableName, rand.nextBoolean());
log.debug("Table " + tableName + " offline ");
- state.getConnector().tableOperations().online(tableName, rand.nextBoolean());
+ env.getConnector().tableOperations().online(tableName, rand.nextBoolean());
log.debug("Table " + tableName + " online ");
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java
index 0b9c062..4761d2a 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/Write.java
@@ -28,6 +28,7 @@ import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.TableOfflineException;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
import org.apache.hadoop.io.Text;
@@ -35,7 +36,7 @@ import org.apache.hadoop.io.Text;
public class Write extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
@SuppressWarnings("unchecked")
ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
@@ -50,7 +51,7 @@ public class Write extends Test {
BatchWriter bw = null;
try {
- bw = state.getMultiTableBatchWriter().getBatchWriter(tableName);
+ bw = env.getMultiTableBatchWriter().getBatchWriter(tableName);
} catch (TableOfflineException e) {
log.error("Table " + tableName + " is offline!");
return;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterSystemPerm.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterSystemPerm.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterSystemPerm.java
index cfc2067..663f2c2 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterSystemPerm.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterSystemPerm.java
@@ -23,20 +23,21 @@ import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class AlterSystemPerm extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getConnector();
- WalkingSecurity ws = new WalkingSecurity(state);
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getConnector();
+ WalkingSecurity ws = new WalkingSecurity(state,env);
String action = props.getProperty("task", "toggle");
String perm = props.getProperty("perm", "random");
- String targetUser = WalkingSecurity.get(state).getSysUserName();
+ String targetUser = WalkingSecurity.get(state,env).getSysUserName();
SystemPermission sysPerm;
if (perm.equals("random")) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java
index a879361..4f9a8b9 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java
@@ -25,27 +25,28 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class AlterTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getInstance().getConnector(WalkingSecurity.get(state,env).getSysUserName(), WalkingSecurity.get(state,env).getSysToken());
- String tableName = WalkingSecurity.get(state).getTableName();
- String namespaceName = WalkingSecurity.get(state).getNamespaceName();
+ String tableName = WalkingSecurity.get(state,env).getTableName();
+ String namespaceName = WalkingSecurity.get(state,env).getNamespaceName();
- boolean exists = WalkingSecurity.get(state).getTableExists();
- boolean hasPermission = WalkingSecurity.get(state).canAlterTable(WalkingSecurity.get(state).getSysCredentials(), tableName, namespaceName);
- String newTableName = String.format("security_%s_%s_%d", InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_"), state.getPid(),
+ boolean exists = WalkingSecurity.get(state,env).getTableExists();
+ boolean hasPermission = WalkingSecurity.get(state,env).canAlterTable(WalkingSecurity.get(state,env).getSysCredentials(), tableName, namespaceName);
+ String newTableName = String.format("security_%s_%s_%d", InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_"), env.getPid(),
System.currentTimeMillis());
- renameTable(conn, state, tableName, newTableName, hasPermission, exists);
+ renameTable(conn, state, env, tableName, newTableName, hasPermission, exists);
}
- public static void renameTable(Connector conn, State state, String oldName, String newName, boolean hasPermission, boolean tableExists)
+ public static void renameTable(Connector conn, State state, Environment env, String oldName, String newName, boolean hasPermission, boolean tableExists)
throws AccumuloSecurityException, AccumuloException, TableExistsException {
try {
conn.tableOperations().rename(oldName, newName);
@@ -56,7 +57,7 @@ public class AlterTable extends Test {
else
return;
} else if (ae.getSecurityErrorCode().equals(SecurityErrorCode.BAD_CREDENTIALS)) {
- if (WalkingSecurity.get(state).userPassTransient(conn.whoami()))
+ if (WalkingSecurity.get(state,env).userPassTransient(conn.whoami()))
return;
}
throw new AccumuloException("Got unexpected ae error code", ae);
@@ -66,7 +67,7 @@ public class AlterTable extends Test {
else
return;
}
- WalkingSecurity.get(state).setTableName(newName);
+ WalkingSecurity.get(state,env).setTableName(newName);
if (!hasPermission)
throw new AccumuloException("Didn't get Security Exception when we should have");
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java
index 335ae31..42ac364 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java
@@ -25,31 +25,32 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.security.Credentials;
import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class AlterTablePerm extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- alter(state, props);
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ alter(state, env, props);
}
- public static void alter(State state, Properties props) throws Exception {
+ public static void alter(State state, Environment env, Properties props) throws Exception {
String action = props.getProperty("task", "toggle");
String perm = props.getProperty("perm", "random");
String sourceUserProp = props.getProperty("source", "system");
String targetUser = props.getProperty("target", "table");
- boolean tabExists = WalkingSecurity.get(state).getTableExists();
+ boolean tabExists = WalkingSecurity.get(state,env).getTableExists();
String target;
if ("table".equals(targetUser))
- target = WalkingSecurity.get(state).getTabUserName();
+ target = WalkingSecurity.get(state,env).getTabUserName();
else
- target = WalkingSecurity.get(state).getSysUserName();
+ target = WalkingSecurity.get(state,env).getSysUserName();
- boolean exists = WalkingSecurity.get(state).userExists(target);
- boolean tableExists = WalkingSecurity.get(state).getTableExists();
+ boolean exists = WalkingSecurity.get(state,env).userExists(target);
+ boolean tableExists = WalkingSecurity.get(state,env).getTableExists();
TablePermission tabPerm;
if (perm.equals("random")) {
@@ -58,31 +59,31 @@ public class AlterTablePerm extends Test {
tabPerm = TablePermission.values()[i];
} else
tabPerm = TablePermission.valueOf(perm);
- String tableName = WalkingSecurity.get(state).getTableName();
- boolean hasPerm = WalkingSecurity.get(state).hasTablePermission(target, tableName, tabPerm);
+ String tableName = WalkingSecurity.get(state,env).getTableName();
+ boolean hasPerm = WalkingSecurity.get(state,env).hasTablePermission(target, tableName, tabPerm);
boolean canGive;
String sourceUser;
AuthenticationToken sourceToken;
if ("system".equals(sourceUserProp)) {
- sourceUser = WalkingSecurity.get(state).getSysUserName();
- sourceToken = WalkingSecurity.get(state).getSysToken();
+ sourceUser = WalkingSecurity.get(state,env).getSysUserName();
+ sourceToken = WalkingSecurity.get(state,env).getSysToken();
} else if ("table".equals(sourceUserProp)) {
- sourceUser = WalkingSecurity.get(state).getTabUserName();
- sourceToken = WalkingSecurity.get(state).getTabToken();
+ sourceUser = WalkingSecurity.get(state,env).getTabUserName();
+ sourceToken = WalkingSecurity.get(state,env).getTabToken();
} else {
- sourceUser = state.getUserName();
- sourceToken = state.getToken();
+ sourceUser = env.getUserName();
+ sourceToken = env.getToken();
}
- Connector conn = state.getInstance().getConnector(sourceUser, sourceToken);
+ Connector conn = env.getInstance().getConnector(sourceUser, sourceToken);
- canGive = WalkingSecurity.get(state).canGrantTable(new Credentials(sourceUser, sourceToken).toThrift(state.getInstance()), target,
- WalkingSecurity.get(state).getTableName(), WalkingSecurity.get(state).getNamespaceName());
+ canGive = WalkingSecurity.get(state,env).canGrantTable(new Credentials(sourceUser, sourceToken).toThrift(env.getInstance()), target,
+ WalkingSecurity.get(state,env).getTableName(), WalkingSecurity.get(state,env).getNamespaceName());
// toggle
if (!"take".equals(action) && !"give".equals(action)) {
try {
boolean res;
- if (hasPerm != (res = state.getConnector().securityOperations().hasTablePermission(target, tableName, tabPerm)))
+ if (hasPerm != (res = env.getConnector().securityOperations().hasTablePermission(target, tableName, tabPerm)))
throw new AccumuloException("Test framework and accumulo are out of sync for user " + conn.whoami() + " for perm " + tabPerm.name()
+ " with local vs. accumulo being " + hasPerm + " " + res);
@@ -108,7 +109,7 @@ public class AlterTablePerm extends Test {
}
}
- boolean trans = WalkingSecurity.get(state).userPassTransient(conn.whoami());
+ boolean trans = WalkingSecurity.get(state,env).userPassTransient(conn.whoami());
if ("take".equals(action)) {
try {
conn.securityOperations().revokeTablePermission(target, tableName, tabPerm);
@@ -136,7 +137,7 @@ public class AlterTablePerm extends Test {
throw new AccumuloException("Got unexpected exception", ae);
}
}
- WalkingSecurity.get(state).revokeTablePermission(target, tableName, tabPerm);
+ WalkingSecurity.get(state,env).revokeTablePermission(target, tableName, tabPerm);
} else if ("give".equals(action)) {
try {
conn.securityOperations().grantTablePermission(target, tableName, tabPerm);
@@ -164,7 +165,7 @@ public class AlterTablePerm extends Test {
throw new AccumuloException("Got unexpected exception", ae);
}
}
- WalkingSecurity.get(state).grantTablePermission(target, tableName, tabPerm);
+ WalkingSecurity.get(state,env).grantTablePermission(target, tableName, tabPerm);
}
if (!exists)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java
index 14f5028..1b4b15c 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java
@@ -25,33 +25,34 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.security.Credentials;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class Authenticate extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- authenticate(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken(), state, props);
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ authenticate(WalkingSecurity.get(state,env).getSysUserName(), WalkingSecurity.get(state,env).getSysToken(), state, env, props);
}
- public static void authenticate(String principal, AuthenticationToken token, State state, Properties props) throws Exception {
+ public static void authenticate(String principal, AuthenticationToken token, State state, Environment env, Properties props) throws Exception {
String targetProp = props.getProperty("target");
boolean success = Boolean.parseBoolean(props.getProperty("valid"));
- Connector conn = state.getInstance().getConnector(principal, token);
+ Connector conn = env.getInstance().getConnector(principal, token);
String target;
if (targetProp.equals("table")) {
- target = WalkingSecurity.get(state).getTabUserName();
+ target = WalkingSecurity.get(state,env).getTabUserName();
} else {
- target = WalkingSecurity.get(state).getSysUserName();
+ target = WalkingSecurity.get(state,env).getSysUserName();
}
- boolean exists = WalkingSecurity.get(state).userExists(target);
+ boolean exists = WalkingSecurity.get(state,env).userExists(target);
// Copy so if failed it doesn't mess with the password stored in state
- byte[] password = Arrays.copyOf(WalkingSecurity.get(state).getUserPassword(target), WalkingSecurity.get(state).getUserPassword(target).length);
- boolean hasPermission = WalkingSecurity.get(state).canAskAboutUser(new Credentials(principal, token).toThrift(state.getInstance()), target);
+ byte[] password = Arrays.copyOf(WalkingSecurity.get(state,env).getUserPassword(target), WalkingSecurity.get(state,env).getUserPassword(target).length);
+ boolean hasPermission = WalkingSecurity.get(state,env).canAskAboutUser(new Credentials(principal, token).toThrift(env.getInstance()), target);
if (!success)
for (int i = 0; i < password.length; i++)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java
index 439e724..724ec98 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java
@@ -25,37 +25,38 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.security.Credentials;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class ChangePass extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
+ public void visit(State state, Environment env, Properties props) throws Exception {
String target = props.getProperty("target");
String source = props.getProperty("source");
String principal;
AuthenticationToken token;
if (source.equals("system")) {
- principal = WalkingSecurity.get(state).getSysUserName();
- token = WalkingSecurity.get(state).getSysToken();
+ principal = WalkingSecurity.get(state,env).getSysUserName();
+ token = WalkingSecurity.get(state,env).getSysToken();
} else {
- principal = WalkingSecurity.get(state).getTabUserName();
- token = WalkingSecurity.get(state).getTabToken();
+ principal = WalkingSecurity.get(state,env).getTabUserName();
+ token = WalkingSecurity.get(state,env).getTabToken();
}
- Connector conn = state.getInstance().getConnector(principal, token);
+ Connector conn = env.getInstance().getConnector(principal, token);
boolean hasPerm;
boolean targetExists;
if (target.equals("table")) {
- target = WalkingSecurity.get(state).getTabUserName();
+ target = WalkingSecurity.get(state,env).getTabUserName();
} else
- target = WalkingSecurity.get(state).getSysUserName();
+ target = WalkingSecurity.get(state,env).getSysUserName();
- targetExists = WalkingSecurity.get(state).userExists(target);
+ targetExists = WalkingSecurity.get(state,env).userExists(target);
- hasPerm = WalkingSecurity.get(state).canChangePassword(new Credentials(principal, token).toThrift(state.getInstance()), target);
+ hasPerm = WalkingSecurity.get(state,env).canChangePassword(new Credentials(principal, token).toThrift(env.getInstance()), target);
Random r = new Random();
@@ -77,14 +78,14 @@ public class ChangePass extends Test {
throw new AccumuloException("User " + target + " doesn't exist and they SHOULD.", ae);
return;
case BAD_CREDENTIALS:
- if (!WalkingSecurity.get(state).userPassTransient(conn.whoami()))
+ if (!WalkingSecurity.get(state,env).userPassTransient(conn.whoami()))
throw new AccumuloException("Bad credentials for user " + conn.whoami());
return;
default:
throw new AccumuloException("Got unexpected exception", ae);
}
}
- WalkingSecurity.get(state).changePassword(target, newPass);
+ WalkingSecurity.get(state,env).changePassword(target, newPass);
// Waiting 1 second for password to propogate through Zk
Thread.sleep(1000);
if (!hasPerm)
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java
index 4c10b13..0866923 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java
@@ -24,19 +24,20 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class CreateTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getInstance().getConnector(WalkingSecurity.get(state,env).getSysUserName(), WalkingSecurity.get(state,env).getSysToken());
- String tableName = WalkingSecurity.get(state).getTableName();
+ String tableName = WalkingSecurity.get(state,env).getTableName();
- boolean exists = WalkingSecurity.get(state).getTableExists();
- boolean hasPermission = WalkingSecurity.get(state).canCreateTable(WalkingSecurity.get(state).getSysCredentials(), null, null);
+ boolean exists = WalkingSecurity.get(state,env).getTableExists();
+ boolean hasPermission = WalkingSecurity.get(state,env).canCreateTable(WalkingSecurity.get(state,env).getSysCredentials(), null, null);
try {
conn.tableOperations().create(tableName);
@@ -48,8 +49,8 @@ public class CreateTable extends Test {
// create table anyway for sake of state
{
try {
- state.getConnector().tableOperations().create(tableName);
- WalkingSecurity.get(state).initTable(tableName);
+ env.getConnector().tableOperations().create(tableName);
+ WalkingSecurity.get(state,env).initTable(tableName);
} catch (TableExistsException tee) {
if (exists)
return;
@@ -66,9 +67,9 @@ public class CreateTable extends Test {
else
return;
}
- WalkingSecurity.get(state).initTable(tableName);
+ WalkingSecurity.get(state,env).initTable(tableName);
for (TablePermission tp : TablePermission.values())
- WalkingSecurity.get(state).grantTablePermission(conn.whoami(), tableName, tp);
+ WalkingSecurity.get(state,env).grantTablePermission(conn.whoami(), tableName, tp);
if (!hasPermission)
throw new AccumuloException("Didn't get Security Exception when we should have");
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
index cffcb95..336b4e4 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
@@ -22,19 +22,20 @@ import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class CreateUser extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getInstance().getConnector(WalkingSecurity.get(state,env).getSysUserName(), WalkingSecurity.get(state,env).getSysToken());
- String tableUserName = WalkingSecurity.get(state).getTabUserName();
+ String tableUserName = WalkingSecurity.get(state,env).getTabUserName();
- boolean exists = WalkingSecurity.get(state).userExists(tableUserName);
- boolean hasPermission = WalkingSecurity.get(state).canCreateUser(WalkingSecurity.get(state).getSysCredentials(), tableUserName);
+ boolean exists = WalkingSecurity.get(state,env).userExists(tableUserName);
+ boolean hasPermission = WalkingSecurity.get(state,env).canCreateUser(WalkingSecurity.get(state,env).getSysCredentials(), tableUserName);
PasswordToken tabUserPass = new PasswordToken("Super Sekret Table User Password");
try {
conn.securityOperations().createLocalUser(tableUserName, tabUserPass);
@@ -47,8 +48,8 @@ public class CreateUser extends Test {
// create user anyway for sake of state
{
if (!exists) {
- state.getConnector().securityOperations().createLocalUser(tableUserName, tabUserPass);
- WalkingSecurity.get(state).createUser(tableUserName, tabUserPass);
+ env.getConnector().securityOperations().createLocalUser(tableUserName, tabUserPass);
+ WalkingSecurity.get(state,env).createUser(tableUserName, tabUserPass);
Thread.sleep(1000);
}
return;
@@ -62,7 +63,7 @@ public class CreateUser extends Test {
throw new AccumuloException("Got unexpected exception", ae);
}
}
- WalkingSecurity.get(state).createUser(tableUserName, tabUserPass);
+ WalkingSecurity.get(state,env).createUser(tableUserName, tabUserPass);
Thread.sleep(1000);
if (!hasPermission)
throw new AccumuloException("Didn't get Security Exception when we should have");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java
index cfcc270..06aa037 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java
@@ -26,34 +26,35 @@ import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.security.SecurityErrorCode;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.security.Credentials;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class DropTable extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- dropTable(state, props);
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ dropTable(state, env, props);
}
- public static void dropTable(State state, Properties props) throws Exception {
+ public static void dropTable(State state, Environment env, Properties props) throws Exception {
String sourceUser = props.getProperty("source", "system");
String principal;
AuthenticationToken token;
if (sourceUser.equals("table")) {
- principal = WalkingSecurity.get(state).getTabUserName();
- token = WalkingSecurity.get(state).getTabToken();
+ principal = WalkingSecurity.get(state,env).getTabUserName();
+ token = WalkingSecurity.get(state,env).getTabToken();
} else {
- principal = WalkingSecurity.get(state).getSysUserName();
- token = WalkingSecurity.get(state).getSysToken();
+ principal = WalkingSecurity.get(state,env).getSysUserName();
+ token = WalkingSecurity.get(state,env).getSysToken();
}
- Connector conn = state.getInstance().getConnector(principal, token);
+ Connector conn = env.getInstance().getConnector(principal, token);
- String tableName = WalkingSecurity.get(state).getTableName();
- String namespaceName = WalkingSecurity.get(state).getNamespaceName();
+ String tableName = WalkingSecurity.get(state,env).getTableName();
+ String namespaceName = WalkingSecurity.get(state,env).getNamespaceName();
- boolean exists = WalkingSecurity.get(state).getTableExists();
- boolean hasPermission = WalkingSecurity.get(state).canDeleteTable(new Credentials(principal, token).toThrift(state.getInstance()), tableName, namespaceName);
+ boolean exists = WalkingSecurity.get(state,env).getTableExists();
+ boolean hasPermission = WalkingSecurity.get(state,env).canDeleteTable(new Credentials(principal, token).toThrift(env.getInstance()), tableName, namespaceName);
try {
conn.tableOperations().delete(tableName);
@@ -63,12 +64,12 @@ public class DropTable extends Test {
throw new AccumuloException("Got a security exception when I should have had permission.", ae);
else {
// Drop anyway for sake of state
- state.getConnector().tableOperations().delete(tableName);
- WalkingSecurity.get(state).cleanTablePermissions(tableName);
+ env.getConnector().tableOperations().delete(tableName);
+ WalkingSecurity.get(state,env).cleanTablePermissions(tableName);
return;
}
} else if (ae.getSecurityErrorCode().equals(SecurityErrorCode.BAD_CREDENTIALS)) {
- if (WalkingSecurity.get(state).userPassTransient(conn.whoami()))
+ if (WalkingSecurity.get(state,env).userPassTransient(conn.whoami()))
return;
}
throw new AccumuloException("Got unexpected ae error code", ae);
@@ -78,7 +79,7 @@ public class DropTable extends Test {
else
return;
}
- WalkingSecurity.get(state).cleanTablePermissions(tableName);
+ WalkingSecurity.get(state,env).cleanTablePermissions(tableName);
if (!hasPermission)
throw new AccumuloException("Didn't get Security Exception when we should have");
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java
index ddf39aa..f310116 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java
@@ -21,19 +21,20 @@ import java.util.Properties;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class DropUser extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
+ public void visit(State state, Environment env, Properties props) throws Exception {
+ Connector conn = env.getInstance().getConnector(WalkingSecurity.get(state,env).getSysUserName(), WalkingSecurity.get(state,env).getSysToken());
- String tableUserName = WalkingSecurity.get(state).getTabUserName();
+ String tableUserName = WalkingSecurity.get(state,env).getTabUserName();
- boolean exists = WalkingSecurity.get(state).userExists(tableUserName);
- boolean hasPermission = WalkingSecurity.get(state).canDropUser(WalkingSecurity.get(state).getSysCredentials(), tableUserName);
+ boolean exists = WalkingSecurity.get(state,env).userExists(tableUserName);
+ boolean hasPermission = WalkingSecurity.get(state,env).canDropUser(WalkingSecurity.get(state,env).getSysCredentials(), tableUserName);
try {
conn.securityOperations().dropLocalUser(tableUserName);
@@ -44,8 +45,8 @@ public class DropUser extends Test {
throw new AccumuloException("Got a security exception when I should have had permission.", ae);
else {
if (exists) {
- state.getConnector().securityOperations().dropLocalUser(tableUserName);
- WalkingSecurity.get(state).dropUser(tableUserName);
+ env.getConnector().securityOperations().dropLocalUser(tableUserName);
+ WalkingSecurity.get(state,env).dropUser(tableUserName);
}
return;
}
@@ -59,7 +60,7 @@ public class DropUser extends Test {
throw new AccumuloException("Got unexpected exception", ae);
}
}
- WalkingSecurity.get(state).dropUser(tableUserName);
+ WalkingSecurity.get(state,env).dropUser(tableUserName);
if (!hasPermission)
throw new AccumuloException("Didn't get Security Exception when we should have");
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityFixture.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityFixture.java
index 30f12fb..6e1daff 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityFixture.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityFixture.java
@@ -25,14 +25,15 @@ 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.test.randomwalk.Fixture;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
public class SecurityFixture extends Fixture {
@Override
- public void setUp(State state) throws Exception {
+ public void setUp(State state, Environment env) throws Exception {
String secTableName, systemUserName, tableUserName, secNamespaceName;
- Connector conn = state.getConnector();
+ Connector conn = env.getConnector();
String hostname = InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_");
@@ -52,55 +53,55 @@ public class SecurityFixture extends Fixture {
PasswordToken sysUserPass = new PasswordToken("sysUser");
conn.securityOperations().createLocalUser(systemUserName, sysUserPass);
- WalkingSecurity.get(state).setTableName(secTableName);
- WalkingSecurity.get(state).setNamespaceName(secNamespaceName);
- state.set("rootUserPass", state.getCredentials().getToken());
+ WalkingSecurity.get(state,env).setTableName(secTableName);
+ WalkingSecurity.get(state,env).setNamespaceName(secNamespaceName);
+ state.set("rootUserPass", env.getToken());
- WalkingSecurity.get(state).setSysUserName(systemUserName);
- WalkingSecurity.get(state).createUser(systemUserName, sysUserPass);
+ WalkingSecurity.get(state,env).setSysUserName(systemUserName);
+ WalkingSecurity.get(state,env).createUser(systemUserName, sysUserPass);
- WalkingSecurity.get(state).changePassword(tableUserName, new PasswordToken(new byte[0]));
+ WalkingSecurity.get(state,env).changePassword(tableUserName, new PasswordToken(new byte[0]));
- WalkingSecurity.get(state).setTabUserName(tableUserName);
+ WalkingSecurity.get(state,env).setTabUserName(tableUserName);
for (TablePermission tp : TablePermission.values()) {
- WalkingSecurity.get(state).revokeTablePermission(systemUserName, secTableName, tp);
- WalkingSecurity.get(state).revokeTablePermission(tableUserName, secTableName, tp);
+ WalkingSecurity.get(state,env).revokeTablePermission(systemUserName, secTableName, tp);
+ WalkingSecurity.get(state,env).revokeTablePermission(tableUserName, secTableName, tp);
}
for (SystemPermission sp : SystemPermission.values()) {
- WalkingSecurity.get(state).revokeSystemPermission(systemUserName, sp);
- WalkingSecurity.get(state).revokeSystemPermission(tableUserName, sp);
+ WalkingSecurity.get(state,env).revokeSystemPermission(systemUserName, sp);
+ WalkingSecurity.get(state,env).revokeSystemPermission(tableUserName, sp);
}
- WalkingSecurity.get(state).changeAuthorizations(tableUserName, new Authorizations());
+ WalkingSecurity.get(state,env).changeAuthorizations(tableUserName, new Authorizations());
}
@Override
- public void tearDown(State state) throws Exception {
+ public void tearDown(State state, Environment env) throws Exception {
log.debug("One last validate");
- Validate.validate(state, log);
- Connector conn = state.getConnector();
+ Validate.validate(state, env, log);
+ Connector conn = env.getConnector();
- if (WalkingSecurity.get(state).getTableExists()) {
- String secTableName = WalkingSecurity.get(state).getTableName();
+ if (WalkingSecurity.get(state,env).getTableExists()) {
+ String secTableName = WalkingSecurity.get(state,env).getTableName();
log.debug("Dropping tables: " + secTableName);
conn.tableOperations().delete(secTableName);
}
- if (WalkingSecurity.get(state).getNamespaceExists()) {
- String secNamespaceName = WalkingSecurity.get(state).getNamespaceName();
+ if (WalkingSecurity.get(state,env).getNamespaceExists()) {
+ String secNamespaceName = WalkingSecurity.get(state,env).getNamespaceName();
log.debug("Dropping namespace: " + secNamespaceName);
conn.namespaceOperations().delete(secNamespaceName);
}
- if (WalkingSecurity.get(state).userExists(WalkingSecurity.get(state).getTabUserName())) {
- String tableUserName = WalkingSecurity.get(state).getTabUserName();
+ if (WalkingSecurity.get(state,env).userExists(WalkingSecurity.get(state,env).getTabUserName())) {
+ String tableUserName = WalkingSecurity.get(state,env).getTabUserName();
log.debug("Dropping user: " + tableUserName);
conn.securityOperations().dropLocalUser(tableUserName);
}
- String systemUserName = WalkingSecurity.get(state).getSysUserName();
+ String systemUserName = WalkingSecurity.get(state,env).getSysUserName();
log.debug("Dropping user: " + systemUserName);
conn.securityOperations().dropLocalUser(systemUserName);
WalkingSecurity.clearInstance();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/a74f392e/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java
index 81192bd..0cff0bf 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SecurityHelper.java
@@ -25,6 +25,7 @@ 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.CachedConfiguration;
+import org.apache.accumulo.test.randomwalk.Environment;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.hadoop.fs.FileSystem;
import org.apache.log4j.Logger;