accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/4] git commit: ACCUMULO-3131 Make sure CyclicReplicationIT sets up SSL when requested
Date Tue, 16 Sep 2014 20:15:53 GMT
ACCUMULO-3131 Make sure CyclicReplicationIT sets up SSL when requested


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

Branch: refs/heads/master
Commit: d1cd740aa435fc9a88e1665ceb308d1aee6f3d03
Parents: 2da2304
Author: Josh Elser <elserj@apache.org>
Authored: Tue Sep 16 14:43:11 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Tue Sep 16 16:15:34 2014 -0400

----------------------------------------------------------------------
 .../accumulo/test/functional/AbstractMacIT.java |  8 +--
 .../test/replication/CyclicReplicationIT.java   | 60 +++++++++++++++++++-
 2 files changed, 61 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1cd740a/test/src/test/java/org/apache/accumulo/test/functional/AbstractMacIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/AbstractMacIT.java b/test/src/test/java/org/apache/accumulo/test/functional/AbstractMacIT.java
index ce6164b..9872019 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/AbstractMacIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/AbstractMacIT.java
@@ -52,7 +52,7 @@ public abstract class AbstractMacIT {
       } catch (Exception e) {}
   }
 
-  protected static File createSharedTestDir(String name) {
+  public static File createSharedTestDir(String name) {
     File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests");
     baseDir.mkdirs();
     if (name != null)
@@ -63,7 +63,7 @@ public abstract class AbstractMacIT {
     return testDir;
   }
 
-  protected static File createTestDir(String name) {
+  public static File createTestDir(String name) {
     File baseDir = new File(System.getProperty("user.dir") + "/target/mini-tests");
     baseDir.mkdirs();
     if (name == null)
@@ -81,7 +81,7 @@ public abstract class AbstractMacIT {
     return names;
   }
 
-  protected static void configureForEnvironment(MiniAccumuloConfigImpl cfg, File folder)
{
+  public static void configureForEnvironment(MiniAccumuloConfigImpl cfg, File folder) {
     if ("true".equals(System.getProperty("org.apache.accumulo.test.functional.useSslForIT")))
{
       configureForSsl(cfg, folder);
     }
@@ -90,7 +90,7 @@ public abstract class AbstractMacIT {
     }
   }
 
-  protected static void configureForSsl(MiniAccumuloConfigImpl cfg, File folder) {
+  public static void configureForSsl(MiniAccumuloConfigImpl cfg, File folder) {
     Map<String,String> siteConfig = cfg.getSiteConfig();
     if ("true".equals(siteConfig.get(Property.INSTANCE_RPC_SSL_ENABLED.getKey()))) {
       // already enabled; don't mess with it

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d1cd740a/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 c84e53d..f5e6df3 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
@@ -20,6 +20,8 @@ import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -42,6 +44,7 @@ import org.apache.accumulo.minicluster.ServerType;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.minicluster.impl.ProcessReference;
+import org.apache.accumulo.test.functional.AbstractMacIT;
 import org.apache.accumulo.tserver.TabletServer;
 import org.apache.accumulo.tserver.replication.AccumuloReplicaSystem;
 import org.apache.commons.io.FileUtils;
@@ -51,18 +54,22 @@ import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
+import org.junit.rules.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Iterables;
 
 /**
- * 
+ *
  */
 public class CyclicReplicationIT {
   private static final Logger log = LoggerFactory.getLogger(CyclicReplicationIT.class);
 
   @Rule
+  public Timeout timeout = new Timeout(5 * 60 * 1000);
+
+  @Rule
   public TestName testName = new TestName();
 
   private File createTestDir(String name) {
@@ -86,7 +93,46 @@ public class CyclicReplicationIT {
     out.close();
   }
 
-  @Test(timeout = 5 * 60 * 1000)
+  /**
+   * Use the same SSL and credential provider configuration that is set up by AbstractMacIT
for the other MAC used for replication
+   */
+  private void updatePeerConfigFromPrimary(MiniAccumuloConfigImpl primaryCfg, MiniAccumuloConfigImpl
peerCfg) {
+    // Set the same SSL information from the primary when present
+    Map<String,String> primarySiteConfig = primaryCfg.getSiteConfig();
+    if ("true".equals(primarySiteConfig.get(Property.INSTANCE_RPC_SSL_ENABLED.getKey())))
{
+      Map<String,String> peerSiteConfig = new HashMap<String,String>();
+      peerSiteConfig.put(Property.INSTANCE_RPC_SSL_ENABLED.getKey(), "true");
+      String keystorePath = primarySiteConfig.get(Property.RPC_SSL_KEYSTORE_PATH.getKey());
+      Assert.assertNotNull("Keystore Path was null", keystorePath);
+      peerSiteConfig.put(Property.RPC_SSL_KEYSTORE_PATH.getKey(), keystorePath);
+      String truststorePath = primarySiteConfig.get(Property.RPC_SSL_TRUSTSTORE_PATH.getKey());
+      Assert.assertNotNull("Truststore Path was null", truststorePath);
+      peerSiteConfig.put(Property.RPC_SSL_TRUSTSTORE_PATH.getKey(), truststorePath);
+
+      // Passwords might be stored in CredentialProvider
+      String keystorePassword = primarySiteConfig.get(Property.RPC_SSL_KEYSTORE_PASSWORD.getKey());
+      if (null != keystorePassword) {
+        peerSiteConfig.put(Property.RPC_SSL_KEYSTORE_PASSWORD.getKey(), keystorePassword);
+      }
+      String truststorePassword = primarySiteConfig.get(Property.RPC_SSL_TRUSTSTORE_PASSWORD.getKey());
+      if (null != truststorePassword) {
+        peerSiteConfig.put(Property.RPC_SSL_TRUSTSTORE_PASSWORD.getKey(), truststorePassword);
+      }
+
+      System.out.println("Setting site configuration for peer " + peerSiteConfig);
+      peerCfg.setSiteConfig(peerSiteConfig);
+    }
+
+    // Use the CredentialProvider if the primary also uses one
+    String credProvider = primarySiteConfig.get(Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey());
+    if (null != credProvider) {
+      Map<String,String> peerSiteConfig = peerCfg.getSiteConfig();
+      peerSiteConfig.put(Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey(), credProvider);
+      peerCfg.setSiteConfig(peerSiteConfig);
+    }
+  }
+
+  @Test
   public void dataIsNotOverReplicated() throws Exception {
     File master1Dir = createTestDir("master1"), master2Dir = createTestDir("master2");
     String password = "password";
@@ -94,6 +140,10 @@ public class CyclicReplicationIT {
     MiniAccumuloConfigImpl master1Cfg = new MiniAccumuloConfigImpl(master1Dir, password);
     master1Cfg.setNumTservers(1);
     master1Cfg.setInstanceName("master1");
+
+    // Set up SSL if needed
+    AbstractMacIT.configureForEnvironment(master1Cfg, AbstractMacIT.createSharedTestDir(this.getClass().getName()
+ "-ssl"));
+
     master1Cfg.setProperty(Property.REPLICATION_NAME, master1Cfg.getInstanceName());
     master1Cfg.setProperty(Property.TSERV_WALOG_MAX_SIZE, "5M");
     master1Cfg.setProperty(Property.REPLICATION_THREADCHECK, "5m");
@@ -105,6 +155,10 @@ public class CyclicReplicationIT {
     MiniAccumuloConfigImpl master2Cfg = new MiniAccumuloConfigImpl(master2Dir, password);
     master2Cfg.setNumTservers(1);
     master2Cfg.setInstanceName("master2");
+
+    // Set up SSL if needed. Need to share the same SSL truststore as master1
+    this.updatePeerConfigFromPrimary(master1Cfg, master2Cfg);
+
     master2Cfg.setProperty(Property.REPLICATION_NAME, master2Cfg.getInstanceName());
     master2Cfg.setProperty(Property.TSERV_WALOG_MAX_SIZE, "5M");
     master2Cfg.setProperty(Property.REPLICATION_THREADCHECK, "5m");
@@ -129,7 +183,7 @@ public class CyclicReplicationIT {
       // 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);
 


Mime
View raw message