http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/schema/StorageShareCapacity.json ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/schema/StorageShareCapacity.json b/modules/gfac/gfac-impl/src/main/resources/schema/StorageShareCapacity.json new file mode 100644 index 0000000..f392c94 --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/schema/StorageShareCapacity.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageShareCapacity.json", + "type": "object", + "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}], + "properties": { + "Type": { + "type": "string", + "description": "The type of storage capacity - StorageCapacity_t" + }, + "TotalSize": { + "type": "integer", + "description": "The total amount of storage (GB)" + }, + "FreeSize": { + "type": "integer", + "description": "The amount of available storage (GB)" + }, + "UsedSize": { + "type": "integer", + "description": "The amount of used storage (GB)" + }, + "ReservedSize": { + "type": "integer", + "description": "The amount storage which is not occupied, but has been reserved for use (GB)" + }, + "StorageShareID": { + "type": "string", + "description": "The ID of the StorageShare related to this capacity" + } + }, + "required": ["Type","StorageShareID"] +}
http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/schema/ToComputingService.json ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/schema/ToComputingService.json b/modules/gfac/gfac-impl/src/main/resources/schema/ToComputingService.json new file mode 100644 index 0000000..6d81b80 --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/schema/ToComputingService.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ToComputingService.json", + "type": "object", + "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}], + "properties": { + "NetworkInfo": { + "type": "string", + "description": "Type of network connections between the Storage and Computing services (NetworkInfo_t)" + }, + "Bandwidth": { + "type": "integer", + "description": "The normal bandwidth available between the Storage and Computing services (Mb/s)" + }, + "StorageAccessProtocolID": { + "type": "array", + "description": "IDs of the protocols that can be used to access the StorageService", + "items": { + "type": "string" + } + }, + "ComputingServiceID": { + "type": "string", + "description": "The ID of the ComputingService" + }, + "StorageServiceID": { + "type": "string", + "description": "The ID of the StorageService" + } + }, + "required": ["ComputingServiceID","StorageServiceID"] +} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/schema/ToStorageService.json ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/schema/ToStorageService.json b/modules/gfac/gfac-impl/src/main/resources/schema/ToStorageService.json new file mode 100644 index 0000000..644f3d1 --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/schema/ToStorageService.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ToStorageService.json", + "type": "object", + "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}], + "properties": { + "LocalPath": { + "type": "string", + "description": "The path within the ComputingService that is used to access the StorageService" + }, + "RemotePath": { + "type": "string", + "description": "The path in the StorageService which is associated with the LocalPath" + }, + "ComputingServiceID": { + "type": "string", + "description": "The ID of the ComputingService" + }, + "StorageServiceID": { + "type": "string", + "description": "The ID of the StorageService" + } + }, + "required": ["LocalPath","RemotePath","ComputingServiceID","StorageServiceID"] +} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/schema/UserDomain.json ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/schema/UserDomain.json b/modules/gfac/gfac-impl/src/main/resources/schema/UserDomain.json new file mode 100644 index 0000000..7acda31 --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/schema/UserDomain.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/UserDomain.json", + "type": "object", + "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Domain.json"}], + "properties": { + "Level": { + "type": "integer", + "description": "the number of hops to reach the root of the hierarchy of UserDomains" + }, + "UserManagerID": { + "type": "array", + "description": "ID for the Endpoint of a Service managing users in this UserDomain", + "items": { + "type": "string" + } + }, + "Member": { + "type": "array", + "description": "Identifiers for users in this UserDomain", + "items": { + "type": "string" + } + }, + "PolicyID": { + "type": "array", + "description": "IDs for Policies associated with this UserDomain", + "items": { + "type": "string" + } + }, + "ChildDomainID": { + "type": "array", + "description": "IDs of UserDomains aggregated by this UserDomain", + "items": { + "type": "string" + } + }, + "ParentDomainID": { + "type": "string", + "description": "The ID of the UserDomain that this UserDomain participates in" + }, + "AccessPolicyID": { + "type": "array", + "description": "IDs of AccessPolicies associated with this UserDomain", + "items": { + "type": "string" + } + }, + "MappingPolicyID": { + "type": "array", + "description": "IDs of MappingPolicies associated with this UserDomain", + "items": { + "type": "string" + } + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/schemas/PBSJobDescriptor.xsd ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/schemas/PBSJobDescriptor.xsd b/modules/gfac/gfac-impl/src/main/resources/schemas/PBSJobDescriptor.xsd new file mode 100644 index 0000000..d5c5992 --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/schemas/PBSJobDescriptor.xsd @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--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. --> + +<schema targetNamespace="http://airavata.apache.org/gsi/ssh/2012/12" xmlns:gsissh="http://airavata.apache.org/gsi/ssh/2012/12" + xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> + + <element name="JobDescriptor" type="gsissh:pbsParams" /> + + <complexType name="pbsParams"> + <sequence> + <element name="jobID" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="userName" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="shellName" type="xsd:string" minOccurs="0" maxOccurs="1" default="/bin/bash"/> + <element name="queueName" type="xsd:string" minOccurs="0" maxOccurs="1" default="normal"/> + <element name="jobName" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="allEnvExport" type="xsd:boolean" minOccurs="0 " maxOccurs="1" default="true"/> + <element name="mailOptions" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="mailAddress" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="partition" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="mailType" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="acountString" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="maxWallTime" type="xsd:string" minOccurs="0" maxOccurs="1" default="1:00:00"/> + <element name="standardOutFile" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="standardErrorFile" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="outputDirectory" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="inputDirectory" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="nodes" type="xsd:int" minOccurs="0" maxOccurs="1" default="1"/> + <element name="processesPerNode" type="xsd:int" minOccurs="0" maxOccurs="1" default="1" /> + <element name="cpuCount" type="xsd:int" minOccurs="0" maxOccurs="1" default="1" /> + <element name="nodeList" type="xsd:string" minOccurs="0" maxOccurs="1" default="1" /> + <element name="workingDirectory" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="executablePath" type="xsd:string" minOccurs="0" maxOccurs="1" /> + <element name="inputs" type="gsissh:inputList" minOccurs="1" maxOccurs="1"/> + <element name="exports" type="gsissh:exportProperties" minOccurs="1" maxOccurs="1"/> + <element name="status" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="afterAny" type="gsissh:afterAnyList" minOccurs="0" maxOccurs="1"/> + <element name="afterOKList" type="gsissh:afterOKList" minOccurs="0" maxOccurs="1"/> + <element name="cTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="qTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="mTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="sTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="compTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="owner" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="executeNode" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="ellapsedTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="usedCPUTime" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="usedMem" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="submitArgs" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="variableList" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="preJobCommands" type="gsissh:preJobCommands" minOccurs="0" maxOccurs="1"/> + <element name="moduleLoadCommands" type="gsissh:moduleLoadCommands" minOccurs="0" maxOccurs="1"/> + <element name="postJobCommands" type="gsissh:postJobCommands" minOccurs="0" maxOccurs="1"/> + <element name="jobSubmitterCommand" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="callBackIp" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="callBackPort" type="xsd:string" minOccurs="0" maxOccurs="1"/> + <element name="chassisName" type="xsd:string" minOccurs="0" maxOccurs="1"/> + </sequence> + </complexType> + + <complexType name="moduleLoadCommands"> + <sequence> + <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </complexType> + <complexType name="preJobCommands"> + <sequence> + <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </complexType> + + <complexType name="postJobCommands"> + <sequence> + <element name="command" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </complexType> + <complexType name="inputList"> + <sequence> + <element name="input" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </complexType> + <complexType name="afterAnyList"> + <sequence> + <element name="afterAny" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </complexType> + + <complexType name="afterOKList"> + <sequence> + <element name="afterOKList" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> + </sequence> + </complexType> + + <complexType name="exportProperties"> + <sequence> + + <element name="name" minOccurs="1" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="xsd:string"> + <attribute name="value" type="xsd:string" use="required" /> + </extension> + </simpleContent> + </complexType> + </element> + + </sequence> + </complexType> +</schema> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/schemas/gsissh-schemas.xsdconfig ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/schemas/gsissh-schemas.xsdconfig b/modules/gfac/gfac-impl/src/main/resources/schemas/gsissh-schemas.xsdconfig new file mode 100644 index 0000000..a46cadc --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/schemas/gsissh-schemas.xsdconfig @@ -0,0 +1,14 @@ +<!--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. --> + +<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config"> + + <xb:namespace uri="http://airavata.apache.org/schemas/gsi/ssh/2012/12"> + <xb:package>org.apache.airavata.gfac.ssh</xb:package> + </xb:namespace> +</xb:config> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/main/resources/service.properties ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/resources/service.properties b/modules/gfac/gfac-impl/src/main/resources/service.properties new file mode 100644 index 0000000..391bfea --- /dev/null +++ b/modules/gfac/gfac-impl/src/main/resources/service.properties @@ -0,0 +1,58 @@ +# +# +# 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. +# +# + + +# +# Class which implemented Scheduler interface. It will be used to determine a Provider +# +scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl + +# +# Data Service Plugins classes +# +datachain.classes= org.apache.airavata.core.gfac.extension.data.RegistryDataService + +# +# Pre execution Plugins classes. For example, GridFTP Input Staging +# +prechain.classes= org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging +prechain.classes= org.apache.airavata.core.gfac.extension.pre.HttpInputStaging + +# +# Post execution Plugins classes. For example, GridFTP Output Staging +# +postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging +postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister + +# +# SSH private key location. It will be used by SSHProvider +# +# ssh.key=/home/user/.ssh/id_rsa +# ssh.keypass= +# ssh.username=usernameAtHost + +# +# MyProxy credential. It will be used by GridFTP Plugins and GramProvider. +# +# myproxy.server=myproxy.teragrid.org +# myproxy.user=username +# myproxy.pass=password +# myproxy.life=3600 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java new file mode 100644 index 0000000..73a6e4a --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2TestWithSSHAuth.java @@ -0,0 +1,252 @@ +///* +// * +// * 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.core.context.ApplicationContext; +//import org.apache.airavata.gfac.core.context.JobExecutionContext; +//import org.apache.airavata.gfac.core.context.MessageContext; +//import org.apache.airavata.gfac.impl.BetterGfacImpl; +//import org.apache.airavata.gfac.ssh.security.SSHSecurityContext; +//import org.apache.airavata.gfac.ssh.api.Cluster; +//import org.apache.airavata.gfac.ssh.api.SSHApiException; +//import org.apache.airavata.gfac.ssh.api.ServerInfo; +//import AuthenticationInfo; +//import org.apache.airavata.gfac.ssh.api.job.JobManagerConfiguration; +//import org.apache.airavata.gfac.ssh.impl.PBSCluster; +//import org.apache.airavata.gfac.ssh.impl.authentication.DefaultPasswordAuthenticationInfo; +//import org.apache.airavata.gfac.ssh.impl.authentication.DefaultPublicKeyFileAuthentication; +//import org.apache.airavata.gfac.ssh.util.CommonUtils; +//import org.apache.airavata.model.workspace.experiment.TaskDetails; +//import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; +//import org.apache.airavata.schemas.gfac.*; +//import org.testng.annotations.BeforeClass; +//import org.testng.annotations.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 String userName; +// private String password; +// private String passPhrase; +// private String hostName; +// private String workingDirectory; +// private String privateKeyPath; +// private String publicKeyPath; +// +// @BeforeClass +// public void setUp() throws Exception { +// +// System.out.println("Test case name " + this.getClass().getName()); +//// System.setProperty("ssh.host","bigred2.uits.iu.edu"); //default ssh host +//// System.setProperty("ssh.user", "lginnali"); +//// System.setProperty("ssh.private.key.path", "/Users/lahirugunathilake/.ssh/id_dsa"); +//// System.setProperty("ssh.public.key.path", "/Users/lahirugunathilake/.ssh/id_dsa.pub"); +//// System.setProperty("ssh.working.directory", "/tmp"); +// +// this.hostName = "bigred2.uits.iu.edu"; +// this.hostName = System.getProperty("ssh.host"); +// this.userName = System.getProperty("ssh.username"); +// this.password = System.getProperty("ssh.password"); +// this.privateKeyPath = System.getProperty("private.ssh.key"); +// this.publicKeyPath = System.getProperty("public.ssh.key"); +// this.passPhrase = System.getProperty("ssh.keypass"); +// this.workingDirectory = System.getProperty("ssh.working.directory"); +// +// +// if (this.userName == null +// || (this.password==null && (this.publicKeyPath == null || this.privateKeyPath == null)) || this.workingDirectory == null) { +// System.out.println("########### In order to test you have to either username password or private,public keys"); +// System.out.println("Use -Dssh.username=xxx -Dssh.password=yyy -Dssh.keypass=zzz " + +// "-Dprivate.ssh.key -Dpublic.ssh.key -Dssh.working.directory "); +// } +// URL resource = BigRed2TestWithSSHAuth.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); +// +//// 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(hostName); +// 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 = "/tmp"; +// 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.setRegistry(RegistryFactory.getLoggingRegistry()); +// jobExecutionContext.setTaskData(new TaskDetails("11323")); +// jobExecutionContext.setOutMessageContext(outMessage); +// +// } +// +// +// private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) { +// try { +// +// AuthenticationInfo authenticationInfo = null; +// if (password != null) { +// authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password); +// } else { +// authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath, +// this.passPhrase); +// } +// // Server info +// ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName); +// +// Cluster pbsCluster = null; +// SSHSecurityContext sshSecurityContext = null; +// +// JobManagerConfiguration pbsJobManager = CommonUtils.getPBSJobManager(app.getInstalledParentPath()); +// pbsCluster = new PBSCluster(serverInfo, authenticationInfo, pbsJobManager); +// +// +// sshSecurityContext = new SSHSecurityContext(); +// sshSecurityContext.setPbsCluster(pbsCluster); +// sshSecurityContext.setUsername(userName); +// sshSecurityContext.setKeyPass(passPhrase); +// sshSecurityContext.setPrivateKeyLoc(privateKeyPath); +// return sshSecurityContext; +// } catch (SSHApiException e) { +// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. +// } +// return null; +// } +// +// @Test +// public void testSSHProvider() throws GFacException { +// BetterGfacImpl gFacAPI = new BetterGfacImpl(); +// gFacAPI.submitJob(jobExecutionContext.getExperimentID(), jobExecutionContext.getTaskData().getTaskID(), jobExecutionContext.getGatewayID()); +// org.junit.Assert.assertNotNull(jobExecutionContext.getJobDetails().getJobDescription()); +// org.junit.Assert.assertNotNull(jobExecutionContext.getJobDetails().getJobID()); +// } +// +//} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java new file mode 100644 index 0000000..28b1047 --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/CredentialStoreTest.java @@ -0,0 +1,135 @@ +///* +// * +// * 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.client.AiravataAPIFactory; +//import org.apache.airavata.client.api.AiravataAPI; +//import org.apache.airavata.client.api.exception.AiravataAPIInvocationException; +//import org.apache.airavata.common.exception.AiravataConfigurationException; +//import org.apache.airavata.common.exception.ApplicationSettingsException; +//import org.apache.airavata.common.utils.ClientSettings; +//import org.apache.airavata.common.utils.DBUtil; +//import org.apache.airavata.common.utils.ServerSettings; +//import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential; +//import org.apache.airavata.credential.store.store.CredentialReader; +//import org.apache.airavata.credential.store.store.impl.CredentialReaderImpl; +//import org.apache.airavata.gfac.GFacException; +//import org.apache.airavata.gfac.RequestData; +//import org.apache.airavata.gfac.ssh.security.TokenizedSSHAuthInfo; +//import org.apache.airavata.gfac.ssh.api.SSHApiException; +//import org.apache.airavata.gfac.ssh.api.ServerInfo; +//import org.apache.airavata.gfac.ssh.impl.PBSCluster; +//import org.apache.airavata.gfac.ssh.util.CommonUtils; +//import org.apache.airavata.registry.api.AiravataRegistry2; +//import org.apache.airavata.registry.api.AiravataRegistryFactory; +//import org.apache.airavata.registry.api.AiravataUser; +//import org.apache.airavata.registry.api.Gateway; +//import org.apache.airavata.registry.api.exception.RegAccessorInstantiateException; +//import org.apache.airavata.registry.api.exception.RegAccessorInvalidException; +//import org.apache.airavata.registry.api.exception.RegAccessorUndefinedException; +//import org.apache.airavata.registry.api.exception.RegException; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.testng.annotations.BeforeTest; +//import org.testng.annotations.Test; +// +//import java.util.UUID; +// +//public class CredentialStoreTest { +// private final static Logger logger = LoggerFactory.getLogger(CredentialStoreTest.class); +// +// @BeforeTest +// public void testGSISSHProvider() throws GFacException, IllegalAccessException, ClassNotFoundException, InstantiationException, ApplicationSettingsException, SSHApiException { +// System.setProperty("credential.store.keystore.url", "/Users/lahirugunathilake/Downloads/airavata_sym.jks"); +// System.setProperty("credential.store.keystore.alias", "airavata"); +// System.setProperty("credential.store.keystore.password", "airavata"); +// System.setProperty("myproxy.username", "ogce"); +// System.setProperty("myproxy.password", ""); +// System.setProperty("trusted.cert.location", "/Users/lahirugunathilake/Downloads/certificates"); +// System.setProperty("credential.store.jdbc.url","jdbc:mysql://gw85.iu.xsede.org:3306/airavata_gta_prod"); +// System.setProperty("credential.store.jdbc.user","gtaAiravataUser"); +// System.setProperty("credential.store.jdbc.password","gtaAiravataPWD"); +// System.setProperty("credential.store.jdbc.driver","com.mysql.jdbc.Driver"); +// +// +// +// UUID uuid = UUID.randomUUID(); +// System.out.println("TokenId: " + uuid.toString()); +//// String publicKey = registry.createCredential("default",uuid.toString(),"lginnali" ); +//// System.out.println("Public-Key: " +publicKey); +//// String tokenId = uuid.toString(); +// String tokenId = "2c308fa9-99f8-4baa-92e4-d062e311483c"; +// CredentialReader credentialReader = new CredentialReaderImpl(new DBUtil("jdbc:mysql://gw85.iu.xsede.org:3306/airavata_gta_prod", +// "ptaAiravataUser", "ptaAiravataPWD", "com.mysql.jdbc.Driver")); +// +// +// RequestData requestData = new RequestData(); +// requestData.setMyProxyUserName("cgateway"); +// requestData.setTokenId(tokenId); +// requestData.setGatewayId("default"); +// TokenizedSSHAuthInfo tokenizedSSHAuthInfo = new TokenizedSSHAuthInfo(credentialReader, requestData); +// +// SSHCredential credentials = tokenizedSSHAuthInfo.getCredentials(); +// ServerInfo serverInfo = new ServerInfo("cgateway", "bigred2.uits.iu.edu"); +// +// PBSCluster pbsCluster = new PBSCluster(serverInfo, tokenizedSSHAuthInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/")); +// Assert.assertNotNull(pbsCluster); +// return; +// +// } +// +// @Test +// public static void main(String[] args) { +// try { +// new CredentialStoreTest().testGSISSHProvider(); +// } catch (GFacException e) { +// e.printStackTrace(); +// } catch (IllegalAccessException e) { +// e.printStackTrace(); +// } catch (ClassNotFoundException e) { +// e.printStackTrace(); +// } catch (InstantiationException e) { +// e.printStackTrace(); +// } catch (ApplicationSettingsException e) { +// e.printStackTrace(); +// } catch (SSHApiException e) { +// e.printStackTrace(); +// } +// } +// +// private static AiravataAPI getAiravataAPI() throws AiravataAPIInvocationException, ApplicationSettingsException { +// AiravataAPI airavataAPI; +// try { +// String sysUser = ClientSettings.getSetting("admin"); +// String gateway = ClientSettings.getSetting("default"); +// airavataAPI = AiravataAPIFactory.getAPI(gateway, sysUser); +// } catch (AiravataAPIInvocationException e) { +// logger.error("Unable to create airavata API", e.getMessage()); +// throw new AiravataAPIInvocationException(e); +// } catch (ApplicationSettingsException e) { +// logger.error("Unable to create airavata API", e.getMessage()); +// throw new ApplicationSettingsException(e.getMessage()); +// } +// return airavataAPI; +// } +// +//} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java new file mode 100644 index 0000000..9e03173 --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTestWithMyProxyAuth.java @@ -0,0 +1,229 @@ +///* +// * +// * 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.aiaravata.application.catalog.data.model.ApplicationInterface; +//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.core.context.ApplicationContext; +//import org.apache.airavata.gfac.core.context.JobExecutionContext; +//import org.apache.airavata.gfac.core.context.MessageContext; +//import org.apache.airavata.gfac.impl.BetterGfacImpl; +//import org.apache.airavata.gfac.gsissh.security.GSISecurityContext; +//import org.apache.airavata.gfac.ssh.api.Cluster; +//import org.apache.airavata.gfac.ssh.api.SSHApiException; +//import org.apache.airavata.gfac.ssh.api.ServerInfo; +//import GSIAuthenticationInfo; +//import org.apache.airavata.gfac.ssh.impl.PBSCluster; +//import org.apache.airavata.gfac.ssh.impl.authentication.MyProxyAuthenticationInfo; +//import org.apache.airavata.gfac.ssh.util.CommonUtils; +//import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription; +//import org.apache.airavata.model.workspace.experiment.TaskDetails; +//import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; +//import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType; +//import org.apache.airavata.schemas.gfac.GsisshHostType; +//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.testng.annotations.BeforeClass; +//import org.testng.annotations.Test; +// +//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 String myProxyUserName; +// private String myProxyPassword; +// private String workingDirectory; +// private String certificateLocation = "/Users/lahirugunathilake/Downloads/certificates"; +// +// @BeforeClass +// 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"); +//// System.setProperty("gsi.certificate.path", "/Users/lahirugunathilake/Downloads/certificates"); +// certificateLocation = System.getProperty("trusted.cert.location"); +// myProxyUserName = System.getProperty("myproxy.username"); +// myProxyPassword = System.getProperty("myproxy.password"); +// workingDirectory = System.getProperty("gsi.working.directory"); +// +// if (myProxyUserName == null || myProxyPassword == null || certificateLocation == null) { +// System.out.println(">>>>>> Please run tests with my proxy user name and password. " + +// "E.g :- mvn clean install -Dmyproxy.username=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<"); +// throw new Exception("Need my proxy user name password to run tests."); +// } +// 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); +// +// /* +// * 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 = workingDirectory + 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(GSISecurityContext.GSI_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.setRegistry(RegistryFactory.getLoggingRegistry()); +// jobExecutionContext.setTaskData(new TaskDetails("11323")); +// 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 testGSISSHProvider() throws GFacException { +// BetterGfacImpl gFacAPI = new BetterGfacImpl(); +// gFacAPI.submitJob(jobExecutionContext.getExperimentID(), jobExecutionContext.getTaskData().getTaskID(), jobExecutionContext.getGatewayID()); +// System.out.println(jobExecutionContext.getJobDetails().getJobDescription()); +// System.out.println(jobExecutionContext.getJobDetails().getJobID()); +// } +// +//} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java new file mode 100644 index 0000000..aeb8158 --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java @@ -0,0 +1,184 @@ +///* +// * +// * 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.List; +// +//import org.apache.airavata.common.utils.MonitorPublisher; +//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.core.context.ApplicationContext; +//import org.apache.airavata.gfac.core.context.JobExecutionContext; +//import org.apache.airavata.gfac.core.context.MessageContext; +//import org.apache.airavata.gfac.core.provider.GFacProviderException; +//import org.apache.airavata.gfac.local.handler.LocalDirectorySetupHandler; +//import org.apache.airavata.gfac.local.provider.impl.LocalProvider; +//import org.apache.airavata.model.workspace.experiment.ExecutionUnit; +//import org.apache.airavata.model.workspace.experiment.Experiment; +//import org.apache.airavata.model.workspace.experiment.TaskDetails; +//import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails; +//import org.apache.airavata.persistance.registry.jpa.impl.LoggingRegistryImpl; +//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.StringParameterType; +//import org.apache.commons.lang.SystemUtils; +//import org.testng.annotations.BeforeTest; +//import org.testng.annotations.Test; +// +//import com.google.common.eventbus.EventBus; +// +//public class LocalProviderTest { +// private JobExecutionContext jobExecutionContext; +// @BeforeTest +// public void setUp() throws Exception { +// +// URL resource = this.getClass().getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML); +// File configFile = new File(resource.getPath()); +// GFacConfiguration gFacConfiguration = GFacConfiguration.create(configFile, null); +// //have to set InFlwo Handlers and outFlowHandlers +// ApplicationContext applicationContext = new ApplicationContext(); +// HostDescription host = new HostDescription(); +// host.getType().setHostName("localhost"); +// host.getType().setHostAddress("localhost"); +// applicationContext.setHostDescription(host); +// /* +// * App +// */ +// ApplicationDescription appDesc = new ApplicationDescription(); +// ApplicationDeploymentDescriptionType app = appDesc.getType(); +// ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance(); +// name.setStringValue("EchoLocal"); +// 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"); +// } +// +// /* +// * Default tmp location +// */ +// String tempDir = System.getProperty("java.io.tmpdir"); +// if (tempDir == null) { +// tempDir = "/tmp"; +// } +// +// 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("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()); +// jobExecutionContext.setApplicationContext(applicationContext); +// /* +// * 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(); +// outMessage.addParameter("echo_output", echo_out); +// +// jobExecutionContext.setOutMessageContext(outMessage); +// +// jobExecutionContext.setExperimentID("test123"); +// jobExecutionContext.setExperiment(new Experiment("test123","project1","admin","testExp")); +// jobExecutionContext.setTaskData(new TaskDetails(jobExecutionContext.getExperimentID())); +// jobExecutionContext.setRegistry(new LoggingRegistryImpl()); +// jobExecutionContext.setWorkflowNodeDetails(new WorkflowNodeDetails(jobExecutionContext.getExperimentID(),"none", ExecutionUnit.APPLICATION)); +// +// +// } +// +// @Test +// public void testLocalDirectorySetupHandler() throws GFacException { +// LocalDirectorySetupHandler localDirectorySetupHandler = new LocalDirectorySetupHandler(); +// localDirectorySetupHandler.invoke(jobExecutionContext); +// +// ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription(); +// ApplicationDeploymentDescriptionType app = applicationDeploymentDescription.getType(); +// junit.framework.Assert.assertTrue(new File(app.getStaticWorkingDirectory()).exists()); +// junit.framework.Assert.assertTrue(new File(app.getScratchWorkingDirectory()).exists()); +// junit.framework.Assert.assertTrue(new File(app.getInputDataDirectory()).exists()); +// junit.framework.Assert.assertTrue(new File(app.getOutputDataDirectory()).exists()); +// } +// +// @Test +// public void testLocalProvider() throws GFacException,GFacProviderException { +// LocalDirectorySetupHandler localDirectorySetupHandler = new LocalDirectorySetupHandler(); +// localDirectorySetupHandler.invoke(jobExecutionContext); +// LocalProvider localProvider = new LocalProvider(); +// localProvider.setMonitorPublisher(new MonitorPublisher(new EventBus())); +// localProvider.initialize(jobExecutionContext); +// localProvider.execute(jobExecutionContext); +// localProvider.dispose(jobExecutionContext); +// } +//} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/SSHProviderTestWithSSHAuth.java new file mode 100644 index 0000000..e16221c --- /dev/null +++ b/modules/gfac/gfac-impl/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.core.context.ApplicationContext; +//import org.apache.airavata.gfac.core.context.JobExecutionContext; +//import org.apache.airavata.gfac.core.context.MessageContext; +//import org.apache.airavata.gfac.impl.BetterGfacImpl; +//import org.apache.airavata.gfac.ssh.security.SSHSecurityContext; +//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 = SSHProviderTestWithSSHAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML); +// GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),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 { +// BetterGfacImpl gFacAPI = new BetterGfacImpl(); +// gFacAPI.submitJob(jobExecutionContext.getExperimentID(), jobExecutionContext.getTaskData().getTaskID(), jobExecutionContext.getGatewayID()); +// MessageContext outMessageContext = jobExecutionContext.getOutMessageContext(); +// Assert.assertEquals(MappingFactory.toString((ActualParameter)outMessageContext.getParameter("echo_output")), "hello"); +// } +//} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java new file mode 100644 index 0000000..9268d84 --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/core/gfac/services/impl/security/GSISecurityContextTestWithMyProxyAuth.java @@ -0,0 +1,163 @@ +/* + * + * 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.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.common.utils.ServerSettings; +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.airavata.gfac.gsissh.security.GSISecurityContext; +import org.apache.airavata.gfac.gsissh.security.TokenizedMyProxyAuthInfo; +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; + + +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 { + +// System.setProperty("myproxy.username", "ogce"); +// System.setProperty("myproxy.password", ""); + userName = System.getProperty("myproxy.username"); + password = System.getProperty("myproxy.password"); + System.setProperty("myproxy.server", "myproxy.teragrid.org"); + System.setProperty("myproxy.life", "3600"); + System.setProperty("credential.store.keystore.url", "../configuration/server/src/main/resources/airavata.jks"); + System.setProperty("credential.store.keystore.alias", "airavata"); + System.setProperty("credential.store.keystore.password", "airavata"); + + if (userName == null || password == null || userName.trim().equals("") || password.trim().equals("")) { + log.error("===== Please set myproxy.username 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_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(); + } + + private GSSCredential getGSSCredentials() throws Exception { + + TokenizedMyProxyAuthInfo gsiTokenizedMyProxyAuthInfo = getGSISecurityContext(); + return gsiTokenizedMyProxyAuthInfo.getCredentials(); + } + + private TokenizedMyProxyAuthInfo getGSISecurityContext() throws Exception { + + RequestData requestData = new RequestData(); + + requestData.setMyProxyUserName(userName); + requestData.setMyProxyPassword(password); + requestData.setMyProxyServerUrl(ServerSettings.getMyProxyServer()); + requestData.setMyProxyLifeTime(ServerSettings.getMyProxyLifetime()); + CredentialReader credentialReader = CredentialReaderFactory.createCredentialStoreReader(getDbUtil()); + + return new TokenizedMyProxyAuthInfo(requestData); + } + + @Test + public void testGetGssCredentials() throws Exception { + + Assert.assertNotNull(getGSSCredentials()); + } + /* + @Test + public void testRenewCredentials() throws Exception { + GSISecurityContext gsiSecurityContext = getGSISecurityContext(); + gsiSecurityContext.getGssCredentials(); + Assert.assertNotNull(gsiSecurityContext.renewCredentials()); + + } + + @Test + public void testGetCredentialsFromStore() throws Exception { + GSISecurityContext gsiSecurityContext = getGSISecurityContext(); + Assert.assertNotNull(gsiSecurityContext.getCredentialsFromStore()); + + } */ + + @Test + public void testGetDefaultCredentials() throws Exception { + TokenizedMyProxyAuthInfo gsiSecurityContext = getGSISecurityContext(); + Assert.assertNotNull(gsiSecurityContext.getDefaultCredentials()); + + } + + @Test + public void testGetProxyCredentials() throws Exception { + TokenizedMyProxyAuthInfo gsiSecurityContext = getGSISecurityContext(); + Assert.assertNotNull(gsiSecurityContext.getProxyCredentials()); + + } + /* + @Test + public void testRenewCredentialsAsATrustedHost() throws Exception { + GSISecurityContext gsiSecurityContext = getGSISecurityContext(); + gsiSecurityContext.getGssCredentials(); + Assert.assertNotNull(gsiSecurityContext.renewCredentialsAsATrustedHost()); + } */ + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java new file mode 100644 index 0000000..a90dcba --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/config/ConfigReaderTest.java @@ -0,0 +1,37 @@ +/* + * + * 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.ssh.config; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class ConfigReaderTest { + + @Test + public void testGetConfiguration() throws Exception { + + System.out.println("Test case name " + this.getClass().getName()); + ConfigReader configReader = new ConfigReader(); + Assert.assertEquals(configReader.getConfiguration("StrictHostKeyChecking"), "no"); + + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/7b809747/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java new file mode 100644 index 0000000..61a7437 --- /dev/null +++ b/modules/gfac/gfac-impl/src/test/java/org/apache/airavata/gfac/ssh/impl/DefaultSSHApiTestWithMyProxyAuth.java @@ -0,0 +1,77 @@ +/* + * + * 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.ssh.impl; + +import org.apache.airavata.gfac.ssh.api.*; +import org.apache.airavata.gfac.ssh.config.ConfigReader; +import org.apache.airavata.gfac.ssh.impl.authentication.DefaultPublicKeyAuthentication; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; + +public class DefaultSSHApiTestWithMyProxyAuth { + private static final Logger log = LoggerFactory.getLogger(PBSCluster.class); + + + + public void tearDown() throws Exception { + } + + + public static void main(String[]ars) throws IOException { + String myProxyUserName = "lg11w"; + +// DefaultPasswordAuthenticationInfo authenticationInfo +// = new DefaultPasswordAuthenticationInfo(""); + byte[] privateKey = IOUtils.toByteArray(new BufferedInputStream(new FileInputStream("/Users/lginnali/.ssh/id_dsa"))); + byte[] publicKey = IOUtils.toByteArray(new BufferedInputStream(new FileInputStream("/Users/lginnali/.ssh/id_dsa.pub"))); + DefaultPublicKeyAuthentication authenticationInfo = new DefaultPublicKeyAuthentication(privateKey,publicKey,""); + + // Create command + CommandInfo commandInfo = new RawCommandInfo("source /etc/bashrc; bsub </home/lg11w/mywork/sshEchoExperiment_9d267072-ca65-4ca8-847a-cd3d130f6050/366787899.lsf"); + + // Server info + //Stampede +// ServerInfo serverInfo = new ServerInfo(myProxyUserName, "stampede.tacc.utexas.edu", 2222); + //Trestles +// ServerInfo serverInfo = new ServerInfo(myProxyUserName, "trestles.sdsc.xsede.org", 22); + + //Lonestar + ServerInfo serverInfo = new ServerInfo(myProxyUserName, "ghpcc06.umassrc.org", 22); + // Output + CommandOutput commandOutput = new SystemCommandOutput(); + + // Execute command + try { + CommandExecutor.executeCommand(commandInfo, serverInfo, authenticationInfo, commandOutput, new ConfigReader()); + } catch (SSHApiException e) { + log.error(e.getMessage(), e); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + + + +}
