You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/04/09 18:54:31 UTC
git commit: Fixing gsissh tool test cases
Repository: airavata
Updated Branches:
refs/heads/master fa32f4dad -> f01ea07ea
Fixing gsissh tool test cases
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/f01ea07e
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/f01ea07e
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/f01ea07e
Branch: refs/heads/master
Commit: f01ea07ea93f11a329e6253c8f120bf6500b0cdd
Parents: fa32f4d
Author: lahiru <la...@apache.org>
Authored: Wed Apr 9 12:54:26 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Wed Apr 9 12:54:26 2014 -0400
----------------------------------------------------------------------
.../ssh/config/SCPFromTestWithMyProxyAuth.java | 82 ----------
.../impl/DefaultSSHApiTestWithMyProxyAuth.java | 163 ++++---------------
.../gsi/ssh/impl/VanilaTestWithSSHAuth.java | 79 +++------
3 files changed, 55 insertions(+), 269 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/f01ea07e/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPFromTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPFromTestWithMyProxyAuth.java b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPFromTestWithMyProxyAuth.java
deleted file mode 100644
index c8a29f5..0000000
--- a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPFromTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-package org.apache.airavata.gsi.ssh.config;
-
-import java.io.File;
-
-import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.util.SSHUtils;
-import org.junit.Assert;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-public class SCPFromTestWithMyProxyAuth {
- private String myProxyUserName;
- private String myProxyPassword;
- private String certificateLocation;
- private String lFilePath;
- private String rFilePath;
-
- @BeforeTest
- public void setUp() throws Exception {
- System.out.println("Test case name " + this.getClass().getName());
-// System.setProperty("myproxy.user", "ogce");
-// System.setProperty("myproxy.password", "");
-// System.setProperty("gsi.certificate.path", "/Users/lahirugunathilake/Downloads/certificates");
- myProxyUserName = System.getProperty("myproxy.user");
- myProxyPassword = System.getProperty("myproxy.password");
- certificateLocation = System.getProperty("gsi.certificate.path");
-
- System.out.println(myProxyPassword + "," + myProxyUserName + "," + certificateLocation);
- if ((myProxyUserName == null) || (myProxyPassword == null) || (certificateLocation == null)) {
- System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
- "E.g :- mvn clean install -Dmyproxy.user=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<" +
- "gsi.certificate.path=/cert/path");
- throw new Exception("Need my proxy user name password to run tests.");
- }
- }
-
-
- @Test
- public void testExecuteCommand() throws Exception {
- // Create authentication
- File test = new File("test");
- if(!test.exists()){
- test.createNewFile();
- }
- lFilePath = test.getAbsolutePath();
- System.out.println(lFilePath);
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
- ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
- SSHUtils SSHUtils = new SSHUtils(serverInfo, authenticationInfo, this.certificateLocation, new ConfigReader());
- SSHUtils.scpTo("/tmp", lFilePath);
- Thread.sleep(1000);
- SSHUtils.scpFrom(File.separator + "tmp" + File.separator + "test", lFilePath);
- boolean delete = test.delete();
- Assert.assertTrue(delete);
- }
- /* add more test cases for each ssh operation */
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f01ea07e/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java
index 222141a..f2617c0 100644
--- a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java
@@ -28,6 +28,7 @@ import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
import org.apache.airavata.gsi.ssh.config.ConfigReader;
import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.gsi.ssh.util.SSHUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.AssertJUnit;
@@ -45,14 +46,15 @@ public class DefaultSSHApiTestWithMyProxyAuth {
private String certificateLocation;
private String pbsFilePath;
private String workingDirectory;
- private String slurmWorkingDirectory;
private String jobID;
+ private String lFilePath;
+ private String rFilePath;
@BeforeTest
public void setUp() throws Exception {
System.out.println("Test case name " + this.getClass().getName());
System.setProperty("myproxy.user", "ogce");
- System.setProperty("myproxy.password", "");
+ System.setProperty("myproxy.password", "0Gce3098");
System.setProperty("gsi.certificate.path", "/Users/lahirugunathilake/Downloads/certificates");
System.setProperty("gsi.working.directory", "/home/ogce");
@@ -60,7 +62,6 @@ public class DefaultSSHApiTestWithMyProxyAuth {
myProxyUserName = System.getProperty("myproxy.user");
myProxyPassword = System.getProperty("myproxy.password");
workingDirectory = System.getProperty("gsi.working.directory");
- slurmWorkingDirectory = "/home1/01437/ogce";
if (myProxyUserName == null || myProxyPassword == null || workingDirectory == null) {
System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
@@ -96,6 +97,9 @@ public class DefaultSSHApiTestWithMyProxyAuth {
@Test
public void testPBSAsync() throws Exception {
// Create authentication
+ System.out.println(myProxyUserName);
+ System.out.println(myProxyPassword);
+ System.out.println(certificateLocation);
GSIAuthenticationInfo authenticationInfo
= new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
7512, 17280000, certificateLocation);
@@ -132,7 +136,7 @@ public class DefaultSSHApiTestWithMyProxyAuth {
jobID = pbsCluster.submitBatchJob(jobDescriptor);
System.out.println("JobID returned : " + jobID);
-// Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
+ //Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
Thread.sleep(1000);
JobDescriptor jobById = pbsCluster.getJobDescriptorById(jobID);
@@ -157,136 +161,6 @@ public class DefaultSSHApiTestWithMyProxyAuth {
System.out.println(jobById.getVariableList());
}
- @Test
- public void testSLURMAsync() throws Exception {
- // Create authentication
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
-
- // Server info
- ServerInfo serverInfo = new ServerInfo("ogce", "stampede.tacc.xsede.org");
- serverInfo.setPort(2222);
-
- Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getSLURMJobManager("/usr/bin/"));
-
-
- // Execute command
- System.out.println("Target SLURM file path: " + slurmWorkingDirectory);
- // constructing the job object
- JobDescriptor jobDescriptor = new JobDescriptor();
- jobDescriptor.setWorkingDirectory(slurmWorkingDirectory);
- jobDescriptor.setShellName("/bin/sh");
- jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
- jobDescriptor.setExecutablePath("/bin/echo");
- jobDescriptor.setAllEnvExport(true);
- jobDescriptor.setMailOptions("n");
- jobDescriptor.setStandardOutFile("" + File.separator + "application.out");
- jobDescriptor.setStandardErrorFile("/home1/01437/ogce" + File.separator + "application.err");
- jobDescriptor.setNodes(1);
- jobDescriptor.setProcessesPerNode(1);
- jobDescriptor.setQueueName("normal");
- jobDescriptor.setMaxWallTime("60");
- jobDescriptor.setAcountString("TG-STA110014S");
- jobDescriptor.setJobSubmitter("sbatch");
- List<String> inputs = new ArrayList<String>();
- inputs.add("Hello World");
- jobDescriptor.setInputValues(inputs);
- //finished construction of job object
- System.out.println(jobDescriptor.toXML());
- jobID = pbsCluster.submitBatchJob(jobDescriptor);
- System.out.println("JobID returned : " + jobID);
- }
-
-
- @Test
- public void testsubmitAsyncJobWithFailure() throws Exception {
- // Create authentication
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
-
- // Server info
- ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
-
- Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
-
- // Execute command
- System.out.println("Target PBS file path: " + workingDirectory);
- System.out.println("Local PBS File path: " + pbsFilePath);
- String workingDirectory = File.separator + "home" + File.separator + "ogce" + File.separator + "gsissh";
- JobDescriptor jobDescriptor = new JobDescriptor();
- jobDescriptor.setWorkingDirectory(workingDirectory);
- jobDescriptor.setShellName("/bin/bash");
- jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
- jobDescriptor.setExecutablePath("/bin/sleep");
- jobDescriptor.setAllEnvExport(true);
- jobDescriptor.setMailOptions("n");
- jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
- jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
- jobDescriptor.setNodes(1);
- jobDescriptor.setProcessesPerNode(100);
- jobDescriptor.setQueueName("normal");
- jobDescriptor.setMaxWallTime("60");
- jobDescriptor.setAcountString("sds128");
- List<String> inputs = new ArrayList<String>();
- inputs.add("Hello World");
- jobDescriptor.setInputValues(inputs);
- System.out.println(jobDescriptor.toXML());
- try {
- String jobID = pbsCluster.submitBatchJob(jobDescriptor);
- System.out.println("JobID returned : " + jobID);
- } catch (SSHApiException e) {
- System.out.println(e.getMessage());
- }
- }
-
- @Test
- public void testSubmitAsyncJobWithListener() throws Exception {
- // Create authentication
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
-
- // Server info
- ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
-
-
- Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
-
-
- // Execute command
- System.out.println("Target PBS file path: " + workingDirectory);
- System.out.println("Local PBS File path: " + pbsFilePath);
- String workingDirectory = File.separator + "home" + File.separator + "ogce" + File.separator + "gsissh";
- JobDescriptor jobDescriptor = new JobDescriptor();
- jobDescriptor.setWorkingDirectory(workingDirectory);
- jobDescriptor.setShellName("/bin/bash");
- jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
- jobDescriptor.setExecutablePath("/bin/sleep");
- jobDescriptor.setAllEnvExport(true);
- jobDescriptor.setMailOptions("n");
- jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
- jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
- jobDescriptor.setNodes(1);
- jobDescriptor.setProcessesPerNode(1);
-// jobDescriptor.setMaxWallTime("1:00:00");
- jobDescriptor.setQueueName("normal");
- jobDescriptor.setAcountString("sds128");
- List<String> inputs = new ArrayList<String>();
- inputs.add("1000");
- jobDescriptor.setInputValues(inputs);
- System.out.println(jobDescriptor.toXML());
- DefaultJobSubmissionListener listener = new DefaultJobSubmissionListener();
- String jobID = pbsCluster.submitBatchJob(jobDescriptor);
- try {
- JobStatus jobStatus = pbsCluster.getJobStatus(jobID);
- org.junit.Assert.assertTrue(true);
- } catch (Exception e) {
- log.error("Error during job status monitoring");
- throw new SSHApiException("Error during job status monitoring", e);
- }
- }
@Test
public void testJobCancel() throws Exception {
@@ -334,4 +208,25 @@ public class DefaultSSHApiTestWithMyProxyAuth {
}
+ @Test
+ public void testSCPToAndSCPFrom() throws Exception {
+ // Create authentication
+ File test = new File("test");
+ if(!test.exists()){
+ test.createNewFile();
+ }
+ lFilePath = test.getAbsolutePath();
+ System.out.println(lFilePath);
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000, certificateLocation);
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+ SSHUtils SSHUtils = new SSHUtils(serverInfo, authenticationInfo, this.certificateLocation, new ConfigReader());
+ SSHUtils.scpTo("/tmp", lFilePath);
+ Thread.sleep(1000);
+ SSHUtils.scpFrom(File.separator + "tmp" + File.separator + "test", lFilePath);
+ boolean delete = test.delete();
+ org.junit.Assert.assertTrue(delete);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f01ea07e/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaTestWithSSHAuth.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaTestWithSSHAuth.java b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaTestWithSSHAuth.java
index 527ee32..f20647d 100644
--- a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaTestWithSSHAuth.java
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaTestWithSSHAuth.java
@@ -51,57 +51,27 @@ public class VanilaTestWithSSHAuth {
@BeforeTest
public void setUp() throws Exception {
System.out.println("Test case name " + this.getClass().getName());
- this.hostName = "trestles.sdsc.edu";
-
-// this.userName = System.setProperty("my.ssh.user", "lginnali");
-// this.password = System.setProperty("my.ssh.password", "");
-// this.workingDirectory = System.setProperty("working.directory", "/N/u/lginnali/BigRed2/myjob");
-// System.setProperty("basedir","/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
- this.userName = System.getProperty("my.ssh.user");
- this.password = System.getProperty("my.ssh.password");
- this.privateKeyPath = System.getProperty("my.private.key.path");
- this.publicKeyPath = System.getProperty("my.public.key.path");
- this.passPhrase = System.getProperty("my.ssh.user.pass.phrase");
+ this.hostName = "bigred2.uits.iu.edu"; //default ssh host
+ System.setProperty("ssh.user", "lginnali");
+ System.setProperty("ssh.private.key.path", "/Users/lahirugunathilake/.ssh/id_dsa");
+ System.setProperty("ssh.public.key.path", "/Users/lahirugunathilake/.ssh/id_dsa.pub");
+ System.setProperty("ssh.working.directory", "/tmp");
+
+ this.hostName = System.getProperty("ssh.host");
+ this.userName = System.getProperty("ssh.user");
+ this.password = System.getProperty("ssh.password");
+ this.privateKeyPath = System.getProperty("ssh.private.key.path");
+ this.publicKeyPath = System.getProperty("ssh.public.key.path");
+ this.passPhrase = System.getProperty("ssh.private.key.passphrase");
this.workingDirectory = System.getProperty("ssh.working.directory");
- System.out.println();
-
-
- if (this.userName == null || (this.userName != null && this.password == null)
+ if (this.userName == null
|| (this.password==null && (this.publicKeyPath == null || this.privateKeyPath == null)) || this.workingDirectory == null) {
System.out.println("########### In order to test you have to either username password or private,public keys");
- System.out.println("Use -Dmy.ssh.user=xxx -Dmy.ssh.user.password=yyy -Dmy.ssh.user.pass.phrase=zzz " +
- "-Dmy.private.key.path -Dmy.public.key.path -Dssh.working.directory ");
- }
- }
-
-
- @Test
- public void testSimpleCommand1() throws Exception {
-
- System.out.println("Starting vanila SSH test ....");
- AuthenticationInfo authenticationInfo = null;
- if (password != null) {
- authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
- } else {
- new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
- this.passPhrase);
+ System.out.println("Use -Dssh.user=xxx -Dssh.password=yyy -Dssh.private.key.passphrase=zzz " +
+ "-Dssh.private.key.path -Dssh.public.key.path -Dssh.working.directory ");
}
-
- // Create command
- CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qstat");
-
- // Server info
- ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
-
- // Output
- CommandOutput commandOutput = new SystemCommandOutput();
-
- // Execute command
- CommandExecutor.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput, new ConfigReader());
-
-
}
@@ -112,12 +82,12 @@ public class VanilaTestWithSSHAuth {
if (password != null) {
authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
} else {
- new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
+ authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
this.passPhrase);
}
// Server info
ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
- Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
+ Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/torque-4.2.3.1/bin/"));
String date = new Date().toString();
date = date.replaceAll(" ", "_");
@@ -189,25 +159,28 @@ public class VanilaTestWithSSHAuth {
}
@Test
- public void testSCPFrom() throws Exception {
+ public void testSCPFromAndSCPTo() throws Exception {
AuthenticationInfo authenticationInfo = null;
if (password != null) {
authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
} else {
- new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
+ authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
this.passPhrase);
}
// Server info
ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
- Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
+ Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/torque-4.2.3.1/bin/"));
String date = new Date().toString();
date = date.replaceAll(" ", "_");
date = date.replaceAll(":", "_");
- String pomFile = System.getProperty("basedir") + File.separator + "pom.xml";
-
+ String pomFile = (new File(".")).getAbsolutePath() + File.separator + "pom.xml";
+ File file = new File(pomFile);
+ if(!file.exists()){
+ file.createNewFile();
+ }
// Constructing theworking directory for demonstration and creating directories in the remote
// resource
workingDirectory = workingDirectory + File.separator
@@ -215,7 +188,7 @@ public class VanilaTestWithSSHAuth {
pbsCluster.makeDirectory(workingDirectory);
pbsCluster.scpTo(workingDirectory, pomFile);
Thread.sleep(1000);
- pbsCluster.scpFrom(workingDirectory + File.separator + "pom.xml", System.getProperty("basedir"));
+ pbsCluster.scpFrom(workingDirectory + File.separator + "pom.xml", (new File(".")).getAbsolutePath());
}