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:27 UTC
[2/2] git commit: new files
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());
+ }
+
+
+}