airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1529898 - /airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
Date Mon, 07 Oct 2013 14:48:04 GMT
Author: lahiru
Date: Mon Oct  7 14:48:04 2013
New Revision: 1529898

URL: http://svn.apache.org/r1529898
Log:
adding new test to submit jobs to br2

Modified:
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java

Modified: airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java?rev=1529898&r1=1529897&r2=1529898&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
(original)
+++ airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaSSHTest.java
Mon Oct  7 14:48:04 2013
@@ -24,12 +24,19 @@ package org.apache.airavata.gsi.ssh.impl
 import com.jcraft.jsch.UserInfo;
 import org.apache.airavata.gsi.ssh.api.*;
 import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+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.DefaultPasswordAuthenticationInfo;
 import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPublicKeyFileAuthentication;
+import org.testng.AssertJUnit;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
+import javax.swing.*;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * User: AmilaJ (amilaj@apache.org)
  * Date: 9/20/13
@@ -48,11 +55,14 @@ public class VanilaSSHTest {
 
 
         this.hostName = "bigred2.uits.iu.edu";
+        System.setProperty("my.ssh.user", "lginnali");
+        System.setProperty("my.ssh.user.password","");
+//        System.setProperty("my.ssh.user","i want to be free");
         this.userName = System.getProperty("my.ssh.user");
         this.password = System.getProperty("my.ssh.user.password");
-        this.passPhrase = System.getProperty("my.ssh.user.pass.phrase");
+//        this.passPhrase = System.getProperty("my.ssh.user.pass.phrase");
 
-        if (this.userName == null || this.passPhrase == null || this.password == null) {
+        if (this.userName == null || this.password == null) {
             System.out.println("########### In order to run tests you need to set password
and " +
                     "passphrase ###############");
             System.out.println("Use -Dmy.ssh.user=xxx -Dmy.ssh.user.password=yyy -Dmy.ssh.user.pass.phrase=zzz");
@@ -88,8 +98,8 @@ public class VanilaSSHTest {
 
         System.out.println("Starting vanila SSH test ....");
 
-        String privateKeyFile = "/Users/thejaka/.ssh/id_rsa";
-        String publicKeyFile = "/Users/thejaka/.ssh/id_rsa.pub";
+        String privateKeyFile = "/Users/lahirugunathilake/.ssh/id_dsa";
+        String publicKeyFile = "/Users/lahirugunathilake/.ssh/id_dsa.pub";
 
         AuthenticationInfo authenticationInfo = new DefaultPublicKeyFileAuthentication(publicKeyFile,
privateKeyFile,
                 this.passPhrase);
@@ -109,4 +119,64 @@ public class VanilaSSHTest {
 
     }
 
+    @Test
+    public void testSimplePBSJob() throws Exception{
+
+        AuthenticationInfo authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+         // Server info
+        ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
+        Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/torque-4.2.3.1/bin/");
+
+
+        // Execute command
+        String workingDirectory = File.separator + "N" + File.separator + "u" + File.separator
+
+                "lginnali" + File.separator + "BigRed2" + File.separator + "myjob";
+        // constructing the job object
+        JobDescriptor jobDescriptor = new JobDescriptor();
+        jobDescriptor.setWorkingDirectory(workingDirectory);
+        jobDescriptor.setShellName("/bin/bash");
+        jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
+        jobDescriptor.setExecutablePath("/bin/echo");
+        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.setQueueName("normal");
+        jobDescriptor.setMaxWallTime("5");
+        jobDescriptor.setJobSubmitter("aprun -n 1");
+        List<String> inputs = new ArrayList<String>();
+        inputs.add("Hello World");
+        jobDescriptor.setInputValues(inputs);
+        //finished construction of job object
+        System.out.println(jobDescriptor.toXML());
+        String jobID = pbsCluster.submitBatchJob(jobDescriptor);
+        System.out.println("JobID returned : " + jobID);
+
+//        Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
+        Thread.sleep(1000);
+        JobDescriptor jobById = pbsCluster.getJobDescriptorById(jobID);
+
+        //printing job data got from previous call
+        AssertJUnit.assertEquals(jobById.getJobId(), jobID);
+        System.out.println(jobById.getAcountString());
+        System.out.println(jobById.getAllEnvExport());
+        System.out.println(jobById.getCompTime());
+        System.out.println(jobById.getExecutablePath());
+        System.out.println(jobById.getEllapsedTime());
+        System.out.println(jobById.getQueueName());
+        System.out.println(jobById.getExecuteNode());
+        System.out.println(jobById.getJobName());
+        System.out.println(jobById.getCTime());
+        System.out.println(jobById.getSTime());
+        System.out.println(jobById.getMTime());
+        System.out.println(jobById.getCompTime());
+        System.out.println(jobById.getOwner());
+        System.out.println(jobById.getQTime());
+        System.out.println(jobById.getUsedCPUTime());
+        System.out.println(jobById.getUsedMemory());
+        System.out.println(jobById.getVariableList());
+    }
+
 }



Mime
View raw message