You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2014/09/11 16:39:46 UTC
svn commit: r1624306 - in /hive/trunk/testutils/ptest2/src:
main/java/org/apache/hive/ptest/execution/
main/java/org/apache/hive/ptest/execution/conf/
main/java/org/apache/hive/ptest/execution/ssh/
test/java/org/apache/hive/ptest/execution/ssh/
Author: brock
Date: Thu Sep 11 14:39:46 2014
New Revision: 1624306
URL: http://svn.apache.org/r1624306
Log:
HIVE-8036 - PTest SSH Options (Brock reviewed by Xuefu)
Modified:
hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java
hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java
Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java?rev=1624306&r1=1624305&r2=1624306&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java Thu Sep 11 14:39:46 2014
@@ -347,7 +347,7 @@ public class PTest {
executionContext = executionContextProvider.createExecutionContext();
LocalCommandFactory localCommandFactory = new LocalCommandFactory(LOG);
PTest ptest = new PTest(conf, executionContext, buildTag, logDir,
- localCommandFactory, new SSHCommandExecutor(LOG),
+ localCommandFactory, new SSHCommandExecutor(LOG, localCommandFactory, conf.getSshOpts()),
new RSyncCommandExecutor(LOG, 10, localCommandFactory), LOG);
exitCode = ptest.run();
} finally {
Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java?rev=1624306&r1=1624305&r2=1624306&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java Thu Sep 11 14:39:46 2014
@@ -55,6 +55,7 @@ public class TestConfiguration {
private static final String JIRA_USER = "jiraUser";
private static final String JIRA_PASSWORD = "jiraPassword";
private static final String JENKINS_URL = "jenkinsURL";
+ private static final String SSH_OPTS = "sshOpts";
private static final String LOGS_URL = "logsURL";
private static final String TEST_CASE_PROPERTY_NAME = "testCasePropertyName";
private static final String BUILD_TOOL = "buildTool";
@@ -75,6 +76,7 @@ public class TestConfiguration {
private String javaHome;
private String javaHomeForTests;
private String branch;
+ private String sshOpts;
private final String jenkinsURL;
private final String logsURL;
private final String jiraUrl;
@@ -122,10 +124,14 @@ public class TestConfiguration {
jenkinsURL = context.getString(JENKINS_URL, "https://builds.apache.org/job").trim();
logsURL = context.getString(LOGS_URL, "").trim();
testCasePropertyName = context.getString(TEST_CASE_PROPERTY_NAME, "testcase").trim();
+ sshOpts = context.getString(SSH_OPTS, "").trim();
}
public Context getContext() {
return context;
}
+ public String getSshOpts() {
+ return sshOpts;
+ }
public String getJenkinsURL() {
return jenkinsURL;
}
Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java?rev=1624306&r1=1624305&r2=1624306&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java Thu Sep 11 14:39:46 2014
@@ -30,15 +30,17 @@ public class SSHCommandExecutor {
private final Logger mLogger;
private final LocalCommandFactory mLocalCommandFactory;
+ private final String mSshOpts;
private volatile boolean mShutdown;
-
- public SSHCommandExecutor(Logger logger, LocalCommandFactory localCommandFactory) {
+
+ public SSHCommandExecutor(Logger logger, LocalCommandFactory localCommandFactory, String sshOpts) {
mLogger = logger;
- mShutdown = false;
mLocalCommandFactory = localCommandFactory;
+ mSshOpts = sshOpts;
+ mShutdown = false;
}
public SSHCommandExecutor(Logger logger) {
- this(logger, new LocalCommandFactory(logger));
+ this(logger, new LocalCommandFactory(logger), "");
}
/**
* Execute the given command via the ssh command line tool. If the command
@@ -47,8 +49,8 @@ public class SSHCommandExecutor {
public void execute(SSHCommand command) {
CollectPolicy collector = new CollectPolicy();
try {
- String commandText = String.format("ssh -v -i %s -l %s %s '%s'", command.getPrivateKey(),
- command.getUser(), command.getHost(), command.getCommand());
+ String commandText = String.format("ssh -v -i %s %s -l %s %s '%s'", command.getPrivateKey(),
+ mSshOpts, command.getUser(), command.getHost(), command.getCommand());
int attempts = 0;
boolean retry;
LocalCommand cmd;
@@ -83,4 +85,4 @@ public class SSHCommandExecutor {
public void shutdownNow() {
this.mShutdown = true;
}
-}
\ No newline at end of file
+}
Modified: hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java?rev=1624306&r1=1624305&r2=1624306&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java (original)
+++ hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java Thu Sep 11 14:39:46 2014
@@ -50,7 +50,8 @@ public class TestSSHCommandExecutor {
public void testShutdownBeforeWaitFor() throws Exception {
LocalCommand localCommand = mock(LocalCommand.class);
localCommandFactory.setInstance(localCommand);
- SSHCommandExecutor executor = new SSHCommandExecutor(LOG, localCommandFactory);
+ SSHCommandExecutor executor = new SSHCommandExecutor(LOG, localCommandFactory,
+ "-o StrictHostKeyChecking=no");
Assert.assertFalse(executor.isShutdown());
executor.shutdownNow();
SSHCommand command = new SSHCommand(executor, "privateKey", "user", "host", 1, "whoami");
@@ -66,7 +67,8 @@ public class TestSSHCommandExecutor {
public void testShutdownDuringWaitFor() throws Exception {
LocalCommand localCommand = mock(LocalCommand.class);
localCommandFactory.setInstance(localCommand);
- final SSHCommandExecutor executor = new SSHCommandExecutor(LOG, localCommandFactory);
+ final SSHCommandExecutor executor = new SSHCommandExecutor(LOG, localCommandFactory,
+ "-o StrictHostKeyChecking=no");
Assert.assertFalse(executor.isShutdown());
when(localCommand.getExitCode()).thenAnswer(new Answer<Integer>() {
@Override
@@ -84,4 +86,4 @@ public class TestSSHCommandExecutor {
}
verify(localCommand, never()).kill();
}
-}
\ No newline at end of file
+}