You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2017/01/27 20:41:18 UTC
[02/11] airavata git commit:
modules/test-suite/multi-tenanted-airavata/src/main/resources/airavata-server-stop.sh
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/ExperimentExecution.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/ExperimentExecution.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/ExperimentExecution.java
index 1e6edd8..85212bd 100644
--- a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/ExperimentExecution.java
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/ExperimentExecution.java
@@ -22,11 +22,9 @@
package org.apache.airavata.testsuite.multitenantedairavata;
import org.apache.airavata.api.Airavata;
+import org.apache.airavata.common.logging.MDCConstants;
import org.apache.airavata.common.utils.ThriftUtils;
-import org.apache.airavata.messaging.core.MessageContext;
-import org.apache.airavata.messaging.core.MessagingFactory;
-import org.apache.airavata.messaging.core.Subscriber;
-import org.apache.airavata.messaging.core.Type;
+import org.apache.airavata.messaging.core.*;
import org.apache.airavata.model.application.io.InputDataObjectType;
import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.model.commons.ErrorModel;
@@ -41,6 +39,7 @@ import org.apache.airavata.model.messaging.event.MessageType;
import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
import org.apache.airavata.model.security.AuthzToken;
import org.apache.airavata.model.status.ExperimentState;
+import org.apache.airavata.model.status.ExperimentStatus;
import org.apache.airavata.model.util.ExperimentModelUtil;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.testsuite.multitenantedairavata.utils.FrameworkUtils;
@@ -51,16 +50,16 @@ import org.apache.thrift.TBase;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import java.io.File;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
+import static org.apache.airavata.testsuite.multitenantedairavata.utils.TestFrameworkConstants.LocalEchoProperties.LOCAL_ECHO_EXPERIMENT_INPUT;
+import static org.apache.airavata.testsuite.multitenantedairavata.utils.TestFrameworkConstants.LocalEchoProperties.LocalApplication.INPUT_NAME;
public class ExperimentExecution {
private Airavata.Client airavata;
@@ -73,7 +72,6 @@ public class ExperimentExecution {
private PropertyReader propertyReader;
private PrintWriter resultWriter;
private String testUser;
- private List<String> gatewaysToAvoid;
private TestFrameworkProps properties;
private AuthzToken authzToken;
@@ -83,12 +81,14 @@ public class ExperimentExecution {
this.airavata = airavata;
this.csTokens = tokenMap;
authzToken = new AuthzToken("emptyToken");
+ authzToken.setClaimsMap(new HashMap<>());
this.appInterfaceMap = getApplicationMap(tokenMap);
this.propertyReader = new PropertyReader();
this.properties = props;
+ authzToken.getClaimsMap().put(org.apache.airavata.common.utils.Constants.USER_NAME, props.getTestUserName());
+ authzToken.getClaimsMap().put(org.apache.airavata.common.utils.Constants.GATEWAY_ID, props.getGname());
FrameworkUtils frameworkUtils = FrameworkUtils.getInstance();
testUser = props.getTestUserName();
- gatewaysToAvoid = frameworkUtils.getGatewayListToAvoid(properties.getSkippedGateways());
this.projectsMap = getProjects(tokenMap);
this.experimentsWithTokens = new HashMap<String, String>();
this.experimentsWithGateway = new HashMap<String, String>();
@@ -143,17 +143,10 @@ public class ExperimentExecution {
try {
if (tokenMap != null && !tokenMap.isEmpty()) {
for (String gatewayId : tokenMap.keySet()) {
- boolean isgatewayValid = true;
- for (String ovoidGateway : gatewaysToAvoid) {
- if (gatewayId.equals(ovoidGateway)) {
- isgatewayValid = false;
- break;
- }
- }
- if (isgatewayValid) {
- List<Project> allUserProjects = airavata.getUserProjects(authzToken, gatewayId, testUser, 5, 0);
- projectsMap.put(gatewayId, allUserProjects);
- }
+
+ List<Project> allUserProjects = airavata.getUserProjects(authzToken, gatewayId, testUser, 5, 0);
+ projectsMap.put(gatewayId, allUserProjects);
+
}
}
} catch (AiravataSystemException e) {
@@ -172,11 +165,11 @@ public class ExperimentExecution {
return projectsMap;
}
- public void launchExperiments() throws Exception {
+
+ public void launchExperiments(String gatewayId, String experimentId) throws Exception {
try {
- for (String expId : experimentsWithTokens.keySet()) {
- airavata.launchExperiment(authzToken, expId, experimentsWithTokens.get(expId));
- }
+ airavata.launchExperiment(authzToken, experimentId, gatewayId);
+
} catch (Exception e) {
logger.error("Error while launching experiment", e);
throw new Exception("Error while launching experiment", e);
@@ -185,10 +178,12 @@ public class ExperimentExecution {
public void monitorExperiments() throws Exception {
- String brokerUrl = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.RABBIT_BROKER_URL, PropertyFileType.AIRAVATA_CLIENT);
+ String brokerUrl = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.RABBIT_BROKER_URL, PropertyFileType.AIRAVATA_SERVER);
System.out.println("broker url " + brokerUrl);
- final String exchangeName = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.RABBIT_EXCHANGE_NAME, PropertyFileType.AIRAVATA_CLIENT);
- Subscriber statusSubscriber = MessagingFactory.getSubscriber(this::processMessage, null, Type.STATUS);
+ final String exchangeName = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.RABBIT_EXCHANGE_NAME, PropertyFileType.AIRAVATA_SERVER);
+ //Subscriber statusSubscriber = MessagingFactory.getSubscriber(this::processMessage, getRoutingKeys(), Type.STATUS);
+ Subscriber statusSubscriber = MessagingFactory.getSubscriber(new ExperimentHandler(), getRoutingKeys(), Type.STATUS);
+
}
private List<String> getRoutingKeys() {
@@ -205,6 +200,79 @@ public class ExperimentExecution {
return routingKeys;
}
+ private class ExperimentHandler implements MessageHandler {
+
+ @Override
+ public void onMessage(MessageContext messageContext) {
+ MDC.put(MDCConstants.GATEWAY_ID, messageContext.getGatewayId());
+ if (messageContext.getType().equals(MessageType.EXPERIMENT)) {
+ try {
+ ExperimentStatusChangeEvent event = new ExperimentStatusChangeEvent();
+ TBase messageEvent = messageContext.getEvent();
+ byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
+ ThriftUtils.createThriftFromBytes(bytes, event);
+ ExperimentState expState = event.getState();
+ String expId = event.getExperimentId();
+ String gatewayId = event.getGatewayId();
+
+ if (expState.equals(ExperimentState.COMPLETED)) {
+ resultWriter.println("Results for experiment : " + expId + " of gateway Id : " + gatewayId);
+ resultWriter.println("=====================================================================");
+ resultWriter.println("Status : " + ExperimentState.COMPLETED.toString());
+ // check file transfers
+ List<OutputDataObjectType> experimentOutputs = airavata.getExperimentOutputs(authzToken, expId);
+ int i = 1;
+ for (OutputDataObjectType output : experimentOutputs) {
+ System.out.println("################ Experiment : " + expId + " COMPLETES ###################");
+ System.out.println("Output " + i + " : " + output.getValue());
+ resultWriter.println("Output " + i + " : " + output.getValue());
+ i++;
+ }
+ resultWriter.println("End of Results for Experiment : " + expId);
+ resultWriter.println("=====================================================================");
+ } else if (expState.equals(ExperimentState.FAILED)) {
+ resultWriter.println("Results for experiment : " + expId + " of gateway Id : " + gatewayId);
+ resultWriter.println("=====================================================================");
+ int j = 1;
+ resultWriter.println("Status : " + ExperimentState.FAILED.toString());
+ System.out.println("################ Experiment : " + expId + " FAILED ###################");
+ ExperimentModel experiment = airavata.getExperiment(authzToken, expId);
+ List<ErrorModel> errors = experiment.getErrors();
+ if (errors != null && !errors.isEmpty()) {
+ for (ErrorModel errorDetails : errors) {
+ System.out.println(errorDetails.getActualErrorMessage());
+ resultWriter.println("Actual Error : " + j + " : " + errorDetails.getActualErrorMessage());
+ resultWriter.println("User Friendly Message : " + j + " : " + errorDetails.getUserFriendlyMessage());
+ }
+ }
+
+ resultWriter.println("End of Results for Experiment : " + expId);
+ resultWriter.println("=====================================================================");
+ }
+ } catch (TException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ resultWriter.flush();
+ MDC.clear();
+ }
+
+ private void cancelExperiment(MessageContext messageContext) {
+// try {
+// byte[] bytes = ThriftUtils.serializeThriftObject(messageContext.getEvent());
+// ExperimentSubmitEvent expEvent = new ExperimentSubmitEvent();
+// ThriftUtils.createThriftFromBytes(bytes, expEvent);
+// log.info("Cancelling experiment with experimentId: {} gateway Id: {}", expEvent.getExperimentId(), expEvent.getGatewayId());
+// terminateExperiment(expEvent.getExperimentId(), expEvent.getGatewayId());
+// } catch (TException e) {
+// log.error("Experiment cancellation failed due to Thrift conversion error", e);
+// }finally {
+// experimentSubscriber.sendAck(messageContext.getDeliveryTag());
+// }
+
+ }
+ }
+
private void processMessage(MessageContext message) {
if (message.getType().equals(MessageType.EXPERIMENT)) {
try {
@@ -250,9 +318,6 @@ public class ExperimentExecution {
resultWriter.println("End of Results for Experiment : " + expId);
resultWriter.println("=====================================================================");
}
-// System.out.println(" Experiment Id : '" + expId
-// + "' with state : '" + event.getState().toString() +
-// " for Gateway " + event.getGatewayId());
} catch (TException e) {
logger.error(e.getMessage(), e);
}
@@ -262,10 +327,6 @@ public class ExperimentExecution {
TBase messageEvent = message.getEvent();
byte[] bytes = ThriftUtils.serializeThriftObject(messageEvent);
ThriftUtils.createThriftFromBytes(bytes, event);
-// System.out.println(" Job ID : '" + event.getJobIdentity().getJobId()
-// + "' with state : '" + event.getState().toString() +
-// " for Gateway " + event.getJobIdentity().getGatewayId());
-// resultWriter.println("Job Status : " + event.getState().toString());
} catch (TException e) {
logger.error(e.getMessage(), e);
@@ -280,409 +341,63 @@ public class ExperimentExecution {
return dateFormat.format(cal.getTime());
}
- public void createAmberWithErrorInputs(String gatewayId,
- String token,
- String projectId,
- String hostId,
- String appId) throws Exception {
+ public String createLocalEchoExperiment(String gatewayId, String applicationInterfaceId, String storageId, String computeResourceId) throws Exception {
+ String experimentId = null;
try {
- List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, appId);
- List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, appId);
- TestFrameworkProps.Error[] errors = properties.getErrors();
- for (TestFrameworkProps.Error error : errors) {
- String name = error.getName();
- String hostName = error.getResoureName();
- if (name.equals(TestFrameworkConstants.ErrorTypeConstants.BADINPUTS)) {
- if (error.getApplication().equals(TestFrameworkConstants.AppcatalogConstants.AMBER_APP_NAME)) {
- Map<String, String> userGivenErrorInputs = error.getErrorFeeds();
- for (String inputName : userGivenErrorInputs.keySet()) {
- for (InputDataObjectType inputDataObjectType : applicationInputs) {
- if (inputDataObjectType.getName().equalsIgnoreCase(inputName)) {
- inputDataObjectType.setValue(userGivenErrorInputs.get(inputName));
- }
- }
- }
- ExperimentModel simpleExperiment =
- ExperimentModelUtil.createSimpleExperiment(gatewayId, projectId, testUser, "AmberErrorInputs", "Amber Experiment run", appId, applicationInputs);
- simpleExperiment.setExperimentOutputs(appOutputs);
- String experimentId;
- if (hostName.equals(TestFrameworkConstants.AppcatalogConstants.TRESTLES_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(hostId, 4, 1, 1, "normal", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (hostName.equals(TestFrameworkConstants.AppcatalogConstants.STAMPEDE_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(hostId, 4, 1, 1, "normal", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (hostName.equals(TestFrameworkConstants.AppcatalogConstants.BR2_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(hostId, 4, 1, 1, "cpu", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- }
-
- }
+ List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, applicationInterfaceId);
+ List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, applicationInterfaceId);
+ for (InputDataObjectType inputDataObjectType : applicationInputs) {
+ if (inputDataObjectType.getName().equalsIgnoreCase(INPUT_NAME)) {
+ inputDataObjectType.setValue(LOCAL_ECHO_EXPERIMENT_INPUT);
}
}
-
- } catch (Exception e) {
- logger.error("Error occured while creating amber experiment with bad inputs", e);
- throw new Exception("Error occured while creating amber experiment with bad inputs", e);
- }
- }
-
- public void createAmberWithErrorUserConfig(String gatewayId,
- String token,
- String projectId,
- String hostId,
- String appId) throws Exception {
- try {
-
- TestFrameworkProps.Error[] errors = properties.getErrors();
- for (TestFrameworkProps.Error error : errors) {
- String name = error.getName();
- String hostName = error.getResoureName();
- if (name.equals(TestFrameworkConstants.ErrorTypeConstants.ERROR_CONFIG)) {
- if (error.getApplication().equals(TestFrameworkConstants.AppcatalogConstants.AMBER_APP_NAME)) {
- List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, appId);
- List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, appId);
- TestFrameworkProps.Application[] applications = properties.getApplications();
- Map<String, String> userGivenAmberInputs = new HashMap<>();
- for (TestFrameworkProps.Application application : applications) {
- if (application.getName().equals(TestFrameworkConstants.AppcatalogConstants.AMBER_APP_NAME)) {
- userGivenAmberInputs = application.getInputs();
- }
- }
- for (String inputName : userGivenAmberInputs.keySet()) {
- for (InputDataObjectType inputDataObjectType : applicationInputs) {
- if (inputDataObjectType.getName().equalsIgnoreCase(inputName)) {
- inputDataObjectType.setValue(userGivenAmberInputs.get(inputName));
- }
- }
- }
- Map<String, String> errorConfigs = error.getErrorFeeds();
- String allocationProject = null;
- String queueName = null;
- Integer walltime = 0;
- String host = null;
- for (String configName : errorConfigs.keySet()) {
- if (configName.equals(TestFrameworkConstants.ErrorTypeConstants.ALLOCATION_PROJECT)) {
- allocationProject = errorConfigs.get(configName);
- } else if (configName.equals(TestFrameworkConstants.ErrorTypeConstants.QUEUE_NAME)) {
- queueName = errorConfigs.get(configName);
- } else if (configName.equals(TestFrameworkConstants.ErrorTypeConstants.WALLTIME)) {
- walltime = Integer.valueOf(errorConfigs.get(configName));
- } else if (configName.equals(TestFrameworkConstants.ErrorTypeConstants.HOST_NAME)) {
- host = errorConfigs.get(configName);
- }
- }
-
- ExperimentModel simpleExperiment =
- ExperimentModelUtil.createSimpleExperiment(gatewayId, projectId, testUser, "AmberErrorConfigs", "Amber Experiment run", appId, applicationInputs);
- simpleExperiment.setExperimentOutputs(appOutputs);
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(hostId, 4, 1, 1, queueName, walltime, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
-
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- String experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
-
- }
- }
+ List<Project> projectsPerGateway = projectsMap.get(gatewayId);
+ String projectID = null;
+ if (projectsPerGateway != null && !projectsPerGateway.isEmpty()) {
+ projectID = projectsPerGateway.get(0).getProjectID();
}
+ ExperimentModel simpleExperiment =
+ ExperimentModelUtil.createSimpleExperiment(gatewayId, projectID, properties.getTestUserName(), "Local Echo Experiment", "Local Echo Experiment run", applicationInterfaceId, applicationInputs);
+ simpleExperiment.setExperimentOutputs(appOutputs);
+
+ ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResourceId, 4, 1, 1, "cpu", 20, 0);
+ UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
+ userConfigurationData.setAiravataAutoSchedule(false);
+ userConfigurationData.setOverrideManualScheduledParams(false);
+ userConfigurationData.setComputationalResourceScheduling(scheduling);
+ userConfigurationData.setStorageId(storageId);
+ userConfigurationData.setExperimentDataDir(TestFrameworkConstants.STORAGE_LOCATION);
+ simpleExperiment.setUserConfigurationData(userConfigurationData);
+
+ experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
+ experimentsWithGateway.put(experimentId, gatewayId);
} catch (Exception e) {
- logger.error("Error occured while creating amber experiment with bad inputs", e);
- throw new Exception("Error occured while creating amber experiment with bad inputs", e);
- }
- }
-
- public void createAmberExperiment() throws Exception {
- try {
- TestFrameworkProps.Application[] applications = properties.getApplications();
- Map<String, String> userGivenAmberInputs = new HashMap<>();
- for (TestFrameworkProps.Application application : applications) {
- if (application.getName().equals(TestFrameworkConstants.AppcatalogConstants.AMBER_APP_NAME)) {
- userGivenAmberInputs = application.getInputs();
- }
- }
-
- for (String gatewayId : csTokens.keySet()) {
- String token = csTokens.get(gatewayId);
- Map<String, String> appsWithNames = appInterfaceMap.get(gatewayId);
- for (String appId : appsWithNames.keySet()) {
- String appName = appsWithNames.get(appId);
- if (appName.equals(TestFrameworkConstants.AppcatalogConstants.AMBER_APP_NAME)) {
- List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, appId);
- List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, appId);
- for (String inputName : userGivenAmberInputs.keySet()) {
- for (InputDataObjectType inputDataObjectType : applicationInputs) {
- if (inputDataObjectType.getName().equalsIgnoreCase(inputName)) {
- inputDataObjectType.setValue(userGivenAmberInputs.get(inputName));
- }
- }
- }
- List<Project> projectsPerGateway = projectsMap.get(gatewayId);
- String projectID = null;
- if (projectsPerGateway != null && !projectsPerGateway.isEmpty()) {
- projectID = projectsPerGateway.get(0).getProjectID();
- }
- ExperimentModel simpleExperiment =
- ExperimentModelUtil.createSimpleExperiment(gatewayId, projectID, testUser, "Amber Experiment", "Amber Experiment run", appId, applicationInputs);
- simpleExperiment.setExperimentOutputs(appOutputs);
- String experimentId;
- Map<String, String> computeResources = airavata.getAvailableAppInterfaceComputeResources(authzToken, appId);
- if (computeResources != null && computeResources.size() != 0) {
- for (String id : computeResources.keySet()) {
- String resourceName = computeResources.get(id);
- if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.TRESTLES_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.STAMPEDE_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- createAmberWithErrorInputs(gatewayId, token, projectID, id, appId);
- createAmberWithErrorUserConfig(gatewayId, token, projectID, id, appId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.BR2_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "cpu", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
- logger.error("Error while creating AMBEr experiment", e);
- throw new Exception("Error while creating AMBER experiment", e);
+ logger.error("Error while creating Echo experiment", e);
+ throw new Exception("Error while creating Echo experiment", e);
}
+ return experimentId;
}
- public void createUltrascanExperiment() throws Exception {
+ public ExperimentModel getExperimentModel(String experimentId){
+ ExperimentModel experimentModel = null;
try {
- TestFrameworkProps.Application[] applications = properties.getApplications();
- int numberOfIterations = properties.getNumberOfIterations();
- Map<String, String> userGivenAmberInputs = new HashMap<>();
- for (TestFrameworkProps.Application application : applications) {
- if (application.getName().equals(TestFrameworkConstants.AppcatalogConstants.ULTRASCAN)) {
- userGivenAmberInputs = application.getInputs();
- }
- }
-
- for (int i = 0; i < numberOfIterations; i++) {
- for (String gatewayId : csTokens.keySet()) {
- String token = csTokens.get(gatewayId);
- Map<String, String> appsWithNames = appInterfaceMap.get(gatewayId);
- for (String appId : appsWithNames.keySet()) {
- String appName = appsWithNames.get(appId);
- if (appName.equals(TestFrameworkConstants.AppcatalogConstants.ULTRASCAN)) {
- List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, appId);
- List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, appId);
- for (String inputName : userGivenAmberInputs.keySet()) {
- for (InputDataObjectType inputDataObjectType : applicationInputs) {
- if (inputDataObjectType.getName().equalsIgnoreCase(inputName)) {
- inputDataObjectType.setValue(userGivenAmberInputs.get(inputName));
- }
- }
- }
- List<Project> projectsPerGateway = projectsMap.get(gatewayId);
- String projectID = null;
- if (projectsPerGateway != null && !projectsPerGateway.isEmpty()) {
- projectID = projectsPerGateway.get(0).getProjectID();
- }
- ExperimentModel simpleExperiment =
- ExperimentModelUtil.createSimpleExperiment(gatewayId, projectID, testUser, "TestFR_Ultrascan_Experiment", "Ultrascan Experiment run", appId, applicationInputs);
- simpleExperiment.setExperimentOutputs(appOutputs);
- String experimentId;
- Map<String, String> computeResources = airavata.getAvailableAppInterfaceComputeResources(authzToken, appId);
- if (computeResources != null && computeResources.size() != 0) {
- for (String id : computeResources.keySet()) {
- String resourceName = computeResources.get(id);
- if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.STAMPEDE_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 30, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.ALAMO_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "batch", 30, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.GORDEN_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 30, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.COMET_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "compute", 30, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.LONESTAR_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 30, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- }
- }
- }
- }
- }
- }
- }
-
- } catch (Exception e) {
- logger.error("Error while creating Ultrascan experiment", e);
- throw new Exception("Error while creating Ultrascan experiment", e);
+ experimentModel = airavata.getExperiment(authzToken, experimentId);
+ } catch (TException e) {
+ logger.error("Error fetching experiment model", e);
}
+ return experimentModel;
}
- public void createEchoExperiment() throws Exception {
+ public ExperimentStatus getExperimentStatus(String experimentId){
+ ExperimentStatus experimentStatus = null;
try {
- for (String gatewayId : csTokens.keySet()) {
- boolean isgatewayValid = true;
- for (String ovoidGateway : gatewaysToAvoid) {
- if (gatewayId.equals(ovoidGateway)) {
- isgatewayValid = false;
- break;
- }
- }
- if (isgatewayValid) {
- String token = csTokens.get(gatewayId);
- Map<String, String> appsWithNames = appInterfaceMap.get(gatewayId);
- for (String appId : appsWithNames.keySet()) {
- String appName = appsWithNames.get(appId);
- if (appName.equals(TestFrameworkConstants.AppcatalogConstants.ECHO_NAME)) {
- List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, appId);
- List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, appId);
- for (InputDataObjectType inputDataObjectType : applicationInputs) {
- if (inputDataObjectType.getName().equalsIgnoreCase("input_to_Echo")) {
- inputDataObjectType.setValue("Hello World !!!");
- }
- }
-
- List<Project> projectsPerGateway = projectsMap.get(gatewayId);
- String projectID = null;
- if (projectsPerGateway != null && !projectsPerGateway.isEmpty()) {
- projectID = projectsPerGateway.get(0).getProjectID();
- }
- ExperimentModel simpleExperiment =
- ExperimentModelUtil.createSimpleExperiment(gatewayId, projectID, "admin", "Echo Experiment", "Echo Experiment run", appId, applicationInputs);
- simpleExperiment.setExperimentOutputs(appOutputs);
- String experimentId;
- Map<String, String> computeResources = airavata.getAvailableAppInterfaceComputeResources(authzToken, appId);
- if (computeResources != null && computeResources.size() != 0) {
- for (String id : computeResources.keySet()) {
- String resourceName = computeResources.get(id);
- if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.TRESTLES_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.STAMPEDE_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- } else if (resourceName.equals(TestFrameworkConstants.AppcatalogConstants.BR2_RESOURCE_NAME)) {
- ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "cpu", 20, 0);
- UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
- simpleExperiment.setUserConfigurationData(userConfigurationData);
- experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
- experimentsWithTokens.put(experimentId, token);
- experimentsWithGateway.put(experimentId, gatewayId);
- }
- }
- }
- }
- }
- }
-
- }
- } catch (Exception e) {
- logger.error("Error while creating Echo experiment", e);
- throw new Exception("Error while creating Echo experiment", e);
+ experimentStatus = airavata.getExperimentStatus(authzToken, experimentId);
+ } catch (TException e) {
+ logger.error("Error fetching experiment status", e);
}
+ return experimentStatus;
}
+
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/FrameworkSetup.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/FrameworkSetup.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/FrameworkSetup.java
index 6de88bf..aea92bb 100644
--- a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/FrameworkSetup.java
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/FrameworkSetup.java
@@ -22,7 +22,6 @@
package org.apache.airavata.testsuite.multitenantedairavata;
import com.google.gson.Gson;
-import com.google.gson.JsonElement;
import org.apache.airavata.api.Airavata;
import org.apache.airavata.testsuite.multitenantedairavata.utils.TestFrameworkConstants;
import org.slf4j.Logger;
@@ -32,12 +31,12 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.URL;
public class FrameworkSetup {
private static FrameworkSetup instance = new FrameworkSetup();
private GatewayRegister gatewayRegister;
private ComputeResourceRegister computeResourceRegister;
+ private StorageResourceRegister storageResourceRegister;
private ApplicationRegister applicationRegister;
private Airavata.Client airavata;
private TestFrameworkProps testFrameworkProps;
@@ -57,6 +56,7 @@ public class FrameworkSetup {
gatewayRegister = new GatewayRegister(airavata, testFrameworkProps);
applicationRegister = new ApplicationRegister(airavata, testFrameworkProps);
computeResourceRegister = new ComputeResourceRegister(airavata, testFrameworkProps);
+ storageResourceRegister = new StorageResourceRegister(airavata, testFrameworkProps);
} catch (Exception e) {
logger.error("Error while creating airavata client instance", e);
}
@@ -73,7 +73,7 @@ public class FrameworkSetup {
while ((line = reader.readLine()) != null) {
content += line;
}
- System.out.println(content);
+ //System.out.println(content);
return content;
}
@@ -105,6 +105,10 @@ public class FrameworkSetup {
return computeResourceRegister;
}
+ public StorageResourceRegister getStorageResourceRegister() {
+ return storageResourceRegister;
+ }
+
public void setComputeResourceRegister(ComputeResourceRegister computeResourceRegister) {
this.computeResourceRegister = computeResourceRegister;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/GatewayRegister.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/GatewayRegister.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/GatewayRegister.java
index 6cf5354..de53fba 100644
--- a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/GatewayRegister.java
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/GatewayRegister.java
@@ -24,18 +24,19 @@ package org.apache.airavata.testsuite.multitenantedairavata;
import org.apache.airavata.api.Airavata;
import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.common.utils.DBUtil;
import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
import org.apache.airavata.credential.store.store.CredentialStoreException;
import org.apache.airavata.credential.store.store.impl.SSHCredentialWriter;
import org.apache.airavata.credential.store.util.TokenGenerator;
import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
+import org.apache.airavata.model.credential.store.CredentialOwnerType;
import org.apache.airavata.model.error.AiravataClientException;
import org.apache.airavata.model.error.AiravataSystemException;
import org.apache.airavata.model.error.InvalidRequestException;
import org.apache.airavata.model.security.AuthzToken;
import org.apache.airavata.model.workspace.Gateway;
+import org.apache.airavata.model.workspace.GatewayApprovalStatus;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.testsuite.multitenantedairavata.utils.FrameworkUtils;
import org.apache.airavata.testsuite.multitenantedairavata.utils.PropertyFileType;
@@ -59,7 +60,6 @@ public class GatewayRegister {
private Map<String, String> projectMap;
private String testUser;
private String testProject;
- private List<String> gatewaysToAvoid;
private TestFrameworkProps properties;
private AuthzToken authzToken;
@@ -73,7 +73,6 @@ public class GatewayRegister {
testUser = properties.getTestUserName();
testProject = properties.getTestProjectName();
FrameworkUtils frameworkUtils = FrameworkUtils.getInstance();
- gatewaysToAvoid = frameworkUtils.getGatewayListToAvoid(properties.getSkippedGateways());
authzToken = new AuthzToken("emptyToken");
}catch (Exception e){
logger.error("Error while initializing setup step", e);
@@ -81,25 +80,33 @@ public class GatewayRegister {
}
}
- public void createGateways() throws Exception{
+ public void createGateway() throws Exception{
try {
// read gateway count from properties file
- gatewayCount = properties.getGcount();
+ List<GatewayResourceProfile> gateReourceProfiles = airavata.getAllGatewayResourceProfiles(authzToken);
+ for(GatewayResourceProfile gatewayResourceProfile : gateReourceProfiles){
+ if(gatewayResourceProfile.getGatewayID().equals(properties.getGname())){
+ createProject(gatewayResourceProfile.getGatewayID());
+ return;
+ }
+ }
+
String genericGatewayName = properties.getGname();
String genericGatewayDomain = properties.getGdomain();
- for (int i = 0; i < gatewayCount; i++){
- Gateway gateway = new Gateway();
- String gatewayId = genericGatewayName + (i + 1);
- gateway.setGatewayId(gatewayId);
- gateway.setGatewayName(gatewayId);
- gateway.setDomain(gatewayId + genericGatewayDomain);
- airavata.addGateway(authzToken, gateway);
- GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
- gatewayResourceProfile.setGatewayID(gatewayId);
- airavata.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
- // create a project per each gateway
- createProject(gatewayId);
- }
+ Gateway gateway = new Gateway();
+ String gatewayId = genericGatewayName;
+ gateway.setGatewayId(gatewayId);
+ gateway.setGatewayName(gatewayId);
+ gateway.setDomain(gatewayId + genericGatewayDomain);
+ gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED);
+ airavata.addGateway(authzToken, gateway);
+ String token = airavata.generateAndRegisterSSHKeys(authzToken, gatewayId, testUser, testUser, CredentialOwnerType.USER);
+ GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
+ gatewayResourceProfile.setCredentialStoreToken(token);
+ gatewayResourceProfile.setGatewayID(gatewayId);
+ airavata.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
+ createProject(gatewayId);
+
} catch (AiravataSystemException e) {
logger.error("Error while creating airavata client instance", e);
throw new Exception("Error while creating airavata client instance", e);
@@ -115,14 +122,38 @@ public class GatewayRegister {
}
}
+ public GatewayResourceProfile getGatewayResourceProfile() throws Exception{
+ return airavata.getGatewayResourceProfile(authzToken, properties.getGname());
+
+ }
+
+ public Gateway getGateway(String gatewayId) throws Exception{
+ Gateway gateway = airavata.getGateway(authzToken, gatewayId);
+ return gateway;
+
+ }
+
public void createProject (String gatewayId) throws Exception{
Project project = new Project();
+ project.setGatewayId(gatewayId);
project.setName(testProject);
project.setOwner(testUser);
String projectId = airavata.createProject(authzToken, gatewayId, project);
projectMap.put(projectId, gatewayId);
}
+ public String writeToken() throws Exception{
+ String tokenWriteLocation = properties.getTokenFileLoc();
+ String fileName = tokenWriteLocation + File.separator + TestFrameworkConstants.CredentialStoreConstants.TOKEN_FILE_NAME;
+ Gateway gateway = airavata.getGateway(authzToken, properties.getGname());
+ PrintWriter tokenWriter = new PrintWriter(fileName, "UTF-8");
+ String token = TokenGenerator.generateToken(gateway.getGatewayId(), null);
+ tokenMap.put(gateway.getGatewayId(), token);
+ tokenWriter.println(gateway.getGatewayId() + ":" + token);
+ tokenWriter.close();
+ return gateway.getGatewayId() + ":" + token +"\n";
+ }
+
public void registerSSHKeys () throws Exception{
try {
// write tokens to file
@@ -131,48 +162,39 @@ public class GatewayRegister {
PrintWriter tokenWriter = new PrintWriter(fileName, "UTF-8");
// credential store related functions are not in the current api, so need to call credential store directly
- String jdbcURL = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_JBDC_URL, PropertyFileType.AIRAVATA_CLIENT);
- String jdbcDriver = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_JBDC_DRIVER, PropertyFileType.AIRAVATA_CLIENT);
- String userName = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_DB_USERNAME, PropertyFileType.AIRAVATA_CLIENT);
- String password = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_DB_PWD, PropertyFileType.AIRAVATA_CLIENT);
+ String jdbcURL = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_JBDC_URL, PropertyFileType.AIRAVATA_SERVER);
+ String jdbcDriver = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_JBDC_DRIVER, PropertyFileType.AIRAVATA_SERVER);
+ String userName = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_DB_USERNAME, PropertyFileType.AIRAVATA_SERVER);
+ String password = propertyReader.readProperty(TestFrameworkConstants.AiravataClientConstants.CS_DB_PWD, PropertyFileType.AIRAVATA_SERVER);
String privateKeyPath = properties.getSshPrivateKeyLoc();
String pubKeyPath = properties.getSshPubKeyLoc();
String keyPassword = properties.getSshPassword();
DBUtil dbUtil = new DBUtil(jdbcURL, userName, password, jdbcDriver);
SSHCredentialWriter writer = new SSHCredentialWriter(dbUtil);
- List<Gateway> allGateways = airavata.getAllGateways(authzToken);
- for (Gateway gateway : allGateways){
- boolean isgatewayValid = true;
- for (String ovoidGateway : gatewaysToAvoid){
- if (gateway.getGatewayId().equals(ovoidGateway)){
- isgatewayValid = false;
- break;
- }
- }
- if (isgatewayValid) {
- SSHCredential sshCredential = new SSHCredential();
- sshCredential.setGateway(gateway.getGatewayId());
- String token = TokenGenerator.generateToken(gateway.getGatewayId(), null);
- sshCredential.setToken(token);
- sshCredential.setPortalUserName(testUser);
- FileInputStream privateKeyStream = new FileInputStream(privateKeyPath);
- File filePri = new File(privateKeyPath);
- byte[] bFilePri = new byte[(int) filePri.length()];
- privateKeyStream.read(bFilePri);
- FileInputStream pubKeyStream = new FileInputStream(pubKeyPath);
- File filePub = new File(pubKeyPath);
- byte[] bFilePub = new byte[(int) filePub.length()];
- pubKeyStream.read(bFilePub);
- privateKeyStream.close();
- pubKeyStream.close();
- sshCredential.setPrivateKey(bFilePri);
- sshCredential.setPublicKey(bFilePub);
- sshCredential.setPassphrase(keyPassword);
- writer.writeCredentials(sshCredential);
- tokenMap.put(gateway.getGatewayId(), token);
- tokenWriter.println(gateway.getGatewayId() + ":" + token);
- }
- }
+ Gateway gateway = airavata.getGateway(authzToken, properties.getGname());
+
+ SSHCredential sshCredential = new SSHCredential();
+ sshCredential.setGateway(gateway.getGatewayId());
+ String token = TokenGenerator.generateToken(gateway.getGatewayId(), null);
+ sshCredential.setToken(token);
+ sshCredential.setPortalUserName(testUser);
+ FileInputStream privateKeyStream = new FileInputStream(privateKeyPath);
+ File filePri = new File(privateKeyPath);
+ byte[] bFilePri = new byte[(int) filePri.length()];
+ privateKeyStream.read(bFilePri);
+ FileInputStream pubKeyStream = new FileInputStream(pubKeyPath);
+ File filePub = new File(pubKeyPath);
+ byte[] bFilePub = new byte[(int) filePub.length()];
+ pubKeyStream.read(bFilePub);
+ privateKeyStream.close();
+ pubKeyStream.close();
+ sshCredential.setPrivateKey(bFilePri);
+ sshCredential.setPublicKey(bFilePub);
+ sshCredential.setPassphrase(keyPassword);
+ writer.writeCredentials(sshCredential);
+ tokenMap.put(gateway.getGatewayId(), token);
+ tokenWriter.println(gateway.getGatewayId() + ":" + token);
+
tokenWriter.close();
} catch (ClassNotFoundException e) {
logger.error("Unable to find mysql driver", e);
@@ -201,10 +223,11 @@ public class GatewayRegister {
} catch (FileNotFoundException e) {
logger.error("Could not find keys specified in the path", e);
throw new Exception("Could not find keys specified in the path",e);
- } catch (CredentialStoreException e) {
+ }catch (CredentialStoreException e) {
logger.error("Error while saving SSH credentials", e);
throw new Exception("Error while saving SSH credentials",e);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
logger.error("Error while saving SSH credentials", e);
throw new Exception("Error while saving SSH credentials",e);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/StorageResourceRegister.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/StorageResourceRegister.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/StorageResourceRegister.java
new file mode 100644
index 0000000..4d358a4
--- /dev/null
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/StorageResourceRegister.java
@@ -0,0 +1,151 @@
+package org.apache.airavata.testsuite.multitenantedairavata;
+
+import org.apache.airavata.api.Airavata;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
+import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
+import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
+import org.apache.airavata.model.data.movement.DMType;
+import org.apache.airavata.model.data.movement.LOCALDataMovement;
+import org.apache.airavata.model.security.AuthzToken;
+import org.apache.airavata.testsuite.multitenantedairavata.utils.TestFrameworkConstants;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.airavata.testsuite.multitenantedairavata.utils.TestFrameworkConstants.LocalEchoProperties.*;
+
+public class StorageResourceRegister {
+
+ private final static Logger logger = LoggerFactory.getLogger(StorageResourceRegister.class);
+
+ private Airavata.Client airavata;
+
+ private TestFrameworkProps properties;
+ private AuthzToken authzToken;
+
+ private Map<String, String> loginNamesWithResourceMap;
+ private Map<String, String> loginNamesWithResourceIds;
+
+ public Map<String, String> getLoginNamesMap() throws Exception {
+ loginNamesWithResourceMap = new HashMap<String, String>();
+ TestFrameworkProps.Resource[] resourcesWithloginName = properties.getResources();
+ if (resourcesWithloginName != null){
+ for (TestFrameworkProps.Resource resource : resourcesWithloginName){
+ loginNamesWithResourceMap.put(resource.getName(), resource.getLoginUser());
+ }
+ }
+ return loginNamesWithResourceMap;
+ }
+
+ public Map<String, String> getLoginNamesWithResourceIDs() throws Exception {
+ loginNamesWithResourceIds = new HashMap<String, String>();
+ Map<String, String> allStorageResourceNames = airavata.getAllStorageResourceNames(authzToken);
+ for (String resourceId : allStorageResourceNames.keySet()) {
+ String resourceName = allStorageResourceNames.get(resourceId);
+ loginNamesWithResourceIds.put(resourceId, loginNamesWithResourceMap.get(resourceName));
+ }
+
+ return loginNamesWithResourceIds;
+ }
+
+ public StorageResourceRegister(Airavata.Client airavata, TestFrameworkProps props) throws Exception{
+ this.airavata = airavata;
+ this.properties = props;
+ loginNamesWithResourceMap = getLoginNamesMap();
+ authzToken = new AuthzToken("emptyToken");
+ }
+
+ public String addStorageResourceResource() throws Exception {
+
+ String localStorageResource = null;
+
+ try{
+ /*
+ check if local storage is already there
+ */
+ Map<String, String> storageResources = airavata.getAllStorageResourceNames(authzToken);
+
+ for(Map.Entry<String, String> storageResource: storageResources.entrySet()){
+ if(storageResource.getValue().contains("localhost")){
+ localStorageResource = storageResource.getKey();
+ System.out.println("Existing Local Storage Resource Id " + localStorageResource);
+ return localStorageResource;
+ }
+ }
+
+ /*
+ Create local storage
+ */
+ for (String resourceName : loginNamesWithResourceMap.keySet()) {
+ if (resourceName.contains(RESOURCE_NAME)) {
+ localStorageResource = registerStorageResource(HOST_NAME, HOST_DESC);
+ System.out.println("Local Storage Resource Id " + localStorageResource);
+ }
+ }
+
+ } catch (TException e) {
+ logger.error("Error occured while creating storage resource preference", e);
+ throw new Exception("Error occured while creating storage resource preference", e);
+ }
+ return localStorageResource;
+ }
+
+ public StorageResourceDescription getStorageResourceDescription(String storageResourceId) throws Exception {
+ return airavata.getStorageResource(authzToken, storageResourceId);
+
+ }
+
+ public String registerStorageResource(String hostName, String hostDesc) throws TException{
+ StorageResourceDescription storageResourceDescription = createStorageResourceDescription(hostName, hostDesc);
+ String storageResourceId = airavata.registerStorageResource(authzToken, storageResourceDescription);
+ airavata.addLocalDataMovementDetails(authzToken, storageResourceId, DMType.STORAGE_RESOURCE, 0, new LOCALDataMovement());
+ return storageResourceId;
+ }
+
+ public StorageResourceDescription createStorageResourceDescription(
+ String hostName, String hostDesc) {
+ StorageResourceDescription host = new StorageResourceDescription();
+ host.setHostName(hostName);
+ host.setStorageResourceDescription(hostDesc);
+ host.setEnabled(true);
+ return host;
+ }
+
+ public void registerGatewayStorageProfile(String storageResourceId) throws Exception{
+ StoragePreference localResourcePreference = null;
+ try{
+ loginNamesWithResourceIds = getLoginNamesWithResourceIDs();
+ List<GatewayResourceProfile> allGatewayComputeResources = airavata.getAllGatewayResourceProfiles(authzToken);
+ for (GatewayResourceProfile gatewayResourceProfile : allGatewayComputeResources) {
+ for (String resourceId : loginNamesWithResourceIds.keySet()) {
+ String loginUserName = loginNamesWithResourceIds.get(resourceId);
+ if (resourceId.equals(storageResourceId) && loginUserName.equals(LOGIN_USER)){
+ localResourcePreference = createStoragePreferenceResource(resourceId, loginUserName, TestFrameworkConstants.STORAGE_LOCATION);
+ airavata.addGatewayStoragePreference(authzToken, gatewayResourceProfile.getGatewayID(), resourceId, localResourcePreference);
+ }
+ }
+ }
+
+ } catch (TException e) {
+ logger.error("Error occured while registering gateway storage profiles", e);
+ throw new Exception("Error occured while registering gateway storage profiles", e);
+ }
+ }
+
+ public StoragePreference getStoragePreference(String gatewayId, String storageResourceId) throws Exception {
+ return airavata.getGatewayStoragePreference(authzToken, gatewayId, storageResourceId);
+
+ }
+
+ public StoragePreference createStoragePreferenceResource(String storageResourceId, String loginUser, String fsRootLocation){
+ StoragePreference storagePreference = new StoragePreference();
+ storagePreference.setStorageResourceId(storageResourceId);
+ storagePreference.setLoginUserName(loginUser);
+ storagePreference.setFileSystemRootLocation(fsRootLocation);
+ return storagePreference;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/TestFrameworkProps.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/TestFrameworkProps.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/TestFrameworkProps.java
index ea9956a..2f85624 100644
--- a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/TestFrameworkProps.java
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/TestFrameworkProps.java
@@ -35,7 +35,6 @@ public class TestFrameworkProps {
private String sshUsername;
private String tokenFileLoc;
private String resultFileLoc;
- private String skippedGateways;
private boolean injectErrors;
private Resource[] resources;
private Application[] applications;
@@ -142,13 +141,6 @@ public class TestFrameworkProps {
this.resultFileLoc = resultFileLoc;
}
- public String getSkippedGateways() {
- return skippedGateways;
- }
-
- public void setSkippedGateways(String skippedGateways) {
- this.skippedGateways = skippedGateways;
- }
public Resource[] getResources() {
return resources;
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ApplicationProperties.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ApplicationProperties.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ApplicationProperties.java
new file mode 100644
index 0000000..6b47ada
--- /dev/null
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ApplicationProperties.java
@@ -0,0 +1,39 @@
+package org.apache.airavata.testsuite.multitenantedairavata.utils;
+
+/**
+ * Created by Ajinkya on 12/14/16.
+ */
+public class ApplicationProperties {
+
+ private String applicationModuleId;
+ private String applicationInterfaceId;
+ private String applicationDeployId;
+
+ public ApplicationProperties(String applicationModuleId, String applicationInterfaceId, String applicationDeployId) {
+ this.applicationModuleId = applicationModuleId;
+ this.applicationInterfaceId = applicationInterfaceId;
+ this.applicationDeployId = applicationDeployId;
+ }
+
+ public String getApplicationModuleId() {
+ return applicationModuleId;
+ }
+
+ public String getApplicationDeployId() {
+ return applicationDeployId;
+ }
+
+ public String getApplicationInterfaceId() {
+ return applicationInterfaceId;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("ApplicationProperties{");
+ sb.append("applicationModuleId='").append(applicationModuleId).append('\'');
+ sb.append(", applicationInterfaceId='").append(applicationInterfaceId).append('\'');
+ sb.append(", applicationDeployId='").append(applicationDeployId).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ComputeResourceProperties.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ComputeResourceProperties.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ComputeResourceProperties.java
new file mode 100644
index 0000000..d9e2d87
--- /dev/null
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/ComputeResourceProperties.java
@@ -0,0 +1,35 @@
+package org.apache.airavata.testsuite.multitenantedairavata.utils;
+
+/**
+ * Created by Ajinkya on 12/14/16.
+ */
+public class ComputeResourceProperties {
+ private String computeResourceId;
+ private String jobSubmissionId;
+
+ public String getComputeResourceId() {
+ return computeResourceId;
+ }
+
+ public void setComputeResourceId(String computeResourceId) {
+ this.computeResourceId = computeResourceId;
+ }
+
+ public String getJobSubmissionId() {
+ return jobSubmissionId;
+ }
+
+ public void setJobSubmissionId(String jobSubmissionId) {
+ this.jobSubmissionId = jobSubmissionId;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("ComputeResourceProperties{");
+ sb.append("computeResourceId='").append(computeResourceId).append('\'');
+ sb.append(", jobSubmissionId='").append(jobSubmissionId).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyFileType.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyFileType.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyFileType.java
index 1db022f..2700567 100644
--- a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyFileType.java
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyFileType.java
@@ -23,6 +23,6 @@ package org.apache.airavata.testsuite.multitenantedairavata.utils;
public enum PropertyFileType {
- AIRAVATA_CLIENT
+ AIRAVATA_SERVER
// TEST_FRAMEWORK
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ce359dc0/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyReader.java
----------------------------------------------------------------------
diff --git a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyReader.java b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyReader.java
index 9df1745..3a8c70f 100644
--- a/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyReader.java
+++ b/modules/test-suite/multi-tenanted-airavata/src/main/java/org/apache/airavata/testsuite/multitenantedairavata/utils/PropertyReader.java
@@ -36,13 +36,13 @@ public class PropertyReader {
public PropertyReader() {
try {
loadProperties();
- } catch (IOException e) {
+ } catch (Exception e) {
logger.error("Unable to read properties files", e);
}
}
protected void loadProperties() throws IOException {
- URL airavataURL = ApplicationSettings.loadFile(TestFrameworkConstants.AIRAVATA_CLIENT_PROPERTIES);
+ URL airavataURL = ApplicationSettings.loadFile(TestFrameworkConstants.AIRAVATA_SERVER_PROPERTIES);
if (airavataURL != null){
airavataClientProperties.load(airavataURL.openStream());
}
@@ -50,7 +50,7 @@ public class PropertyReader {
public String readProperty (String propertyName, PropertyFileType type){
switch (type){
- case AIRAVATA_CLIENT:
+ case AIRAVATA_SERVER:
return airavataClientProperties.getProperty(propertyName);
}
return null;