HBASE-8350 enable ChaosMonkey to run commands as different users
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1469551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
21f3899165
commit
b7391e5449
|
@ -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) {
|
||||
|
@ -71,11 +89,12 @@ public class HBaseClusterManager extends ClusterManager {
|
|||
|
||||
@Override
|
||||
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(), " ") + "\""
|
||||
}, " ")};
|
||||
}
|
||||
|
@ -84,22 +103,6 @@ public class HBaseClusterManager extends ClusterManager {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -665,6 +665,14 @@ cluster uniformly, <code>IntegrationTestingUtility</code>, and <code>HBaseCluste
|
|||
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.
|
||||
|
|
Loading…
Reference in New Issue