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/04 15:27:26 UTC
[1/2] new files
Repository: airavata
Updated Branches:
refs/heads/master 9ab16b97e -> f2a7fc3e7
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java
new file mode 100644
index 0000000..4e739df
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTestWithMyProxyAuth.java
@@ -0,0 +1,306 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.handler.GFacHandlerConfig;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.DataType;
+import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.ParameterType;
+import org.apache.airavata.schemas.gfac.ProjectAccountType;
+import org.apache.airavata.schemas.gfac.QueueType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ParamChemTestWithMyProxyAuth extends GFacBaseTestWithMyProxyAuth {
+ private JobExecutionContext jobExecutionContext;
+
+ @Before
+ public void setUp() throws Exception {
+
+ GFacConfiguration gFacConfiguration = new GFacConfiguration(null);
+ GSISecurityContext context = getSecurityContext();
+
+ //have to set InFlwo Handlers and outFlowHandlers
+ gFacConfiguration.setInHandlers(Arrays.asList(new GFacHandlerConfig[]{new GFacHandlerConfig(null,"org.apache.airavata.gfac.handler.GramDirectorySetupHandler"), new GFacHandlerConfig(null,"org.apache.airavata.gfac.handler.GridFTPInputHandler")}));
+ gFacConfiguration.setOutHandlers(Arrays.asList(new GFacHandlerConfig[] {new GFacHandlerConfig(null,"org.apache.airavata.gfac.handler.GridFTPOutputHandler")}));
+ /*
+ * Host
+ */
+ String serviceName = "Prepare_Model_Reference_Data";
+ HostDescription host = new HostDescription(GlobusHostType.type);
+ host.getType().setHostName("trestles");
+ host.getType().setHostAddress("trestles.sdsc.edu");
+ ((GlobusHostType) host.getType()).addGridFTPEndPoint("gsiftp://trestles-dm.sdsc.edu:2811");
+ ((GlobusHostType) host.getType()).addGlobusGateKeeperEndPoint("trestles-login2.sdsc.edu:2119/jobmanager-pbstest2");
+
+ /*
+ * App
+ */
+ ApplicationDescription appDesc =
+ new ApplicationDescription(HpcApplicationDeploymentType.type);
+ ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType
+ = appDesc.getType();
+ applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(serviceName);
+ String tempDir = "/oasis/projects/nsf/uic151/gridchem/airavata-workdirs";
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ tempDir = tempDir + File.separator
+ + serviceName + "_" + date + "_" + UUID.randomUUID();
+ applicationDeploymentDescriptionType.setExecutableLocation("/home/gridchem/workflow_script/sys_exec/scripts/step1/step1_model_refdata_prep.sh");
+ applicationDeploymentDescriptionType.setScratchWorkingDirectory(tempDir);
+ applicationDeploymentDescriptionType.setStaticWorkingDirectory(tempDir);
+ applicationDeploymentDescriptionType.setInputDataDirectory(tempDir + File.separator + "inputData");
+ applicationDeploymentDescriptionType.setOutputDataDirectory(tempDir + File.separator + "outputData");
+ applicationDeploymentDescriptionType.setStandardOutput(tempDir + File.separator + applicationDeploymentDescriptionType.getApplicationName().getStringValue() + ".stdout");
+ applicationDeploymentDescriptionType.setStandardError(tempDir + File.separator + applicationDeploymentDescriptionType.getApplicationName().getStringValue() + ".stderr");
+
+ ProjectAccountType projectAccountType = ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber("uic151");
+
+ QueueType queueType = ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).addNewQueue();
+ queueType.setQueueName("shared");
+
+ ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setJobType(JobTypeType.SERIAL);
+ ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setMaxWallTime(30);
+ ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setMaxMemory(2000);
+ ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setCpuCount(1);
+ ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setNodeCount(1);
+ ((HpcApplicationDeploymentType) applicationDeploymentDescriptionType).setProcessorsPerNode(1);
+
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
+ List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
+
+ serv.getType().setName(serviceName);
+ serv.getType().setDescription(serviceName);
+
+ //Creating input parameters
+ InputParameterType parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("molecule_id");
+ ParameterType parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.STRING);
+ parameterType.setName("String");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("geom_mol2");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.URI);
+ parameterType.setName("URI");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("toppar_main_tgz");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.URI);
+ parameterType.setName("URI");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("toppar_usr_tgz");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.URI);
+ parameterType.setName("URI");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("toppar_mol_str");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.URI);
+ parameterType.setName("URI");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("molecule_dir_in_tgz");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.URI);
+ parameterType.setName("URI");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("GC_UserName");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.STRING);
+ parameterType.setName("String");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("GC_ProjectName");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.STRING);
+ parameterType.setName("String");
+ inputParameters.add(parameter);
+
+ parameter = InputParameterType.Factory.newInstance();
+ parameter.setParameterName("GC_WorkflowName");
+ parameterType = parameter.addNewParameterType();
+ parameterType.setType(DataType.STRING);
+ parameterType.setName("String");
+ inputParameters.add(parameter);
+
+ //Creating output parameters
+ OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
+ outputParameter.setParameterName("opt_freq_input_gjf");
+ ParameterType outputParaType = outputParameter.addNewParameterType();
+ outputParaType.setType(DataType.URI);
+ outputParaType.setName("URI");
+ outputParameters.add(outputParameter);
+
+ outputParameter = OutputParameterType.Factory.newInstance();
+ outputParameter.setParameterName("charmm_miminized_crd");
+ outputParaType = outputParameter.addNewParameterType();
+ outputParaType.setType(DataType.URI);
+ outputParaType.setName("URI");
+ outputParameters.add(outputParameter);
+
+ outputParameter = OutputParameterType.Factory.newInstance();
+ outputParameter.setParameterName("step1_log");
+ outputParaType = outputParameter.addNewParameterType();
+ outputParaType.setType(DataType.URI);
+ outputParaType.setName("URI");
+ outputParameters.add(outputParameter);
+
+ outputParameter = OutputParameterType.Factory.newInstance();
+ outputParameter.setParameterName("molecule_dir_out_tgz");
+ outputParaType = outputParameter.addNewParameterType();
+ outputParaType.setType(DataType.URI);
+ outputParaType.setName("URI");
+ outputParameters.add(outputParameter);
+
+ outputParameter = OutputParameterType.Factory.newInstance();
+ outputParameter.setParameterName("gcvars");
+ outputParaType = outputParameter.addNewParameterType();
+ outputParaType.setType(DataType.URI);
+ outputParaType.setName("URI");
+ outputParameters.add(outputParameter);
+
+ //Setting input and output parameters to serviceDescriptor
+ serv.getType().setInputParametersArray(inputParameters.toArray(new InputParameterType[]{}));
+ serv.getType().setOutputParametersArray(outputParameters.toArray(new OutputParameterType[]{}));
+
+ jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
+ jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, context);
+ ApplicationContext applicationContext = new ApplicationContext();
+ applicationContext.setHostDescription(host);
+ applicationContext.setApplicationDeploymentDescription(appDesc);
+ jobExecutionContext.setApplicationContext(applicationContext);
+ applicationContext.setServiceDescription(serv);
+
+ MessageContext inMessage = new MessageContext();
+
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType) echo_input.getType()).setValue("ai");
+ inMessage.addParameter("molecule_id", echo_input);
+
+ ActualParameter geom_mol2 = new ActualParameter(URIParameterType.type);
+ ((URIParameterType) geom_mol2.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/ai.mol2");
+ inMessage.addParameter("geom_mol2", geom_mol2);
+
+ ActualParameter toppar_main_tgz = new ActualParameter(URIParameterType.type);
+ ((URIParameterType) toppar_main_tgz.getType()).setValue("/home/gridchem/workflow_script/toppar/cgenff/releases/2b7/main.tgz");
+ inMessage.addParameter("toppar_main_tgz", toppar_main_tgz);
+
+ ActualParameter toppar_usr_tgz = new ActualParameter(URIParameterType.type);
+ ((URIParameterType) toppar_usr_tgz.getType()).setValue("gsiftp://trestles.sdsc.edu");
+ inMessage.addParameter("toppar_usr_tgz", toppar_usr_tgz);
+
+ ActualParameter toppar_mol_str = new ActualParameter(URIParameterType.type);
+ ((URIParameterType) toppar_mol_str.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/toppar/ai.str");
+ inMessage.addParameter("toppar_mol_str", toppar_mol_str);
+
+ ActualParameter molecule_dir_in_tgz = new ActualParameter(URIParameterType.type);
+ ((URIParameterType) molecule_dir_in_tgz.getType()).setValue("");
+ inMessage.addParameter("molecule_dir_in_tgz", molecule_dir_in_tgz);
+
+ ActualParameter GC_UserName = new ActualParameter();
+ ((StringParameterType) GC_UserName.getType()).setValue("leoshen");
+ inMessage.addParameter("GC_UserName", GC_UserName);
+
+ ActualParameter GC_ProjectName = new ActualParameter();
+ ((StringParameterType) GC_ProjectName.getType()).setValue("leoshen");
+ inMessage.addParameter("GC_ProjectName", GC_ProjectName);
+
+ ActualParameter GC_WorkflowName = new ActualParameter();
+ ((StringParameterType) GC_WorkflowName.getType()).setValue("ai__1339258840");
+ inMessage.addParameter("GC_WorkflowName", GC_WorkflowName);
+
+ jobExecutionContext.setInMessageContext(inMessage);
+
+ MessageContext outMessage = new MessageContext();
+
+ ActualParameter opt_freq_input_gjf = new ActualParameter(URIParameterType.type);
+ outMessage.addParameter("opt_freq_input_gjf", opt_freq_input_gjf);
+
+ ActualParameter charmm_miminized_crd = new ActualParameter(URIParameterType.type);
+ outMessage.addParameter("charmm_miminized_crd", charmm_miminized_crd);
+
+ ActualParameter step1_log = new ActualParameter(URIParameterType.type);
+ outMessage.addParameter("step1_log", step1_log);
+
+ ActualParameter molecule_dir_out_tgz = new ActualParameter(URIParameterType.type);
+ outMessage.addParameter("molecule_dir_out_tgz", molecule_dir_out_tgz);
+
+ ActualParameter gcvars = new ActualParameter(URIParameterType.type);
+ outMessage.addParameter("gcvars", gcvars);
+
+ jobExecutionContext.setOutMessageContext(outMessage);
+
+ }
+
+ @Test
+ public void testGramProvider() throws GFacException {
+// GFacImpl gFacAPI = new GFacImpl();
+// gFacAPI.submitJob(jobExecutionContext);
+// MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
+// Assert.assertFalse(outMessageContext.getParameters().isEmpty());
+// Assert.assertEquals(MappingFactory.toString((ActualParameter) outMessageContext.getParameter("echo_output")), "hello");
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java
new file mode 100644
index 0000000..cd5611c
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.SSHHostType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.apache.commons.lang.SystemUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SSHProviderTestWithSSHAuth {
+ private JobExecutionContext jobExecutionContext;
+ @Before
+ public void setUp() throws Exception {
+
+ URL resource = GramProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),null,null);
+// gFacConfiguration.s
+ //have to set InFlwo Handlers and outFlowHandlers
+ ApplicationContext applicationContext = new ApplicationContext();
+ HostDescription host = new HostDescription(SSHHostType.type);
+ host.getType().setHostName("bigred");
+ host.getType().setHostAddress("bigred2.uits.iu.edu");
+ applicationContext.setHostDescription(host);
+ /*
+ * App
+ */
+ ApplicationDescription appDesc = new ApplicationDescription();
+ ApplicationDeploymentDescriptionType app = appDesc.getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+ name.setStringValue("EchoSSH");
+ app.setApplicationName(name);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ if (SystemUtils.IS_OS_WINDOWS) {
+ URL url = this.getClass().getClassLoader().getResource("echo.bat");
+ app.setExecutableLocation(url.getFile());
+ } else {
+ //for unix and Mac
+ app.setExecutableLocation("/bin/echo");
+ }
+
+ /*
+ * Job location
+ */
+ String tempDir = "/tmp";
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ tempDir = tempDir + File.separator
+ + "EchoSSH" + "_" + date + "_" + UUID.randomUUID();
+
+ app.setScratchWorkingDirectory(tempDir);
+ app.setStaticWorkingDirectory(tempDir);
+ app.setInputDataDirectory(tempDir + File.separator + "input");
+ app.setOutputDataDirectory(tempDir + File.separator + "output");
+ app.setStandardOutput(tempDir + File.separator + "echo.stdout");
+ app.setStandardError(tempDir + File.separator + "echo.stderr");
+
+ applicationContext.setApplicationDeploymentDescription(appDesc);
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("EchoSSH");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("echo_input");
+ input.setParameterType(StringParameterType.Factory.newInstance());
+ inputList.add(input);
+ InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+ .size()]);
+
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+
+ jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
+ jobExecutionContext.setApplicationContext(applicationContext);
+
+ // Add security context
+ jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext());
+ /*
+ * Host
+ */
+ applicationContext.setServiceDescription(serv);
+
+ MessageContext inMessage = new MessageContext();
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ inMessage.addParameter("echo_input", echo_input);
+
+ jobExecutionContext.setInMessageContext(inMessage);
+
+ MessageContext outMessage = new MessageContext();
+ ActualParameter echo_out = new ActualParameter();
+// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ outMessage.addParameter("echo_output", echo_out);
+
+ jobExecutionContext.setOutMessageContext(outMessage);
+
+ }
+
+ private SSHSecurityContext getSecurityContext() {
+ SSHSecurityContext context = new SSHSecurityContext();
+ context.setUsername("lginnali");
+ context.setPrivateKeyLoc("~/.ssh/id_dsa");
+ context.setKeyPass("i want to be free");
+ return context;
+ }
+
+ @Test
+ public void testLocalProvider() throws GFacException {
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
+ Assert.assertEquals(MappingFactory.toString((ActualParameter)outMessageContext.getParameter("echo_output")), "hello");
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java
new file mode 100644
index 0000000..434a09d
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/US3TestWithMyProxyAuth.java
@@ -0,0 +1,152 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import java.io.File;
+import java.util.Date;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.ExtendedKeyValueType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.junit.Before;
+import org.junit.Test;
+
+public class US3TestWithMyProxyAuth extends AbstractBESTestWithMyProxyAuth {
+
+
+ @Before
+ public void initJobContext() throws Exception {
+ initTest();
+ }
+
+ @Test
+ public void submitJob() throws Exception {
+ JobTypeType jobType = JobTypeType.Factory.newInstance();
+ jobType.set(JobTypeType.MPI);
+ ApplicationContext appContext = getApplicationContext();
+ appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType));
+ jobExecutionContext.setApplicationContext(appContext);
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ }
+
+
+ protected ApplicationDescription getApplicationDesc(JobTypeType jobType) {
+ ApplicationDescription appDesc = new ApplicationDescription(
+ HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) appDesc
+ .getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
+ .newInstance();
+ name.setStringValue("US3-Job");
+ appDepType.setApplicationName(name);
+
+// ProjectAccountType projectAccountType = appDepType.addNewProjectAccount();
+// projectAccountType.setProjectAccountNumber("TG-AST110064");
+
+// QueueType queueType = appDepType.addNewQueue();
+// queueType.setQueueName("development");
+
+ // TODO: also handle parallel jobs
+ if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
+ appDepType.setJobType(JobTypeType.SERIAL);
+ }
+ else if (jobType.enumValue() == JobTypeType.MPI) {
+ appDepType.setJobType(JobTypeType.MPI);
+ }
+ else {
+ appDepType.setJobType(JobTypeType.OPEN_MP);
+ }
+
+ appDepType.setNodeCount(4);
+ appDepType.setProcessorsPerNode(8);
+
+ appDepType.setMaxWallTime(15);
+
+ appDepType.setExecutableLocation("us_mpi_analysis");
+
+ ExtendedKeyValueType extKV = appDepType.addNewKeyValuePairs();
+ // using jsdl spmd standard
+ extKV.setName("NumberOfProcesses");
+ // this will be transformed into mpiexec -n 4
+ extKV.setStringValue("32");
+
+ /*
+ * Default tmp location
+ */
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ String remoteTempDir = scratchDir + File.separator + "US3" + "_" + date + "_"
+ + UUID.randomUUID();
+
+ System.out.println(remoteTempDir);
+
+ // no need of these parameters, as unicore manages by itself
+ appDepType.setScratchWorkingDirectory(remoteTempDir);
+ appDepType.setStaticWorkingDirectory(remoteTempDir);
+ appDepType.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
+ appDepType.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
+
+ appDepType.setStandardOutput(appDepType.getOutputDataDirectory()+"/stdout");
+
+ appDepType.setStandardError(appDepType.getOutputDataDirectory()+"/stderr");
+
+ return appDesc;
+ }
+ protected MessageContext getInMessageContext() {
+ MessageContext inMessage = new MessageContext();
+
+ ActualParameter a1 = new ActualParameter();
+ a1.getType().changeType(StringParameterType.type);
+ ((StringParameterType)a1.getType()).setValue("hpcinput-uslims3.uthscsa.edu-uslims3_cauma3-01594.tar");
+ inMessage.addParameter("arg1", a1);
+
+ ActualParameter i1 = new ActualParameter();
+ i1.getType().changeType(URIParameterType.type);
+ ((URIParameterType)i1.getType()).setValue("file:///"+System.getProperty("user.home")+"/juelich-us3/hpcinput-uslims3.uthscsa.edu-uslims3_cauma3-01594.tar");
+ inMessage.addParameter("i1", i1);
+
+ return inMessage;
+ }
+
+ protected MessageContext getOutMessageContext() {
+ MessageContext outMessage = new MessageContext();
+
+ ActualParameter a1 = new ActualParameter();
+ a1.getType().changeType(StringParameterType.type);
+ ((StringParameterType)a1.getType()).setValue("output/analysis-results.tar");
+ outMessage.addParameter("o1", a1);
+
+ return outMessage;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java
new file mode 100644
index 0000000..f3f866c
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/context/security/GSISecurityContextTestWithMyProxyAuth.java
@@ -0,0 +1,174 @@
+/*
+ *
+ * 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.gfac.context.security;
+
+import junit.framework.Assert;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.common.utils.DatabaseTestCases;
+import org.apache.airavata.common.utils.DerbyUtil;
+import org.apache.airavata.credential.store.store.CredentialReader;
+import org.apache.airavata.credential.store.store.CredentialReaderFactory;
+import org.apache.airavata.gfac.RequestData;
+import org.apache.log4j.Logger;
+import org.ietf.jgss.GSSCredential;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.io.File;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 7/12/13
+ * Time: 12:58 PM
+ */
+
+public class GSISecurityContextTestWithMyProxyAuth extends DatabaseTestCases {
+
+ private static String userName;
+ private static String password;
+
+ private static final Logger log = Logger.getLogger(GSISecurityContextTestWithMyProxyAuth.class);
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ AiravataUtils.setExecutionAsServer();
+
+ userName = System.getProperty("myproxy.user");
+ password = System.getProperty("myproxy.password");
+
+ if (userName == null || password == null || userName.trim().equals("") || password.trim().equals("")) {
+ log.error("===== Please set myproxy.user and myproxy.password system properties. =======");
+ Assert.fail("Please set myproxy.user and myproxy.password system properties.");
+ }
+
+ log.info("Using my proxy user name - " + userName);
+
+ setUpDatabase();
+
+ }
+
+ public static void setUpDatabase() throws Exception {
+ DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
+
+ waitTillServerStarts();
+
+ /*
+ * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_NAME VARCHAR(256) NOT NULL,\n" +
+ * " COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n" + " CREDENTIAL BLOB NOT NULL,\n" +
+ * " PRIVATE_KEY BLOB NOT NULL,\n" + " NOT_BEFORE VARCHAR(256) NOT NULL,\n" +
+ * " NOT_AFTER VARCHAR(256) NOT NULL,\n" + " LIFETIME INTEGER NOT NULL,\n" +
+ * " REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,\n" +
+ * " REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',\n" +
+ * " PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)\n" + ")";
+ */
+
+ String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
+ + " GATEWAY_ID VARCHAR(256) NOT NULL,\n"
+ + " TOKEN_ID VARCHAR(256) NOT NULL,\n"
+ + // Actual token used to identify the credential
+ " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
+ + " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
+ + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
+
+ String dropTable = "drop table CREDENTIALS";
+
+ try {
+ executeSQL(dropTable);
+ } catch (Exception e) {
+ }
+
+ executeSQL(createTable);
+
+ }
+
+ @AfterClass
+ public static void shutDownDatabase() throws Exception {
+ DerbyUtil.stopDerbyServer();
+ }
+
+ @Test
+ public void testGetTrustedCertificatePath() throws Exception {
+
+ File f = new File(GSISecurityContext.getTrustedCertificatePath());
+ Assert.assertTrue(f.exists());
+ }
+
+ private GSSCredential getGSSCredentials() throws Exception {
+
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+
+ return gsiSecurityContext.getGssCredentials();
+ }
+
+ private GSISecurityContext getGSISecurityContext() throws Exception {
+
+ RequestData requestData = new RequestData();
+
+ requestData.setMyProxyUserName(userName);
+ requestData.setMyProxyPassword(password);
+
+ CredentialReader credentialReader = CredentialReaderFactory.createCredentialStoreReader(getDbUtil());
+
+ return new GSISecurityContext(credentialReader, requestData);
+ }
+
+ @Test
+ public void testGetGssCredentials() throws Exception {
+
+ Assert.assertNotNull(getGSSCredentials());
+ }
+
+ @Test
+ public void testRenewCredentials() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.renewCredentials());
+
+ }
+
+ @Test
+ public void testGetCredentialsFromStore() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.getCredentialsFromStore());
+
+ }
+
+ @Test
+ public void testGetDefaultCredentials() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.getDefaultCredentials());
+
+ }
+
+ @Test
+ public void testGetProxyCredentials() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.getProxyCredentials());
+
+ }
+
+ @Test
+ public void testRenewCredentialsAsATrustedHost() throws Exception {
+ GSISecurityContext gsiSecurityContext = getGSISecurityContext();
+ Assert.assertNotNull(gsiSecurityContext.renewCredentialsAsATrustedHost());
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/provider/impl/GramProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/provider/impl/GramProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/provider/impl/GramProviderTestWithMyProxyAuth.java
new file mode 100644
index 0000000..0d73e57
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/gfac/provider/impl/GramProviderTestWithMyProxyAuth.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.gfac.provider.impl;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 7/12/13
+ * Time: 11:17 AM
+ */
+
+public class GramProviderTestWithMyProxyAuth {
+ @BeforeMethod
+ public void setUp() throws Exception {
+
+ }
+
+ @AfterMethod
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testExecute() throws Exception {
+
+ GramProvider gramProvider = new GramProvider();
+
+ System.out.println(gramProvider.getGramErrorString(1));
+
+ System.out.println("======================================================================================");
+ System.out.println("Executing test .......................................................................");
+
+ }
+
+ @Test
+ public void testCancelJob() throws Exception {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/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
new file mode 100644
index 0000000..8d0674a
--- /dev/null
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPFromTestWithMyProxyAuth.java
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.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.setProperty("myproxy.user", "ogce");
+// System.setProperty("myproxy.password", "");
+// System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
+ myProxyUserName = System.getProperty("myproxy.user");
+ myProxyPassword = System.getProperty("myproxy.password");
+ String pomDirectory = System.getProperty("basedir");
+
+ File pomFileDirectory = new File(pomDirectory);
+
+ System.out.println("POM directory ----------------- " + pomFileDirectory.getAbsolutePath());
+
+ certificateLocation = pomFileDirectory.getAbsolutePath() + "/certificates";
+
+
+ lFilePath = pomDirectory + File.separator + "pom.xml";
+ rFilePath = "/tmp/";
+ }
+
+
+ @Test
+ public void testExecuteCommand() throws Exception {
+ // Create authentication
+ 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(rFilePath, lFilePath);
+ Thread.sleep(1000);
+ SSHUtils.scpFrom(File.separator + "tmp" + File.separator + "pom.xml", System.getProperty("basedir"));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTestWithSSHAuth.java
----------------------------------------------------------------------
diff --git a/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTestWithSSHAuth.java b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTestWithSSHAuth.java
new file mode 100644
index 0000000..198fcd9
--- /dev/null
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/config/SCPToTestWithSSHAuth.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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 org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.util.SSHUtils;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.io.File;
+
+public class SCPToTestWithSSHAuth {
+ private String myProxyUserName;
+ private String myProxyPassword;
+ private String certificateLocation;
+ private String lFilePath;
+ private String rFilePath;
+
+ @BeforeTest
+ public void setUp() throws Exception {
+// System.setProperty("myproxy.user", "ogce");
+// System.setProperty("myproxy.password", "");
+// System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
+ myProxyUserName = System.getProperty("myproxy.user");
+ myProxyPassword = System.getProperty("myproxy.password");
+
+ String pomDirectory = System.getProperty("basedir");
+
+ File pomFileDirectory = new File(pomDirectory);
+
+ System.out.println("POM directory ----------------- " + pomFileDirectory.getAbsolutePath());
+
+ certificateLocation = pomFileDirectory.getAbsolutePath() + "/certificates";
+
+ if (myProxyUserName == null || myProxyPassword == 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 <<<<<<<");
+ throw new Exception("Need my proxy user name password to run tests.");
+ }
+ lFilePath = pomDirectory + File.separator + "pom.xml";
+ rFilePath = "/tmp";
+ }
+
+
+ @Test
+ public void testExecuteCommand() throws Exception {
+ // Create authentication
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000,certificateLocation);
+ ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");
+ SSHUtils scpTo = new SSHUtils(serverInfo,authenticationInfo,this.certificateLocation,new ConfigReader());
+ scpTo.scpTo(rFilePath, lFilePath);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/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
new file mode 100644
index 0000000..030f868
--- /dev/null
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java
@@ -0,0 +1,433 @@
+/*
+ *
+ * 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.impl;
+
+import junit.framework.Assert;
+import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultSSHApiTestWithMyProxyAuth {
+ private static final Logger log = LoggerFactory.getLogger(PBSCluster.class);
+ private String myProxyUserName;
+ private String myProxyPassword;
+ private String certificateLocation;
+ private String pbsFilePath;
+ private String workingDirectory;
+ private String slurmWorkingDirectory;
+ private String jobID;
+
+ @BeforeTest
+ public void setUp() throws Exception {
+ System.setProperty("myproxy.user", "ogce");
+ System.setProperty("myproxy.password", "");
+ System.setProperty("basedir", "/Users/lahirugunathilake/Downloads");
+ System.setProperty("gsi.working.directory", "/home/ogce");
+ myProxyUserName = System.getProperty("myproxy.user");
+ myProxyPassword = System.getProperty("myproxy.password");
+ workingDirectory = System.getProperty("gsi.working.directory");
+ slurmWorkingDirectory = "/home1/01437/ogce";
+ String pomDirectory = System.getProperty("basedir");
+
+ File pomFileDirectory = new File(pomDirectory);
+
+ System.out.println("POM directory ----------------- " + pomFileDirectory.getAbsolutePath());
+
+ certificateLocation = pomFileDirectory.getAbsolutePath() + "/certificates";
+
+
+ if (myProxyUserName == null || myProxyPassword == null || workingDirectory == 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<<<<<<<");
+ throw new Exception("Need my proxy user name password to run tests.");
+ }
+ }
+
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testExecuteCommand() throws Exception {
+ // Create authentication
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000, certificateLocation);
+
+ // Create command
+ CommandInfo commandInfo = new RawCommandInfo("/bin/ls");
+
+ // Server info
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+
+ // Output
+ CommandOutput commandOutput = new SystemCommandOutput();
+
+ // Execute command
+ CommandExecutor.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput, new ConfigReader());
+ }
+
+
+ @Test
+ public void testPBSAsync() 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);
+ // 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("60");
+ jobDescriptor.setAcountString("sds128");
+ 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);
+
+// 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());
+ }
+
+ @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);
+
+// 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());
+ }
+
+
+ @Test
+ public void testGetCluster() throws Exception {
+// GSIAuthenticationInfo authenticationInfo
+// = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+// 7512, 17280000);
+// // Server info
+// ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+// // Get the API
+// SSHApi sshApi = SSHApiFactory.createSSHApi(this.certificateLocation);
+// Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
+// System.out.println(cluster.getNodes()[0].getName());
+// System.out.println(cluster.getNodes()[0].getNp());
+// System.out.println(cluster.getNodes()[0].getState());
+// System.out.println(cluster.getNodes()[0].getCores()[0].getId());
+// System.out.println(cluster.getNodes()[0].getName());
+
+ }
+
+
+ @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 {
+// // Wait 5 seconds to start the first poll, this is hard coded, user doesn't have
+// // to configure this.
+// Thread.sleep(5000);
+// } catch (InterruptedException e) {
+// log.error("Error during job status monitoring");
+// throw new SSHApiException("Error during job status monitoring", e);
+// }
+// // Get the job status first
+// try {
+////
+//// Thread t = new Thread() {
+//// @Override
+//// public void run() {
+//// try {
+ // p
+ JobStatus jobStatus = pbsCluster.getJobStatus(jobID);
+ while (true) {
+ while (!jobStatus.equals(JobStatus.C.toString())) {
+ if (!jobStatus.equals(listener.getJobStatus().toString())) {
+ listener.setJobStatus(jobStatus);
+ listener.statusChanged(jobStatus);
+ }
+ Thread.sleep(60000);
+
+ jobStatus = pbsCluster.getJobStatus(jobID);
+ }
+ //Set the job status to Complete
+ listener.setJobStatus(JobStatus.C);
+ listener.statusChanged(jobStatus);
+ break;
+ }
+// } catch (InterruptedException e) {
+// log.error("Error listening to the submitted job", e);
+// } catch (SSHApiException e) {
+// log.error("Error listening to the submitted job", e);
+// }
+// }
+// };
+ // This thread runs until the program termination, so that use can provide
+// // any action in onChange method of the listener, without worrying for waiting in the caller thread.
+ //t.setDaemon(true);
+// t.start();
+ } catch (Exception e) {
+ log.error("Error during job status monitoring");
+ throw new SSHApiException("Error during job status monitoring", e);
+ }
+ while (!listener.isJobDone()) {
+ Thread.sleep(10000);
+ }
+ }
+
+ @Test
+ public void testJobCancel() 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("60");
+ jobDescriptor.setQueueName("normal");
+ jobDescriptor.setAcountString("sds128");
+ List<String> inputs = new ArrayList<String>();
+ inputs.add("1000");
+ jobDescriptor.setInputValues(inputs);
+ System.out.println(jobDescriptor.toXML());
+ String jobID = pbsCluster.submitBatchJob(jobDescriptor);
+ System.out.println("Job submitted to successfully : " + jobID);
+ JobDescriptor jobById = pbsCluster.getJobDescriptorById(jobID);
+ if (!CommonUtils.isJobFinished(jobById)) {
+ JobDescriptor job = pbsCluster.cancelJob(jobID);
+ if (CommonUtils.isJobFinished(job)) {
+ Assert.assertTrue(true);
+ } else {
+ Assert.assertTrue(true);
+ }
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/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
new file mode 100644
index 0000000..576d4ee
--- /dev/null
+++ b/tools/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/VanilaTestWithSSHAuth.java
@@ -0,0 +1,220 @@
+/*
+ *
+ * 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.impl;
+
+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.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class VanilaTestWithSSHAuth {
+
+ private String userName;
+ private String password;
+ private String passPhrase;
+ private String hostName;
+ private String workingDirectory;
+ private String privateKeyPath;
+ private String publicKeyPath;
+
+ @BeforeTest
+ public void setUp() throws Exception {
+ this.hostName = "bigred2.uits.iu.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.workingDirectory = System.getProperty("ssh.working.directory");
+
+ System.out.println();
+
+
+ if (this.userName == null || (this.userName != null && this.password == 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);
+ }
+
+ // Create command
+ CommandInfo commandInfo = new RawCommandInfo("/opt/torque/torque-4.2.3.1/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());
+
+
+ }
+
+
+ @Test
+ public void testSimplePBSJob() throws Exception {
+
+ AuthenticationInfo authenticationInfo = null;
+ if (password != null) {
+ authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+ } else {
+ 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/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";
+
+ workingDirectory = workingDirectory + File.separator
+ + date + "_" + UUID.randomUUID();
+ pbsCluster.makeDirectory(workingDirectory);
+ Thread.sleep(1000);
+ pbsCluster.makeDirectory(workingDirectory + File.separator + "inputs");
+ Thread.sleep(1000);
+ pbsCluster.makeDirectory(workingDirectory + File.separator + "outputs");
+
+
+ // doing file transfer to the remote resource
+ String remoteLocation = workingDirectory + File.separator + "inputs";
+ pbsCluster.scpTo(remoteLocation, pomFile);
+
+ int i = pomFile.lastIndexOf(File.separator);
+ String fileName = pomFile.substring(i + 1);
+ // 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(remoteLocation + File.separator + fileName);
+ 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());
+ }
+
+ @Test
+ public void testSCPFrom() throws Exception {
+
+ AuthenticationInfo authenticationInfo = null;
+ if (password != null) {
+ authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+ } else {
+ 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/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";
+
+ // Constructing theworking directory for demonstration and creating directories in the remote
+ // resource
+ workingDirectory = workingDirectory + File.separator
+ + date + "_" + UUID.randomUUID();
+ pbsCluster.makeDirectory(workingDirectory);
+ pbsCluster.scpTo(workingDirectory, pomFile);
+ Thread.sleep(1000);
+ pbsCluster.scpFrom(workingDirectory + File.separator + "pom.xml", System.getProperty("basedir"));
+ }
+
+
+}
[2/2] git commit: new files
Posted by la...@apache.org.
new files
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/f2a7fc3e
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/f2a7fc3e
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/f2a7fc3e
Branch: refs/heads/master
Commit: f2a7fc3e77dbe7682fc4f2bcd10ffefb781fd6a4
Parents: 9ab16b9
Author: lahiru <la...@apache.org>
Authored: Fri Apr 4 09:27:19 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Fri Apr 4 09:27:19 2014 -0400
----------------------------------------------------------------------
.../impl/AbstractBESTestWithMyProxyAuth.java | 169 ++++++++
.../impl/BESParallelJobTestWithMyProxyAuth.java | 141 ++++++
.../impl/BESProviderTestWithMyProxyAuth.java | 211 +++++++++
.../services/impl/BigRed2TestWithSSHAuth.java | 213 +++++++++
.../impl/GFacBaseTestWithMyProxyAuth.java | 115 +++++
.../impl/GSISSHProviderTestWithMyProxyAuth.java | 208 +++++++++
.../impl/GramProviderTestWithMyProxyAuth.java | 225 ++++++++++
.../impl/JSDLGeneratorTestWithMyProxyAuth.java | 318 ++++++++++++++
.../impl/ParamChemTestWithMyProxyAuth.java | 306 +++++++++++++
.../impl/SSHProviderTestWithSSHAuth.java | 172 ++++++++
.../services/impl/US3TestWithMyProxyAuth.java | 152 +++++++
.../GSISecurityContextTestWithMyProxyAuth.java | 174 ++++++++
.../impl/GramProviderTestWithMyProxyAuth.java | 61 +++
.../ssh/config/SCPFromTestWithMyProxyAuth.java | 74 ++++
.../gsi/ssh/config/SCPToTestWithSSHAuth.java | 75 ++++
.../impl/DefaultSSHApiTestWithMyProxyAuth.java | 433 +++++++++++++++++++
.../gsi/ssh/impl/VanilaTestWithSSHAuth.java | 220 ++++++++++
17 files changed, 3267 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java
new file mode 100644
index 0000000..689ae86
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/AbstractBESTestWithMyProxyAuth.java
@@ -0,0 +1,169 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Date;
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.UnicoreHostType;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument.ContextHeader;
+import org.apache.log4j.PropertyConfigurator;
+
+public abstract class AbstractBESTestWithMyProxyAuth extends GFacBaseTestWithMyProxyAuth {
+
+ protected static String tmpFilePath = "target"+File.separator+"data";
+ protected JobExecutionContext jobExecutionContext;
+ private String userName = "";
+
+// public static final String[] hostArray = new String[] { "https://zam1161v01.zam.kfa-juelich.de:8002/INTEROP1/services/BESFactory?res=default_bes_factory" };
+
+ public static final String[] hostArray = new String[] {
+ "https://deisa-unic.fz-juelich.de:9111/FZJ_JUROPA/services/BESFactory?res=default_bes_factory"
+ };
+
+
+// public static final String[] hostArray = new String[] {
+// "https://daemon.alamo.futuregrid.org:8082/ALAMO/services/BESFactory?res=default_bes_factory"
+// };
+
+// public static final String[] hostArray = new String[] {
+// "https://daemon.india.futuregrid.org:8081/INDIA/services/BESFactory?res=default_bes_factory"
+// };
+
+
+ // directory where data will be copy into and copied out to unicore
+ // resources
+
+ // public static final String gridftpAddress =
+ // "gsiftp://gridftp1.ls4.tacc.utexas.edu:2811";
+ // public static final String scratchDir = "/scratch/01129/tg804076/";
+
+ // public static final String gridftpAddress =
+ // "gsiftp://gridftp.psc.xsede.org:2811";
+ // public static final String scratchDir = "/brashear/msmemon/airavata/";
+
+ public static final String gridftpAddress = "gsiftp://osg-xsede.grid.iu.edu:2811/";
+ public static final String scratchDir = "/home/ogce/airavata/";
+
+ protected String remoteTempDir = null;
+
+ protected void initTest() throws Exception {
+ PropertyConfigurator.configure("src/test/resources/logging.properties");
+ /*
+ * Default tmp location
+ */
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ remoteTempDir = scratchDir + File.separator + "BESJOB" + "_" + date
+ + "_" + UUID.randomUUID();
+ jobExecutionContext = new JobExecutionContext(getGFACConfig(),
+ getServiceDesc("BES-APP-Service").getType().getName());
+ jobExecutionContext.setApplicationContext(getApplicationContext());
+ jobExecutionContext.setInMessageContext(getInMessageContext());
+ jobExecutionContext.setOutMessageContext(getOutMessageContext());
+ jobExecutionContext.addSecurityContext(
+ GSISecurityContext.GSI_SECURITY_CONTEXT, getSecurityContext());
+
+ }
+
+ protected void submitJob() throws Exception {
+// ContextHeader contextHeader = ContextHeader.Factory.newInstance();
+// buildOutputLocation(contextHeader);
+//
+// buildUserName(contextHeader, userName);
+// jobExecutionContext.setContextHeader(contextHeader);
+ }
+
+ protected GFacConfiguration getGFACConfig() throws Exception {
+ URL resource = this.getClass().getClassLoader()
+ .getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ System.out.println(resource.getFile());
+ return GFacConfiguration.create(new File(resource.getPath()), null,
+ null);
+ }
+
+ protected ApplicationContext getApplicationContext() {
+ ApplicationContext applicationContext = new ApplicationContext();
+ applicationContext.setHostDescription(getHostDesc());
+ return applicationContext;
+ }
+
+ protected HostDescription getHostDesc() {
+ HostDescription host = new HostDescription(UnicoreHostType.type);
+ host.getType().setHostAddress("zam1161v01.zam.kfa-juelich.de");
+ host.getType().setHostName("DEMO-INTEROP-SITE");
+ ((UnicoreHostType) host.getType())
+ .setUnicoreBESEndPointArray(hostArray);
+ ((UnicoreHostType) host.getType())
+ .setGridFTPEndPointArray(new String[] { gridftpAddress });
+ return host;
+ }
+
+ protected abstract ApplicationDescription getApplicationDesc(
+ JobTypeType jobType);
+
+ protected ServiceDescription getServiceDesc(String serviceName) {
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName(serviceName);
+ return serv;
+ }
+
+ protected abstract MessageContext getInMessageContext();
+
+ protected abstract MessageContext getOutMessageContext();
+
+
+ protected void buildOutputLocation(ContextHeader currentContextHeader) {
+ File tmpDir = new File(tmpFilePath+File.separator+"output-"+new Random().nextInt(1000));
+
+ if(!tmpDir.exists()) {
+ tmpDir.mkdirs();
+ }
+ currentContextHeader.addNewWorkflowOutputDataHandling().addNewApplicationOutputDataHandling().setOutputDataDirectory(tmpDir.getAbsolutePath());
+
+ }
+
+
+ protected void buildUserName(ContextHeader currentContextHeader, String userName) {
+ if("".equals(userName) || userName == null) return;
+
+ currentContextHeader.setUserIdentifier(userName);
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java
new file mode 100644
index 0000000..0775271
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESParallelJobTestWithMyProxyAuth.java
@@ -0,0 +1,141 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import java.io.File;
+import java.util.Date;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.ExtendedKeyValueType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BESParallelJobTestWithMyProxyAuth extends AbstractBESTestWithMyProxyAuth {
+
+
+ @Before
+ public void initJobContext() throws Exception {
+ initTest();
+ }
+
+
+ @Test
+ public void submitJob() throws Exception {
+ JobTypeType jobType = JobTypeType.Factory.newInstance();
+ jobType.set(JobTypeType.MPI);
+ ApplicationContext appContext = getApplicationContext();
+ appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType));
+ jobExecutionContext.setApplicationContext(appContext);
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ }
+
+
+ protected ApplicationDescription getApplicationDesc(JobTypeType jobType) {
+ ApplicationDescription appDesc = new ApplicationDescription(
+ HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType appDepType = (HpcApplicationDeploymentType) appDesc
+ .getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
+ .newInstance();
+ name.setStringValue("MPIRemote");
+ appDepType.setApplicationName(name);
+// ProjectAccountType projectAccountType = appDepType.addNewProjectAccount();
+// projectAccountType.setProjectAccountNumber("TG-AST110064");
+
+// QueueType queueType = appDepType.addNewQueue();
+// queueType.setQueueName("development");
+
+ // TODO: also handle parallel jobs
+ if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
+ appDepType.setJobType(JobTypeType.SERIAL);
+ }
+ else if (jobType.enumValue() == JobTypeType.MPI) {
+ appDepType.setJobType(JobTypeType.MPI);
+ }
+ else {
+ appDepType.setJobType(JobTypeType.OPEN_MP);
+ }
+
+ appDepType.setNodeCount(1);
+ appDepType.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ appDepType.setExecutableLocation("/home/bes/mpiexamples/a.out");
+
+// appDepType.setExecutableLocation("/lustre/jhome11/zam/m.memon/mpiexamples");
+
+
+
+ ExtendedKeyValueType extKV = appDepType.addNewKeyValuePairs();
+ // using jsdl spmd standard
+ extKV.setName("NumberOfProcesses");
+ // this will be transformed into mpiexec -n 4
+ extKV.setStringValue("1");
+
+ /*
+ * Default tmp location
+ */
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ String remoteTempDir = scratchDir + File.separator + "SimpleEcho" + "_" + date + "_"
+ + UUID.randomUUID();
+
+ System.out.println(remoteTempDir);
+
+ // no need of these parameters, as unicore manages by itself
+ appDepType.setScratchWorkingDirectory(remoteTempDir);
+ appDepType.setStaticWorkingDirectory(remoteTempDir);
+ appDepType.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
+ appDepType.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
+
+ appDepType.setStandardOutput(appDepType.getOutputDataDirectory()+"/jsdl_stdout");
+
+ appDepType.setStandardError(appDepType.getOutputDataDirectory()+"/jsdl_stderr");
+
+ return appDesc;
+ }
+ protected MessageContext getInMessageContext() {
+ MessageContext inMessage = new MessageContext();
+ return inMessage;
+ }
+
+
+
+ protected MessageContext getOutMessageContext() {
+ MessageContext outMessage = new MessageContext();
+ return outMessage;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java
new file mode 100644
index 0000000..aebdf4c
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BESProviderTestWithMyProxyAuth.java
@@ -0,0 +1,211 @@
+package org.apache.airavata.core.gfac.services.impl;
+
+/*
+*
+* 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.
+*
+*/
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.ProjectAccountType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BESProviderTestWithMyProxyAuth extends AbstractBESTestWithMyProxyAuth {
+
+ private String tmpFilePath;
+
+ @Before
+ public void initJobContext() throws Exception {
+ initTest();
+ }
+
+ @Test
+ public void submitJob() throws GFacException {
+ JobTypeType jobType = JobTypeType.Factory.newInstance();
+ jobType.set(JobTypeType.SERIAL);
+ ApplicationContext appContext = getApplicationContext();
+ appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType));
+ jobExecutionContext.setApplicationContext(appContext);
+
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ }
+
+
+ protected ApplicationDescription getApplicationDesc(JobTypeType jobType) {
+ ApplicationDescription appDesc = new ApplicationDescription(
+ HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc
+ .getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
+ .newInstance();
+ name.setStringValue("CatRemote");
+ app.setApplicationName(name);
+ ProjectAccountType projectAccountType = app.addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber("TG-AST110064");
+
+ app.setCpuCount(1);
+ // TODO: also handle parallel jobs
+ if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
+ app.setJobType(JobTypeType.SERIAL);
+ }
+ else if (jobType.enumValue() == JobTypeType.MPI) {
+ app.setJobType(JobTypeType.MPI);
+ }
+ else {
+ app.setJobType(JobTypeType.OPEN_MP);
+ }
+
+ app.setNodeCount(1);
+ app.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ app.setExecutableLocation("/bin/cat");
+
+
+ /*
+ * Default tmp location
+ */
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ String remoteTempDir = scratchDir + File.separator + "SimpleCat" + "_" + date + "_"
+ + UUID.randomUUID();
+
+ System.out.println(remoteTempDir);
+
+ // no need of these parameters, as unicore manages by itself
+ app.setScratchWorkingDirectory(remoteTempDir);
+ app.setStaticWorkingDirectory(remoteTempDir);
+ app.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
+ app.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
+
+ app.setStandardOutput(app.getOutputDataDirectory()+"/jsdl_stdout");
+
+ app.setStandardError(app.getOutputDataDirectory()+"/jsdl_stderr");
+
+ return appDesc;
+ }
+
+ protected ServiceDescription getServiceDesc() {
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("SimpleCat");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("copy_input");
+ input.setParameterType(URIParameterType.Factory.newInstance());
+ inputList.add(input);
+ InputParameterType[] inputParamList = inputList
+ .toArray(new InputParameterType[inputList.size()]);
+
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+ return serv;
+ }
+
+ protected MessageContext getInMessageContext() {
+
+ File tmpFile = new File("target"+File.separator+"tmp-"+new Random().nextInt(5));
+ try {
+ FileUtils.touch(tmpFile);
+ FileUtils.writeStringToFile(tmpFile, "tmp contents", "UTF-8");
+ tmpFilePath = tmpFile.getAbsolutePath();
+ } catch (Exception e) {
+ assertTrue(false);
+ }
+
+ MessageContext inMessage = new MessageContext();
+
+ ActualParameter copy_input = new ActualParameter();
+ copy_input.getType().changeType(URIParameterType.type);
+ ((URIParameterType)copy_input.getType()).setValue("file:///"+tmpFile.getAbsolutePath());
+ inMessage.addParameter("f1", copy_input);
+
+ ActualParameter f2 = new ActualParameter();
+ f2.getType().changeType(URIParameterType.type);
+ ((URIParameterType)f2.getType()).setValue("http://unicore-dev.zam.kfa-juelich.de/maven/cog-globus/cog-jglobus/1.4/cog-jglobus-1.4.jar");
+ inMessage.addParameter("f2", f2);
+
+
+ ActualParameter a1 = new ActualParameter();
+ a1.getType().changeType(StringParameterType.type);
+ ((StringParameterType)a1.getType()).setValue(tmpFile.getName());
+ inMessage.addParameter("arg1", a1);
+
+ return inMessage;
+ }
+
+ protected MessageContext getOutMessageContext() {
+
+ MessageContext outMessage = new MessageContext();
+ ActualParameter a1 = new ActualParameter();
+ a1.getType().changeType(StringParameterType.type);
+ ((StringParameterType)a1.getType()).setValue(new File(tmpFilePath).getName());
+ outMessage.addParameter("echo_output", a1);
+
+ ActualParameter o1 = new ActualParameter();
+ o1.getType().changeType(URIParameterType.type);
+ // this may be any gridftp / ftp directory
+ ((URIParameterType)o1.getType()).setValue(gridftpAddress+"/"+remoteTempDir + "/" + "outputData"+"/"+"cog-jglobus-1.4.jar");
+ outMessage.addParameter("o1", o1);
+
+ return outMessage;
+ }
+
+ @After
+ public void cleanData(){
+ FileUtils.deleteQuietly(new File(tmpFilePath));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java
new file mode 100644
index 0000000..78d3b27
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java
@@ -0,0 +1,213 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.SecurityContext;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPasswordAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.schemas.gfac.*;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class BigRed2TestWithSSHAuth {
+ private JobExecutionContext jobExecutionContext;
+
+ private static final String hostAddress = "bigred2";
+ private static final String hostName = "bigred2.uits.iu.edu";
+ private static String userName = "lginnali";
+ private static String password = "";
+
+ @Before
+ public void setUp() throws Exception {
+
+ if(System.getProperty("bigred2.password") == null || System.getProperty("bigred2.username") == null){
+ System.out.println("set the bigred2 password/username in maven command : mvn clean install -Dbigred2.username=xxx -Dbigred2.password=yyy");
+ throw new Exception("Wrong inputs given");
+ }
+ userName = System.getProperty("bigred2.username");
+ password = System.getProperty("bigred2.password");
+ URL resource = GramProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ assert resource != null;
+ System.out.println(resource.getFile());
+ GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), null, null);
+
+// gFacConfiguration.setMyProxyLifeCycle(3600);
+// gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+// gFacConfiguration.setMyProxyUser("*****");
+// gFacConfiguration.setMyProxyPassphrase("*****");
+// gFacConfiguration.setTrustedCertLocation("./certificates");
+// //have to set InFlwo Handlers and outFlowHandlers
+// gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
+// gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
+
+ /*
+ * Host
+ */
+ HostDescription host = new HostDescription(SSHHostType.type);
+ host.getType().setHostAddress(hostAddress);
+ host.getType().setHostName(hostName);
+ ((SSHHostType)host.getType()).setHpcResource(true);
+ /*
+ * App
+ */
+ ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+ name.setStringValue("EchoLocal");
+ app.setApplicationName(name);
+
+ app.setCpuCount(1);
+ app.setJobType(JobTypeType.SERIAL);
+ app.setNodeCount(1);
+ app.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ app.setExecutableLocation("/bin/echo");
+
+ /*
+ * Default tmp location
+ */
+ String tempDir = "~/";
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ tempDir = tempDir + File.separator
+ + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+ System.out.println(tempDir);
+ app.setScratchWorkingDirectory(tempDir);
+ app.setStaticWorkingDirectory(tempDir);
+ app.setInputDataDirectory(tempDir + File.separator + "inputData");
+ app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+ app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stdout");
+ app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stderr");
+ app.setMaxWallTime(5);
+ app.setJobSubmitterCommand("aprun -n 1");
+ app.setInstalledParentPath("/opt/torque/torque-4.2.3.1/bin/");
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("SimpleEcho");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("echo_input");
+ input.setParameterType(StringParameterType.Factory.newInstance());
+ inputList.add(input);
+
+ InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+
+ .size()]);
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+
+ jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
+ // Adding security context
+ jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(app));
+ ApplicationContext applicationContext = new ApplicationContext();
+ jobExecutionContext.setApplicationContext(applicationContext);
+ applicationContext.setServiceDescription(serv);
+ applicationContext.setApplicationDeploymentDescription(appDesc);
+ applicationContext.setHostDescription(host);
+
+ MessageContext inMessage = new MessageContext();
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
+ inMessage.addParameter("echo_input", echo_input);
+
+
+ jobExecutionContext.setInMessageContext(inMessage);
+
+ MessageContext outMessage = new MessageContext();
+ ActualParameter echo_out = new ActualParameter();
+// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ outMessage.addParameter("echo_output", echo_out);
+
+ jobExecutionContext.setOutMessageContext( outMessage);
+
+ }
+
+ private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) {
+ AuthenticationInfo authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+ // Server info
+ ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
+
+ Cluster pbsCluster = null;
+ try {
+ JobManagerConfiguration pbsJobManager = CommonUtils.getPBSJobManager(app.getInstalledParentPath());
+ pbsCluster = new PBSCluster(serverInfo, authenticationInfo,pbsJobManager);
+ } catch (SSHApiException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+
+ SSHSecurityContext sshSecurityContext = new SSHSecurityContext();
+ sshSecurityContext.setPbsCluster(pbsCluster);
+ sshSecurityContext.setUsername(userName);
+ return sshSecurityContext;
+ }
+
+ @Test
+ public void testGramProvider() throws GFacException {
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestWithMyProxyAuth.java
new file mode 100644
index 0000000..3bd814b
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GFacBaseTestWithMyProxyAuth.java
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import junit.framework.Assert;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.common.utils.DatabaseTestCases;
+import org.apache.airavata.common.utils.DerbyUtil;
+import org.apache.airavata.credential.store.store.CredentialReader;
+import org.apache.airavata.credential.store.store.impl.CredentialReaderImpl;
+import org.apache.airavata.gfac.RequestData;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.log4j.Logger;
+import org.junit.BeforeClass;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 7/11/13
+ * Time: 1:31 AM
+ */
+
+public class GFacBaseTestWithMyProxyAuth extends DatabaseTestCases {
+
+ private static String myProxyUserName;
+ private static String myProxyPassword;
+
+ private static final Logger log = Logger.getLogger(GFacBaseTestWithMyProxyAuth.class);
+
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ AiravataUtils.setExecutionAsServer();
+
+ myProxyUserName = System.getProperty("myproxy.user");
+ myProxyPassword = System.getProperty("myproxy.password");
+
+ if (userName == null || password == null || userName.trim().equals("") || password.trim().equals("")) {
+ log.error("===== Please set myproxy.user and myproxy.password system properties. =======");
+ Assert.fail("Please set myproxy.user and myproxy.password system properties.");
+ }
+
+ log.info("Using my proxy user name - " + userName);
+
+ setUpDatabase();
+
+ }
+
+
+
+
+ public static void setUpDatabase() throws Exception {
+ DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
+
+ waitTillServerStarts();
+
+ /*
+ * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_NAME VARCHAR(256) NOT NULL,\n" +
+ * " COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n" + " CREDENTIAL BLOB NOT NULL,\n" +
+ * " PRIVATE_KEY BLOB NOT NULL,\n" + " NOT_BEFORE VARCHAR(256) NOT NULL,\n" +
+ * " NOT_AFTER VARCHAR(256) NOT NULL,\n" + " LIFETIME INTEGER NOT NULL,\n" +
+ * " REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,\n" +
+ * " REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',\n" +
+ * " PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)\n" + ")";
+ */
+
+ String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
+ + " GATEWAY_ID VARCHAR(256) NOT NULL,\n"
+ + " TOKEN_ID VARCHAR(256) NOT NULL,\n"
+ + // Actual token used to identify the credential
+ " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
+ + " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
+ + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
+
+ String dropTable = "drop table CREDENTIALS";
+
+ try {
+ executeSQL(dropTable);
+ } catch (Exception e) {
+ }
+
+ executeSQL(createTable);
+
+ }
+
+ public GSISecurityContext getSecurityContext() throws Exception {
+ GSISecurityContext.setUpTrustedCertificatePath("/Users/raminder/.globus/certificates");
+ RequestData requestData = new RequestData();
+ requestData.setMyProxyServerUrl("myproxy.teragrid.org");
+ requestData.setMyProxyUserName("******");
+ requestData.setMyProxyPassword("*******");
+ requestData.setMyProxyLifeTime(3600);
+ CredentialReader credentialReader = new CredentialReaderImpl(getDbUtil());
+ return new GSISecurityContext(credentialReader, requestData);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
new file mode 100644
index 0000000..57b0c79
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java
@@ -0,0 +1,208 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.SecurityContext;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.schemas.gfac.*;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class GSISSHProviderTestWithMyProxyAuth {
+ private JobExecutionContext jobExecutionContext;
+
+ //FIXME: move job properties to configuration file
+ private static final String hostAddress = "trestles.sdsc.edu";
+ private static final String hostName = "trestles";
+ private static final String myProxyUserName = "ogce";
+ private static final String myProxyPassword = "";
+ private static final String certificateLocation = "/Users/raminder/.globus/certificates/";
+
+ @Before
+ public void setUp() throws Exception {
+ URL resource = GSISSHProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ assert resource != null;
+ System.out.println(resource.getFile());
+ GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), null, null);
+
+// gFacConfiguration.setMyProxyLifeCycle(3600);
+// gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+// gFacConfiguration.setMyProxyUser("*****");
+// gFacConfiguration.setMyProxyPassphrase("*****");
+// gFacConfiguration.setTrustedCertLocation("./certificates");
+// //have to set InFlwo Handlers and outFlowHandlers
+// gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
+// gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
+
+ /*
+ * Host
+ */
+ HostDescription host = new HostDescription(GsisshHostType.type);
+ host.getType().setHostAddress(hostAddress);
+ host.getType().setHostName(hostName);
+
+ /*
+ * App
+ */
+ ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc.getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+ name.setStringValue("EchoLocal");
+ app.setApplicationName(name);
+ ProjectAccountType projectAccountType = app.addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber("sds128");
+
+ QueueType queueType = app.addNewQueue();
+ queueType.setQueueName("normal");
+
+ app.setCpuCount(1);
+ app.setJobType(JobTypeType.SERIAL);
+ app.setNodeCount(1);
+ app.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ app.setExecutableLocation("/bin/echo");
+
+ /*
+ * Default tmp location
+ */
+ String tempDir = "/home/ogce/scratch/";
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ tempDir = tempDir + File.separator
+ + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+ System.out.println(tempDir);
+ app.setScratchWorkingDirectory(tempDir);
+ app.setStaticWorkingDirectory(tempDir);
+ app.setInputDataDirectory(tempDir + File.separator + "inputData");
+ app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+ app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stdout");
+ app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stderr");
+ app.setMaxWallTime(5);
+ app.setInstalledParentPath("/opt/torque/bin/");
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("SimpleEcho");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("echo_input");
+ input.setParameterType(StringParameterType.Factory.newInstance());
+ inputList.add(input);
+
+ InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+
+ .size()]);
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+
+ jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
+ // Adding security context
+ jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(app));
+ ApplicationContext applicationContext = new ApplicationContext();
+ jobExecutionContext.setApplicationContext(applicationContext);
+ applicationContext.setServiceDescription(serv);
+ applicationContext.setApplicationDeploymentDescription(appDesc);
+ applicationContext.setHostDescription(host);
+
+ MessageContext inMessage = new MessageContext();
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
+ inMessage.addParameter("echo_input", echo_input);
+
+
+ jobExecutionContext.setInMessageContext(inMessage);
+
+ MessageContext outMessage = new MessageContext();
+ ActualParameter echo_out = new ActualParameter();
+// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ outMessage.addParameter("echo_output", echo_out);
+
+ jobExecutionContext.setOutMessageContext(outMessage);
+
+ }
+
+ private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) {
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000, certificateLocation);
+
+ // Server info
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+ Cluster pbsCluster = null;
+ try {
+ pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(app.getInstalledParentPath()));
+ } catch (SSHApiException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ GSISecurityContext sshSecurityContext = new GSISecurityContext(pbsCluster);
+ return sshSecurityContext;
+ }
+ @Test
+ public void testGramProvider() throws GFacException {
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTestWithMyProxyAuth.java
new file mode 100644
index 0000000..ffaaaae
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GramProviderTestWithMyProxyAuth.java
@@ -0,0 +1,225 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.ProjectAccountType;
+import org.apache.airavata.schemas.gfac.QueueType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GramProviderTestWithMyProxyAuth extends GFacBaseTestWithMyProxyAuth {
+ private JobExecutionContext jobExecutionContext;
+
+
+// private static final String hostAddress = "blacklight.psc.teragrid.org";
+// private static final String hostName = "Blacklight";
+// private static final String gridftpAddress = "gsiftp://gridftp.blacklight.psc.teragrid.org:2812";
+// private static final String gramAddress = "";
+
+ //FIXME: move job properties to configuration file
+ private static final String hostAddress = "trestles.sdsc.edu";
+ private static final String hostName = "trestles";
+ private static final String gridftpAddress = "gsiftp://trestles.sdsc.edu:2811/";
+ private static final String gramAddress = "trestles-login2.sdsc.edu:2119/jobmanager-pbstest2";
+
+ @Before
+ public void setUp() throws Exception {
+ URL resource = GramProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ assert resource != null;
+ System.out.println(resource.getFile());
+ GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),null,null);
+// gFacConfiguration.setMyProxyLifeCycle(3600);
+// gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+// gFacConfiguration.setMyProxyUser("*****");
+// gFacConfiguration.setMyProxyPassphrase("*****");
+// gFacConfiguration.setTrustedCertLocation("./certificates");
+// //have to set InFlwo Handlers and outFlowHandlers
+// gFacConfiguration.setInHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GramDirectorySetupHandler","org.apache.airavata.gfac.handler.GridFTPInputHandler"}));
+// gFacConfiguration.setOutHandlers(Arrays.asList(new String[] {"org.apache.airavata.gfac.handler.GridFTPOutputHandler"}));
+
+ /*
+ * Host
+ */
+ HostDescription host = new HostDescription(GlobusHostType.type);
+ host.getType().setHostAddress(hostAddress);
+ host.getType().setHostName(hostName);
+ ((GlobusHostType)host.getType()).setGlobusGateKeeperEndPointArray(new String[]{gramAddress});
+ ((GlobusHostType)host.getType()).setGridFTPEndPointArray(new String[]{gridftpAddress});
+ /*
+ * App
+ */
+ ApplicationDescription appDesc = new ApplicationDescription(HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType)appDesc.getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
+ name.setStringValue("EchoLocal");
+ app.setApplicationName(name);
+ ProjectAccountType projectAccountType = app.addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber("sds128");
+
+ QueueType queueType = app.addNewQueue();
+ queueType.setQueueName("development");
+
+ app.setCpuCount(1);
+ app.setJobType(JobTypeType.SERIAL);
+ app.setNodeCount(1);
+ app.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ app.setExecutableLocation("/bin/echo");
+
+ /*
+ * Default tmp location
+ */
+ String tempDir = "/scratch/01437/ogce/test/";
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ tempDir = tempDir + File.separator
+ + "SimpleEcho" + "_" + date + "_" + UUID.randomUUID();
+
+ System.out.println(tempDir);
+ app.setScratchWorkingDirectory(tempDir);
+ app.setStaticWorkingDirectory(tempDir);
+ app.setInputDataDirectory(tempDir + File.separator + "inputData");
+ app.setOutputDataDirectory(tempDir + File.separator + "outputData");
+ app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stdout");
+ app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue() + ".stderr");
+
+
+ /*
+ * Service
+ */
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("SimpleEcho");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("echo_input");
+ input.setParameterType(StringParameterType.Factory.newInstance());
+ inputList.add(input);
+
+ InputParameterType input1 = InputParameterType.Factory.newInstance();
+ input.setParameterName("myinput");
+ URIParameterType uriType = URIParameterType.Factory.newInstance();
+ uriType.setValue("gsiftp://gridftp1.ls4.tacc.utexas.edu:2811//home1/01437/ogce/gram_20130215.log");
+ input.setParameterType(uriType);
+ inputList.add(input1);
+
+
+ InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+
+ .size()]);
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+
+ jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
+ // Adding security context
+ jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, getSecurityContext());
+ ApplicationContext applicationContext = new ApplicationContext();
+ jobExecutionContext.setApplicationContext(applicationContext);
+ applicationContext.setServiceDescription(serv);
+ applicationContext.setApplicationDeploymentDescription(appDesc);
+ applicationContext.setHostDescription(host);
+
+ MessageContext inMessage = new MessageContext();
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ inMessage.addParameter("echo_input", echo_input);
+
+ // added extra
+ ActualParameter copy_input = new ActualParameter();
+ copy_input.getType().changeType(URIParameterType.type);
+ ((URIParameterType)copy_input.getType()).setValue("file:///tmp/tmpstrace");
+
+ ActualParameter outlocation = new ActualParameter();
+ ((StringParameterType)outlocation.getType()).setValue("./outputData/.");
+ inMessage.addParameter("copy_input", copy_input);
+ inMessage.addParameter("outputlocation", outlocation);
+
+ // added extra
+
+
+
+ jobExecutionContext.setInMessageContext(inMessage);
+
+ MessageContext outMessage = new MessageContext();
+ ActualParameter echo_out = new ActualParameter();
+// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
+ outMessage.addParameter("echo_output", echo_out);
+
+ jobExecutionContext.setOutMessageContext(outMessage);
+
+ }
+
+ @Test
+ public void testGramProvider() throws GFacException {
+ GFacImpl gFacAPI = new GFacImpl();
+ gFacAPI.submitJob(jobExecutionContext);
+ MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
+ Assert.assertEquals(MappingFactory.toString((ActualParameter)outMessageContext.getParameter("echo_output")), "hello");
+ }
+
+ @Test
+ public void testGetJdbcUrl() {
+ System.out.println(getJDBCUrl());
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/f2a7fc3e/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTestWithMyProxyAuth.java
new file mode 100644
index 0000000..528b083
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/JSDLGeneratorTestWithMyProxyAuth.java
@@ -0,0 +1,318 @@
+/*
+ *
+ * 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.core.gfac.services.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.provider.utils.JSDLGenerator;
+import org.apache.airavata.gfac.provider.utils.JSDLUtils;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.JobTypeType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
+import org.apache.airavata.schemas.gfac.ProjectAccountType;
+import org.apache.airavata.schemas.gfac.QueueType;
+import org.apache.airavata.schemas.gfac.StringParameterType;
+import org.apache.airavata.schemas.gfac.URIParameterType;
+import org.apache.airavata.schemas.gfac.UnicoreHostType;
+import org.apache.log4j.PropertyConfigurator;
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JSDLGeneratorTestWithMyProxyAuth {
+
+ public static final String[] hostArray = new String[] { "https://zam1161v01.zam.kfa-juelich.de:8002/INTEROP1/services/BESFactory?res=default_bes_factory" };
+ public static final String gridftpAddress = "gsiftp://gridftp.blacklight.psc.teragrid.org:2811";
+ public static final String hostAddress = "zam1161v01.zam.kfa-juelich.de";
+ public static final String hostName = "DEMO-INTEROP-SITE";
+ public static final String scratchDir = "/scratch/msmemon/airavata";
+
+ protected JobExecutionContext jobExecutionContext;
+
+
+ @Test
+ public void testSerialJSDLWithStdout() throws Exception{
+
+ JobTypeType jobType = JobTypeType.Factory.newInstance();
+ jobType.set(JobTypeType.SERIAL);
+ ApplicationContext appContext = getApplicationContext();
+ appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType, true));
+ jobExecutionContext.setApplicationContext(appContext);
+
+ JobDefinitionDocument jobDefDoc = JSDLGenerator.buildJSDLInstance(jobExecutionContext);
+
+ assertTrue (jobDefDoc.getJobDefinition().getJobDescription().getApplication().toString().contains("/bin/cat"));
+ assertTrue(jobDefDoc.getJobDefinition().getJobDescription().getDataStagingArray().length > 2);
+
+ assertTrue(jobDefDoc.getJobDefinition().getJobDescription().getJobIdentification().getJobProjectArray().length > 0);
+
+ assertFalse(JSDLUtils.getPOSIXApplication(jobDefDoc.getJobDefinition())==null);
+
+ assertEquals("jsdl_stdout", JSDLUtils.getOrCreatePOSIXApplication(jobDefDoc.getJobDefinition()).getOutput().getStringValue().toString());
+
+ }
+
+ @Test
+ public void testSerialJSDLWithoutStdout() throws Exception{
+
+ JobTypeType jobType = JobTypeType.Factory.newInstance();
+ jobType.set(JobTypeType.SERIAL);
+ ApplicationContext appContext = getApplicationContext();
+ appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType, false));
+ jobExecutionContext.setApplicationContext(appContext);
+
+ JobDefinitionDocument jobDefDoc = JSDLGenerator.buildJSDLInstance(jobExecutionContext);
+
+ assertTrue (jobDefDoc.getJobDefinition().getJobDescription().getApplication().toString().contains("/bin/cat"));
+ assertTrue(jobDefDoc.getJobDefinition().getJobDescription().getDataStagingArray().length > 2);
+
+ assertTrue(jobDefDoc.getJobDefinition().getJobDescription().getJobIdentification().getJobProjectArray().length > 0);
+
+ assertFalse(JSDLUtils.getPOSIXApplication(jobDefDoc.getJobDefinition())==null);
+
+ assertEquals("stdout", JSDLUtils.getOrCreatePOSIXApplication(jobDefDoc.getJobDefinition()).getOutput().getStringValue().toString());
+ assertEquals("stderr", JSDLUtils.getOrCreatePOSIXApplication(jobDefDoc.getJobDefinition()).getError().getStringValue().toString());
+
+ }
+
+
+ @Test
+ public void testMPIJSDL() throws Exception{
+
+ JobTypeType jobType = JobTypeType.Factory.newInstance();
+ jobType.set(JobTypeType.MPI);
+ ApplicationContext appContext = getApplicationContext();
+ appContext.setApplicationDeploymentDescription(getApplicationDesc(jobType, true));
+ jobExecutionContext.setApplicationContext(appContext);
+
+ JobDefinitionDocument jobDefDoc = JSDLGenerator.buildJSDLInstance(jobExecutionContext);
+
+ assertTrue (jobDefDoc.getJobDefinition().getJobDescription().getApplication().toString().contains("/bin/cat"));
+ assertTrue(jobDefDoc.getJobDefinition().getJobDescription().getDataStagingArray().length > 2);
+
+ assertTrue(jobDefDoc.getJobDefinition().getJobDescription().getJobIdentification().getJobProjectArray().length > 0);
+
+ assertEquals("jsdl_stdout", JSDLUtils.getOrCreateSPMDApplication(jobDefDoc.getJobDefinition()).getOutput().getStringValue().toString());
+
+ assertFalse(JSDLUtils.getSPMDApplication(jobDefDoc.getJobDefinition())==null);
+
+
+ }
+
+ protected GFacConfiguration getGFACConfig() throws Exception{
+ URL resource = BESProviderTestWithMyProxyAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ System.out.println(resource.getFile());
+ GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),null,null);
+ return gFacConfiguration;
+ }
+
+
+ protected ApplicationContext getApplicationContext() {
+ ApplicationContext applicationContext = new ApplicationContext();
+ applicationContext.setHostDescription(getHostDesc());
+
+ applicationContext.setServiceDescription(getServiceDesc());
+ return applicationContext;
+ }
+
+ protected ApplicationDescription getApplicationDesc(JobTypeType jobType, boolean setOuput) {
+ ApplicationDescription appDesc = new ApplicationDescription(
+ HpcApplicationDeploymentType.type);
+ HpcApplicationDeploymentType app = (HpcApplicationDeploymentType) appDesc
+ .getType();
+ ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory
+ .newInstance();
+ name.setStringValue("EchoLocal");
+ app.setApplicationName(name);
+ ProjectAccountType projectAccountType = app.addNewProjectAccount();
+ projectAccountType.setProjectAccountNumber("TG-AST110064");
+
+ QueueType queueType = app.addNewQueue();
+ queueType.setQueueName("development");
+
+ app.setCpuCount(1);
+ // TODO: also handle parallel jobs
+ if((jobType.enumValue() == JobTypeType.SERIAL) || (jobType.enumValue() == JobTypeType.SINGLE)) {
+ app.setJobType(JobTypeType.SERIAL);
+ }
+ else if (jobType.enumValue() == JobTypeType.MPI) {
+ app.setJobType(JobTypeType.MPI);
+ }
+ else {
+ app.setJobType(JobTypeType.OPEN_MP);
+ }
+
+ app.setNodeCount(1);
+ app.setProcessorsPerNode(1);
+
+ /*
+ * Use bat file if it is compiled on Windows
+ */
+ app.setExecutableLocation("/bin/cat");
+
+ /*
+ * Default tmp location
+ */
+ String date = (new Date()).toString();
+ date = date.replaceAll(" ", "_");
+ date = date.replaceAll(":", "_");
+
+ String remoteTempDir = scratchDir + File.separator + "SimpleEcho" + "_" + date + "_"
+ + UUID.randomUUID();
+
+ System.out.println(remoteTempDir);
+
+ // no need of these parameters, as unicore manages by itself
+ app.setScratchWorkingDirectory(remoteTempDir);
+ app.setStaticWorkingDirectory(remoteTempDir);
+ app.setInputDataDirectory(remoteTempDir + File.separator + "inputData");
+ app.setOutputDataDirectory(remoteTempDir + File.separator + "outputData");
+
+ if(setOuput) {
+ app.setStandardOutput(app.getOutputDataDirectory()+"/jsdl_stdout");
+ app.setStandardError(app.getOutputDataDirectory()+"/jsdl_stderr");
+ }
+ return appDesc;
+ }
+
+ protected HostDescription getHostDesc() {
+ HostDescription host = new HostDescription(UnicoreHostType.type);
+ host.getType().setHostAddress(hostAddress);
+ host.getType().setHostName(hostName);
+ ((UnicoreHostType) host.getType()).setUnicoreBESEndPointArray(hostArray);
+ ((UnicoreHostType) host.getType()).setGridFTPEndPointArray(new String[]{gridftpAddress});
+ return host;
+ }
+
+ protected ServiceDescription getServiceDesc() {
+ ServiceDescription serv = new ServiceDescription();
+ serv.getType().setName("SimpleCat");
+
+ List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+ InputParameterType input = InputParameterType.Factory.newInstance();
+ input.setParameterName("echo_input");
+ input.setParameterType(StringParameterType.Factory.newInstance());
+ inputList.add(input);
+ InputParameterType[] inputParamList = inputList
+ .toArray(new InputParameterType[inputList.size()]);
+
+ List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+ OutputParameterType output = OutputParameterType.Factory.newInstance();
+ output.setParameterName("echo_output");
+ output.setParameterType(StringParameterType.Factory.newInstance());
+ outputList.add(output);
+ OutputParameterType[] outputParamList = outputList
+ .toArray(new OutputParameterType[outputList.size()]);
+
+ serv.getType().setInputParametersArray(inputParamList);
+ serv.getType().setOutputParametersArray(outputParamList);
+
+
+ return serv;
+ }
+
+ protected MessageContext getInMessageContext() {
+ MessageContext inMessage = new MessageContext();
+
+ ActualParameter i1 = new ActualParameter();
+ i1.getType().changeType(URIParameterType.type);
+ ((URIParameterType)i1.getType()).setValue("file:///tmp/ifile1");
+ inMessage.addParameter("i1", i1);
+
+ ActualParameter i2 = new ActualParameter();
+ i2.getType().changeType(URIParameterType.type);
+ ((URIParameterType)i2.getType()).setValue("file:///tmp/ifile2");
+ inMessage.addParameter("i2", i2);
+
+ ActualParameter i3 = new ActualParameter();
+ i2.getType().changeType(URIParameterType.type);
+ ((URIParameterType)i2.getType()).setValue("///tmp/ifile2");
+ inMessage.addParameter("i3", i2);
+
+ ActualParameter simpleArg = new ActualParameter();
+ simpleArg.getType().changeType(StringParameterType.type);
+ ((StringParameterType)simpleArg.getType()).setValue("argument1");
+ inMessage.addParameter("a1", simpleArg);
+
+ ActualParameter nameValueArg = new ActualParameter();
+ nameValueArg.getType().changeType(StringParameterType.type);
+ ((StringParameterType)nameValueArg.getType()).setValue("name1=value1");
+ inMessage.addParameter("nameValueArg", nameValueArg);
+
+ ActualParameter echo_input = new ActualParameter();
+ ((StringParameterType) echo_input.getType())
+ .setValue("echo_output=hello");
+ inMessage.addParameter("echo_input", echo_input);
+
+ return inMessage;
+ }
+
+ protected MessageContext getOutMessageContext() {
+ MessageContext om1 = new MessageContext();
+
+ // TODO: Aint the output parameters are only the name of the files staged out to the gridftp endpoint?
+ ActualParameter o1 = new ActualParameter();
+ ((StringParameterType) o1.getType())
+ .setValue("tempfile");
+ om1.addParameter("o1", o1);
+
+ ActualParameter o2 = new ActualParameter();
+ o2.getType().changeType(URIParameterType.type);
+
+ ((URIParameterType)o2.getType()).setValue("http://path/to/upload");
+ om1.addParameter("o2", o2);
+
+
+
+ return om1;
+ }
+
+ @Before
+ public void initJobContext() throws Exception {
+ PropertyConfigurator.configure("src/test/resources/logging.properties");
+ jobExecutionContext = new JobExecutionContext(getGFACConfig(), getServiceDesc().getType().getName());
+ jobExecutionContext.setApplicationContext(getApplicationContext());
+ jobExecutionContext.setInMessageContext(getInMessageContext());
+ jobExecutionContext.setOutMessageContext(getOutMessageContext());
+ }
+
+
+}