hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1469564 - in /hbase/branches/0.94/src: docbkx/developer.xml test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
Date Thu, 18 Apr 2013 20:52:40 GMT
Author: sershe
Date: Thu Apr 18 20:52:40 2013
New Revision: 1469564

URL: http://svn.apache.org/r1469564
Log:
HBASE-8350 enable ChaosMonkey to run commands as different users

Modified:
    hbase/branches/0.94/src/docbkx/developer.xml
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java

Modified: hbase/branches/0.94/src/docbkx/developer.xml
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/docbkx/developer.xml?rev=1469564&r1=1469563&r2=1469564&view=diff
==============================================================================
--- hbase/branches/0.94/src/docbkx/developer.xml (original)
+++ hbase/branches/0.94/src/docbkx/developer.xml Thu Apr 18 20:52:40 2013
@@ -655,6 +655,14 @@ cluster uniformly, <code>IntegrationTest
 and public client API's can be used.
 </para>
 
+<para>
+On a distributed cluster, integration tests that use ChaosMonkey or otherwise manipulate
services thru cluster manager (e.g. restart regionservers) use SSH to do it.
+To run these, test process should be able to run commands on remote end, so ssh should be
configured accordingly (for example, if HBase runs under hbase
+user in your cluster, you can set up passwordless ssh for that user and run the test also
under it). To facilitate that, <code>hbase.it.clustermanager.ssh.user</code> and
+<code>hbase.it.clustermanager.ssh.opts</code> configuration settings can be used.
The former is the remote user that cluster manager should use to perform ssh commands.
+The latter contains additional options that are passed to SSH (for example, "-i /tmp/my-key").
+</para>
+
 <section xml:id="maven.build.commands.integration.tests.mini">
 <title>Running integration tests against mini cluster</title>
 <para>HBase 0.92 added a <varname>verify</varname> maven target.

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java?rev=1469564&r1=1469563&r2=1469564&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java Thu
Apr 18 20:52:40 2013
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseClusterManager.CommandProvider.Operation;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.util.Shell;
@@ -37,16 +38,33 @@ import org.apache.hadoop.util.Shell;
  */
 @InterfaceAudience.Private
 public class HBaseClusterManager extends ClusterManager {
+  private String sshUserName;
+  private String sshOptions;
+
+  @Override
+  public void setConf(Configuration conf) {
+    super.setConf(conf);
+    if (conf == null) {
+      // Configured gets passed null before real conf. Why? I don't know.
+      return;
+    }
+    sshUserName = conf.get("hbase.it.clustermanager.ssh.user", "");
+    String extraSshOptions = conf.get("hbase.it.clustermanager.ssh.opts", "");
+    sshOptions = System.getenv("HBASE_SSH_OPTS");
+    if (!extraSshOptions.isEmpty()) {
+      sshOptions = StringUtils.join(new Object[] { sshOptions, extraSshOptions }, " ");
+    }
+    LOG.info("Running with SSH user [" + sshUserName + "] and options [" + sshOptions + "]");
+  }
 
   /**
    * Executes commands over SSH
    */
-  static class RemoteShell extends Shell.ShellCommandExecutor {
+  protected class RemoteShell extends Shell.ShellCommandExecutor {
 
     private String hostname;
 
     private String sshCmd = "/usr/bin/ssh";
-    private String sshOptions = System.getenv("HBASE_SSH_OPTS"); //from conf/hbase-env.sh
 
     public RemoteShell(String hostname, String[] execString, File dir, Map<String, String>
env,
         long timeout) {
@@ -70,11 +88,12 @@ public class HBaseClusterManager extends
     }
 
     public String[] getExecString() {
+      String userAndHost = sshUserName.isEmpty() ? hostname : (sshUserName + "@" + hostname);
       return new String[] {
           "bash", "-c",
           StringUtils.join(new String[] { sshCmd,
-              sshOptions == null ? "" : sshOptions,
-              hostname,
+              (sshOptions == null) ? "" : sshOptions,
+              userAndHost,
               "\"" + StringUtils.join(super.getExecString(), " ") + "\""
           }, " ")};
     }
@@ -83,22 +102,6 @@ public class HBaseClusterManager extends
     public void execute() throws IOException {
       super.execute();
     }
-
-    public void setSshCmd(String sshCmd) {
-      this.sshCmd = sshCmd;
-    }
-
-    public void setSshOptions(String sshOptions) {
-      this.sshOptions = sshOptions;
-    }
-
-    public String getSshCmd() {
-      return sshCmd;
-    }
-
-    public String getSshOptions() {
-      return sshOptions;
-    }
   }
 
   /**



Mime
View raw message