accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/6] git commit: ACCUMULO-2587 Fix up the tests to set the user/passwd where required.
Date Tue, 27 May 2014 04:04:19 GMT
ACCUMULO-2587 Fix up the tests to set the user/passwd where required.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3605275d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3605275d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3605275d

Branch: refs/heads/ACCUMULO-378
Commit: 3605275d0bf747d78f6cf5a56725f1d8af34785c
Parents: b3ef383
Author: Josh Elser <elserj@apache.org>
Authored: Sun May 25 22:08:03 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Sun May 25 22:08:03 2014 -0400

----------------------------------------------------------------------
 .../org/apache/accumulo/core/conf/Property.java |  4 +--
 .../MasterReplicationCoordinatorTest.java       | 25 ++++++++++++++++-
 .../test/replication/CyclicReplicationIT.java   | 19 +++++++++++++
 .../test/replication/ReplicationIT.java         | 29 ++++++++++++++++++++
 .../ReplicationPortAdvertisementIT.java         |  1 -
 .../replication/ReplicationSequentialIT.java    | 23 ++++++++++++++++
 6 files changed, 97 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3605275d/core/src/main/java/org/apache/accumulo/core/conf/Property.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
index fe0ea25..8b24332 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@ -467,7 +467,7 @@ public enum Property {
   REPLICATION_PEER_USER("replication.peer.user.", null, PropertyType.PREFIX, "The username
to provide when authenticating with the given peer"),
   @Experimental
   @Sensitive
-  REPLICATION_PEER_PASSWORD("replication.peer.password", null, PropertyType.PREFIX, "The
password to provide when authenticating with the given peer"),
+  REPLICATION_PEER_PASSWORD("replication.peer.password.", null, PropertyType.PREFIX, "The
password to provide when authenticating with the given peer"),
   @Experimental
   REPLICATION_NAME("replication.name", "", PropertyType.STRING, "Name of this cluster with
respect to replication. Used to identify this instance from other peers"),
   @Experimental
@@ -487,7 +487,7 @@ public enum Property {
   @Experimental
   REPLICATION_MAX_UNIT_SIZE("replication.max.unit.size", "64M", PropertyType.MEMORY, "Maximum
size of data to send in a replication message"),
   @Experimental
-  REPLICATION_WORK_ASSIGNER("replication.work.assigner", "org.apache.accumulo.master.replication.DistributedWorkQueueWorkAssigner",
PropertyType.CLASSNAME,
+  REPLICATION_WORK_ASSIGNER("replication.work.assigner", "org.apache.accumulo.master.replication.SequentialWorkAssigner",
PropertyType.CLASSNAME,
       "Replication WorkAssigner implementation to use"),
   @Experimental
   REPLICATION_WORK_PROCESSOR_DELAY("replication.work.processor.delay", "0s", PropertyType.TIMEDURATION,
"Amount of time to wait before first checking for replication work"),

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3605275d/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
b/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
index 045f542..1ec3f24 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/MasterReplicationCoordinatorTest.java
@@ -19,7 +19,7 @@ package org.apache.accumulo.master.replication;
 import java.util.Collections;
 import java.util.TreeSet;
 
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.fate.zookeeper.ZooReader;
 import org.apache.accumulo.master.Master;
 import org.apache.accumulo.server.master.state.TServerInstance;
@@ -38,6 +38,13 @@ public class MasterReplicationCoordinatorTest {
   public void randomServer() {
     Master master = EasyMock.createMock(Master.class);
     ZooReader reader = EasyMock.createMock(ZooReader.class);
+    Instance inst = EasyMock.createMock(Instance.class);
+
+    EasyMock.expect(master.getInstance()).andReturn(inst);
+    EasyMock.expect(inst.getInstanceID()).andReturn("1234");
+
+    EasyMock.replay(master, reader, inst);
+
     MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader);
     TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
 
@@ -48,6 +55,13 @@ public class MasterReplicationCoordinatorTest {
   public void invalidOffset() {
     Master master = EasyMock.createMock(Master.class);
     ZooReader reader = EasyMock.createMock(ZooReader.class);
+    Instance inst = EasyMock.createMock(Instance.class);
+
+    EasyMock.expect(master.getInstance()).andReturn(inst);
+    EasyMock.expect(inst.getInstanceID()).andReturn("1234");
+
+    EasyMock.replay(master, reader, inst);
+
     MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader);
     TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
 
@@ -58,8 +72,17 @@ public class MasterReplicationCoordinatorTest {
   public void randomServerFromMany() {
     Master master = EasyMock.createMock(Master.class);
     ZooReader reader = EasyMock.createMock(ZooReader.class);
+    Instance inst = EasyMock.createMock(Instance.class);
+
+    EasyMock.expect(master.getInstance()).andReturn(inst);
+    EasyMock.expect(inst.getInstanceID()).andReturn("1234");
+
+    EasyMock.replay(master, reader, inst);
+
     MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader);
 
+    EasyMock.verify(master, reader, inst);
+
     TreeSet<TServerInstance> instances = new TreeSet<>();
     TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
     instances.add(inst1);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3605275d/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
b/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
index d8ef56f..a03cfab 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.replication.ReplicaSystemFactory;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -36,6 +37,7 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.LongCombiner.Type;
 import org.apache.accumulo.core.iterators.user.SummingCombiner;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.TablePermission;
 import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
@@ -117,6 +119,19 @@ public class CyclicReplicationIT {
     try {
       Connector connMaster1 = master1Cluster.getConnector("root", password), connMaster2
= master2Cluster.getConnector("root", password);
 
+      String master1UserName = "master1", master1Password = "foo";
+      String master2UserName = "master2", master2Password = "bar";
+
+      connMaster1.securityOperations().createLocalUser(master1UserName, new PasswordToken(master1Password));
+      connMaster2.securityOperations().createLocalUser(master2UserName, new PasswordToken(master2Password));
+
+      // Configure the credentials we should use to authenticate ourselves to the peer for
replication
+      connMaster1.instanceOperations().setProperty(Property.REPLICATION_PEER_USER.getKey()
+ master2Cluster.getInstanceName(), master2UserName);
+      connMaster1.instanceOperations().setProperty(Property.REPLICATION_PEER_PASSWORD.getKey()
+ master2Cluster.getInstanceName(), master2Password);
+      
+      connMaster2.instanceOperations().setProperty(Property.REPLICATION_PEER_USER.getKey()
+ master1Cluster.getInstanceName(), master1UserName);
+      connMaster2.instanceOperations().setProperty(Property.REPLICATION_PEER_PASSWORD.getKey()
+ master1Cluster.getInstanceName(), master1Password);
+
       connMaster1.instanceOperations().setProperty(
           Property.REPLICATION_PEERS.getKey() + master2Cluster.getInstanceName(),
           ReplicaSystemFactory.getPeerConfigurationValue(AccumuloReplicaSystem.class,
@@ -145,6 +160,10 @@ public class CyclicReplicationIT {
       connMaster2.tableOperations().setProperty(master2Cluster.getInstanceName(),
           Property.TABLE_REPLICATION_TARGETS.getKey() + master1Cluster.getInstanceName(),
master1TableId);
 
+      // Give our replication user the ability to write to the respective table
+      connMaster1.securityOperations().grantTablePermission(master1UserName, master1Cluster.getInstanceName(),
TablePermission.WRITE);
+      connMaster2.securityOperations().grantTablePermission(master2UserName, master2Cluster.getInstanceName(),
TablePermission.WRITE);
+
       IteratorSetting summingCombiner = new IteratorSetting(50, SummingCombiner.class);
       SummingCombiner.setEncodingType(summingCombiner, Type.STRING);
       SummingCombiner.setCombineAllColumns(summingCombiner, true);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3605275d/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
index 77dcceb..f34b626 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationIT.java
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.replication.ReplicaSystemFactory;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -35,6 +36,7 @@ import org.apache.accumulo.core.replication.ReplicationSchema.WorkSection;
 import org.apache.accumulo.core.replication.StatusUtil;
 import org.apache.accumulo.core.replication.proto.Replication.Status;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.TablePermission;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
@@ -84,6 +86,12 @@ public class ReplicationIT extends ConfigurableMacIT {
     Connector connMaster = getConnector();
     Connector connPeer = peerCluster.getConnector("root", ROOT_PASSWORD);
 
+    String peerUserName = "repl";
+    String peerPassword = "passwd";
+
+    // Create a user on the peer for replication to use
+    connPeer.securityOperations().createLocalUser(peerUserName, new PasswordToken(peerPassword));
+
     String peerClusterName = "peer";
 
     // ...peer = AccumuloReplicaSystem,instanceName,zookeepers
@@ -92,6 +100,10 @@ public class ReplicationIT extends ConfigurableMacIT {
         ReplicaSystemFactory.getPeerConfigurationValue(AccumuloReplicaSystem.class,
             AccumuloReplicaSystem.buildConfiguration(peerCluster.getInstanceName(), peerCluster.getZooKeepers())));
 
+    // Configure the credentials we should use to authenticate ourselves to the peer for
replication
+    connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_USER.getKey() +
peerClusterName, peerUserName);
+    connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_PASSWORD.getKey()
+ peerClusterName, peerPassword);
+
     String masterTable = "master", peerTable = "peer";
 
     connMaster.tableOperations().create(masterTable);
@@ -102,6 +114,9 @@ public class ReplicationIT extends ConfigurableMacIT {
     String peerTableId = connPeer.tableOperations().tableIdMap().get(peerTable);
     Assert.assertNotNull(peerTableId);
 
+    // Give our replication user the ability to write to the table
+    connPeer.securityOperations().grantTablePermission(peerUserName, peerTable, TablePermission.WRITE);
+
     // Replicate this table to the peerClusterName in a table with the peerTableId table
id
     connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION.getKey(),
"true");
     connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION_TARGETS.getKey()
+ peerClusterName, peerTableId);
@@ -173,6 +188,16 @@ public class ReplicationIT extends ConfigurableMacIT {
 
       String peerClusterName = "peer";
 
+      String peerUserName = "repl";
+      String peerPassword = "passwd";
+
+      // Create a user on the peer for replication to use
+      connPeer.securityOperations().createLocalUser(peerUserName, new PasswordToken(peerPassword));
+
+      // Configure the credentials we should use to authenticate ourselves to the peer for
replication
+      connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_USER.getKey()
+ peerClusterName, peerUserName);
+      connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_PASSWORD.getKey()
+ peerClusterName, peerPassword);
+
       // ...peer = AccumuloReplicaSystem,instanceName,zookeepers
       connMaster.instanceOperations().setProperty(
           Property.REPLICATION_PEERS.getKey() + peerClusterName,
@@ -197,6 +222,10 @@ public class ReplicationIT extends ConfigurableMacIT {
       String peerTableId2 = connPeer.tableOperations().tableIdMap().get(peerTable2);
       Assert.assertNotNull(peerTableId2);
 
+      // Give our replication user the ability to write to the tables
+      connPeer.securityOperations().grantTablePermission(peerUserName, peerTable1, TablePermission.WRITE);
+      connPeer.securityOperations().grantTablePermission(peerUserName, peerTable2, TablePermission.WRITE);
+
       // Replicate this table to the peerClusterName in a table with the peerTableId table
id
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION.getKey(),
"true");
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGETS.getKey()
+ peerClusterName, peerTableId1);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3605275d/test/src/test/java/org/apache/accumulo/test/replication/ReplicationPortAdvertisementIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationPortAdvertisementIT.java
b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationPortAdvertisementIT.java
index f879895..0afbc05 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationPortAdvertisementIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationPortAdvertisementIT.java
@@ -24,7 +24,6 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooReader;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3605275d/test/src/test/java/org/apache/accumulo/test/replication/ReplicationSequentialIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationSequentialIT.java
b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationSequentialIT.java
index ac2f25c..c7c36e8 100644
--- a/test/src/test/java/org/apache/accumulo/test/replication/ReplicationSequentialIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/replication/ReplicationSequentialIT.java
@@ -31,6 +31,7 @@ import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.replication.ReplicaSystemFactory;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -41,6 +42,7 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.ReplicationSectio
 import org.apache.accumulo.core.protobuf.ProtobufUtil;
 import org.apache.accumulo.core.replication.proto.Replication.Status;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.TablePermission;
 import org.apache.accumulo.master.replication.SequentialWorkAssigner;
 import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
@@ -110,8 +112,15 @@ public class ReplicationSequentialIT extends ConfigurableMacIT {
       final Connector connPeer = peerCluster.getConnector("root", ROOT_PASSWORD);
   
       ReplicationTable.create(connMaster);
+
+      String peerUserName = "peer", peerPassword = "foo";
   
       String peerClusterName = "peer";
+
+      connPeer.securityOperations().createLocalUser(peerUserName, new PasswordToken(peerPassword));
+      
+      connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_USER.getKey()
+ peerClusterName, peerUserName);
+      connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_PASSWORD.getKey()
+ peerClusterName, peerPassword);
   
       // ...peer = AccumuloReplicaSystem,instanceName,zookeepers
       connMaster.instanceOperations().setProperty(
@@ -128,6 +137,8 @@ public class ReplicationSequentialIT extends ConfigurableMacIT {
       connPeer.tableOperations().create(peerTable);
       String peerTableId = connPeer.tableOperations().tableIdMap().get(peerTable);
       Assert.assertNotNull(peerTableId);
+
+      connPeer.securityOperations().grantTablePermission(peerUserName, peerTable, TablePermission.WRITE);
   
       // Replicate this table to the peerClusterName in a table with the peerTableId table
id
       connMaster.tableOperations().setProperty(masterTable, Property.TABLE_REPLICATION.getKey(),
"true");
@@ -262,6 +273,13 @@ public class ReplicationSequentialIT extends ConfigurableMacIT {
       Connector connPeer = peer1Cluster.getConnector("root", ROOT_PASSWORD);
 
       String peerClusterName = "peer";
+      String peerUserName = "peer", peerPassword = "foo";
+
+      // Create local user
+      connPeer.securityOperations().createLocalUser(peerUserName, new PasswordToken(peerPassword));
+
+      connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_USER.getKey()
+ peerClusterName, peerUserName);
+      connMaster.instanceOperations().setProperty(Property.REPLICATION_PEER_PASSWORD.getKey()
+ peerClusterName, peerPassword);
 
       // ...peer = AccumuloReplicaSystem,instanceName,zookeepers
       connMaster.instanceOperations().setProperty(
@@ -271,6 +289,7 @@ public class ReplicationSequentialIT extends ConfigurableMacIT {
 
       String masterTable1 = "master1", peerTable1 = "peer1", masterTable2 = "master2", peerTable2
= "peer2";
 
+      // Create tables
       connMaster.tableOperations().create(masterTable1);
       String masterTableId1 = connMaster.tableOperations().tableIdMap().get(masterTable1);
       Assert.assertNotNull(masterTableId1);
@@ -287,6 +306,10 @@ public class ReplicationSequentialIT extends ConfigurableMacIT {
       String peerTableId2 = connPeer.tableOperations().tableIdMap().get(peerTable2);
       Assert.assertNotNull(peerTableId2);
 
+      // Grant write permission
+      connPeer.securityOperations().grantTablePermission(peerUserName, peerTable1, TablePermission.WRITE);
+      connPeer.securityOperations().grantTablePermission(peerUserName, peerTable2, TablePermission.WRITE);
+
       // Replicate this table to the peerClusterName in a table with the peerTableId table
id
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION.getKey(),
"true");
       connMaster.tableOperations().setProperty(masterTable1, Property.TABLE_REPLICATION_TARGETS.getKey()
+ peerClusterName, peerTableId1);


Mime
View raw message