diff --git a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java index 03e44bf..3455137 100644 --- a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java +++ b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java @@ -347,7 +347,7 @@ public static void main(String[] args) throws Exception { 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 { diff --git a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java index b48b3ba..71c513d 100644 --- a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java +++ b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java @@ -55,6 +55,7 @@ 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 @@ 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 TestConfiguration(Context context, Logger logger) 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; } diff --git a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java index 54f230b..8c9f707 100644 --- a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java +++ b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/ssh/SSHCommandExecutor.java @@ -30,15 +30,17 @@ 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 SSHCommandExecutor(Logger logger) { 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 @@ boolean isShutdown() { public void shutdownNow() { this.mShutdown = true; } -} \ No newline at end of file +} diff --git a/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java b/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java index d533639..f81535f 100644 --- a/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java +++ b/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/ssh/TestSSHCommandExecutor.java @@ -50,7 +50,8 @@ public void setup() throws Exception { 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 void testShutdownBeforeWaitFor() throws Exception { 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() { @Override @@ -84,4 +86,4 @@ public Integer answer(InvocationOnMock invocation) throws Throwable { } verify(localCommand, never()).kill(); } -} \ No newline at end of file +}