airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: adding unit test to registry resources and fixing some issues in the cpi - AIRAVATA-1006
Date Mon, 03 Mar 2014 17:02:18 GMT
Repository: airavata
Updated Branches:
  refs/heads/master f75fa7ef3 -> 0a470ce90


adding unit test to registry resources and fixing some issues in the cpi - AIRAVATA-1006


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/0a470ce9
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/0a470ce9
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/0a470ce9

Branch: refs/heads/master
Commit: 0a470ce909fd6d1e041524792cb81f5f6059b5ce
Parents: f75fa7e
Author: chathuri <chathuri@apache.org>
Authored: Mon Mar 3 12:02:08 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Mon Mar 3 12:02:08 2014 -0500

----------------------------------------------------------------------
 .../model/util/ExperimentModelUtil.java         |   4 +-
 .../client/OrchestratorClientFactoryTest.java   |  18 ++-
 .../registry/jpa/impl/ExperimentRegistry.java   | 103 +++++++++++++-
 .../jpa/ExperimentInputResourceTest.java        | 136 ++++++++++---------
 .../jpa/ExperimentOutputResourceTest.java       |  76 +++++++++++
 5 files changed, 263 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/0a470ce9/airavata-api/airavata-model-utils/src/main/java/org/apache/airavata/model/util/ExperimentModelUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-model-utils/src/main/java/org/apache/airavata/model/util/ExperimentModelUtil.java
b/airavata-api/airavata-model-utils/src/main/java/org/apache/airavata/model/util/ExperimentModelUtil.java
index 412e5f1..52c1ee6 100644
--- a/airavata-api/airavata-model-utils/src/main/java/org/apache/airavata/model/util/ExperimentModelUtil.java
+++ b/airavata-api/airavata-model-utils/src/main/java/org/apache/airavata/model/util/ExperimentModelUtil.java
@@ -46,7 +46,6 @@ public class ExperimentModelUtil {
     }
 
 
-
     public static ComputationalResourceScheduling createComputationResourceScheduling(String
resourceHostId,
                                                                                       int
cpuCount,
                                                                                       int
nodeCount,
@@ -112,10 +111,11 @@ public class ExperimentModelUtil {
             taskDetails.setApplicationInputs(experimentInputs);
         }
 
-         List<DataObjectType> experimentOutputs = experiment.getExperimentOutputs();
+        List<DataObjectType> experimentOutputs = experiment.getExperimentOutputs();
         if (experimentOutputs != null){
             taskDetails.setApplicationOutputs(experimentOutputs);
         }
+        
         UserConfigurationData configData = experiment.getUserConfigurationData();
         if (configData != null){
             ComputationalResourceScheduling scheduling = configData.getComputationalResourceScheduling();

http://git-wip-us.apache.org/repos/asf/airavata/blob/0a470ce9/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
b/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
index a20c80e..9cc6bcd 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
+++ b/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
@@ -63,16 +63,14 @@ public class OrchestratorClientFactoryTest {
 
     private AiravataAPI getAiravataAPI() {
         AiravataAPI airavataAPI = null;
-        if (airavataAPI == null) {
-            try {
-                String systemUserName = ServerSettings.getSystemUser();
-                String gateway = ServerSettings.getSystemUserGateway();
-                airavataAPI = AiravataAPIFactory.getAPI(gateway, systemUserName);
-            } catch (ApplicationSettingsException e) {
-                e.printStackTrace();
-            } catch (AiravataAPIInvocationException e) {
-                e.printStackTrace();
-            }
+        try {
+            String systemUserName = ServerSettings.getSystemUser();
+            String gateway = ServerSettings.getSystemUserGateway();
+            airavataAPI = AiravataAPIFactory.getAPI(gateway, systemUserName);
+        } catch (ApplicationSettingsException e) {
+            e.printStackTrace();
+        } catch (AiravataAPIInvocationException e) {
+            e.printStackTrace();
         }
         return airavataAPI;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/0a470ce9/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
index a4bac31..ca5c717 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
@@ -25,6 +25,7 @@ import org.apache.airavata.model.workspace.experiment.*;
 import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.persistance.registry.jpa.utils.ThriftDataModelConversion;
 import org.apache.airavata.registry.cpi.CompositeIdentifier;
@@ -89,6 +90,22 @@ public class ExperimentRegistry {
                 addUserConfigData(userConfigurationData, experimentID);
             }
 
+            List<DataObjectType> experimentOutputs = experiment.getExperimentOutputs();
+            if (experimentOutputs != null && !experimentOutputs.isEmpty()){
+                addExpOutputs(experimentOutputs, experimentID);
+            }
+
+            ExperimentStatus experimentStatus = experiment.getExperimentStatus();
+            if (experimentStatus != null){
+                updateExperimentStatus(experimentStatus, experimentID);
+            }
+
+            List<WorkflowNodeDetails> workflowNodeDetailsList = experiment.getWorkflowNodeDetailsList();
+            if (workflowNodeDetailsList != null && !workflowNodeDetailsList.isEmpty()){
+                for (WorkflowNodeDetails wf : workflowNodeDetailsList){
+                    addWorkflowNodeDetails(wf, experimentID);
+                }
+            }
         } catch (Exception e) {
             logger.error("Error while saving experiment to registry", e.getMessage());
             throw new Exception(e);
@@ -615,6 +632,11 @@ public class ExperimentRegistry {
             if (nodeInputs != null) {
                 addWorkflowInputs(nodeDetails.getNodeInputs(), resource);
             }
+            List<DataObjectType> nodeOutputs = nodeDetails.getNodeOutputs();
+            if (nodeOutputs != null && !nodeOutputs.isEmpty()){
+                CompositeIdentifier ids = new CompositeIdentifier(expId, resource.getNodeInstanceId());
+                addNodeOutputs(nodeOutputs, ids);
+            }
             return resource.getNodeInstanceId();
         } catch (Exception e) {
             logger.error("Error while adding workflow node details...", e.getMessage());
@@ -635,6 +657,10 @@ public class ExperimentRegistry {
             if (nodeInputs != null) {
                 updateWorkflowInputs(nodeDetails.getNodeInputs(), workflowNode);
             }
+            List<DataObjectType> nodeOutputs = nodeDetails.getNodeOutputs();
+            if (nodeOutputs != null && !nodeOutputs.isEmpty()){
+                updateNodeOutputs(nodeOutputs, nodeId);
+            }
         } catch (Exception e) {
             logger.error("Error while updating workflow node details...", e.getMessage());
             throw new Exception(e);
@@ -711,6 +737,34 @@ public class ExperimentRegistry {
             if (outputDataHandling != null) {
                 addOutputDataHandling(outputDataHandling, taskDetail);
             }
+
+            List<JobDetails> jobDetailsList = taskDetails.getJobDetailsList();
+            if (jobDetailsList != null && !jobDetailsList.isEmpty()){
+                for (JobDetails job : jobDetailsList){
+                    CompositeIdentifier ids = new CompositeIdentifier(taskDetail.getTaskId(),
job.getJobID());
+                    addJobDetails(job,ids);
+                }
+            }
+
+            List<DataTransferDetails> dataTransferDetailsList = taskDetails.getDataTransferDetailsList();
+            if (dataTransferDetailsList != null && !dataTransferDetailsList.isEmpty()){
+                for (DataTransferDetails transferDetails : dataTransferDetailsList){
+                    addDataTransferDetails(transferDetails, taskDetail.getTaskId());
+                }
+            }
+
+            List<ErrorDetails> errors = taskDetails.getErrors();
+            if (errors != null && !errors.isEmpty()){
+                for (ErrorDetails error : errors){
+                    addErrorDetails(error, taskDetail.getTaskId());
+                }
+            }
+
+            TaskStatus taskStatus = taskDetails.getTaskStatus();
+            if (taskStatus != null){
+                CompositeIdentifier ids = new CompositeIdentifier(nodeId, taskDetail.getTaskId());
+                addTaskStatus(taskStatus, ids);
+            }
             return taskDetail.getTaskId();
         } catch (Exception e) {
             logger.error("Error while adding task details...", e.getMessage());
@@ -745,6 +799,31 @@ public class ExperimentRegistry {
             if (outputDataHandling != null) {
                 updateOutputDataHandling(outputDataHandling, taskDetail);
             }
+            List<JobDetails> jobDetailsList = taskDetails.getJobDetailsList();
+            if (jobDetailsList != null && !jobDetailsList.isEmpty()){
+                for (JobDetails job : jobDetailsList){
+                    updateJobDetails(job, job.getJobID());
+                }
+            }
+
+            List<DataTransferDetails> dataTransferDetailsList = taskDetails.getDataTransferDetailsList();
+            if (dataTransferDetailsList != null && !dataTransferDetailsList.isEmpty()){
+                for (DataTransferDetails transferDetails : dataTransferDetailsList){
+                    updateDataTransferDetails(transferDetails, transferDetails.getTransferID());
+                }
+            }
+
+            List<ErrorDetails> errors = taskDetails.getErrors();
+            if (errors != null && !errors.isEmpty()){
+                for (ErrorDetails error : errors){
+                    addErrorDetails(error, taskDetail.getTaskId());
+                }
+            }
+
+            TaskStatus taskStatus = taskDetails.getTaskStatus();
+            if (taskStatus != null){
+                updateTaskStatus(taskStatus, taskId);
+            }
             return taskDetail.getTaskId();
         } catch (Exception e) {
             logger.error("Error while updating task details...", e.getMessage());
@@ -1171,7 +1250,29 @@ public class ExperimentRegistry {
             existingExperiment.setWorkflowExecutionId(experiment.getWorkflowExecutionInstanceId());
             existingExperiment.save();
             List<DataObjectType> experimentInputs = experiment.getExperimentInputs();
-            updateExpInputs(experimentInputs, existingExperiment);
+            if (experimentInputs != null && !experimentInputs.isEmpty()){
+                updateExpInputs(experimentInputs, existingExperiment);
+            }
+
+            UserConfigurationData userConfigurationData = experiment.getUserConfigurationData();
+            if (userConfigurationData != null) {
+                updateUserConfigData(userConfigurationData, expId);
+            }
+
+            List<DataObjectType> experimentOutputs = experiment.getExperimentOutputs();
+            if (experimentOutputs != null && !experimentOutputs.isEmpty()){
+                updateExpOutputs(experimentOutputs, expId);
+            }
+            ExperimentStatus experimentStatus = experiment.getExperimentStatus();
+            if (experimentStatus != null){
+                updateExperimentStatus(experimentStatus, expId);
+            }
+            List<WorkflowNodeDetails> workflowNodeDetailsList = experiment.getWorkflowNodeDetailsList();
+            if (workflowNodeDetailsList != null && !workflowNodeDetailsList.isEmpty()){
+                for (WorkflowNodeDetails wf : workflowNodeDetailsList){
+                    updateWorkflowNodeDetails(wf, wf.getNodeInstanceId());
+                }
+            }
         } catch (Exception e) {
             logger.error("Error while updating experiment...", e.getMessage());
             throw new Exception(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/0a470ce9/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentInputResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentInputResourceTest.java
b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentInputResourceTest.java
index e9bda26..318b044 100644
--- a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentInputResourceTest.java
+++ b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentInputResourceTest.java
@@ -1,61 +1,75 @@
-///*
-// *
-// * Licensed to the Apache Software Foundation (ASF) under one
-// * or more contributor license agreements.  See the NOTICE file
-// * distributed with this work for additional information
-// * regarding copyright ownership.  The ASF licenses this file
-// * to you under the Apache License, Version 2.0 (the
-// * "License"); you may not use this file except in compliance
-// * with the License.  You may obtain a copy of the License at
-// *
-// *   http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing,
-// * software distributed under the License is distributed on an
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// * KIND, either express or implied.  See the License for the
-// * specific language governing permissions and limitations
-// * under the License.
-// *
-// */
-//
-//package org.apache.airavata.persistance.registry.jpa;
-//
-//import org.apache.airavata.persistance.registry.jpa.resources.*;
-//
-//import java.util.Map;
-//
-//public class ExperimentInputResourceTest extends AbstractResourceTest  {
-//    private ExperimentMetadataResource experimentResource;
-//    @Override
-//    public void setUp() throws Exception {
-//        super.setUp();
-//        super.setUp();
-//        GatewayResource gatewayResource = super.getGatewayResource();
-//        WorkerResource workerResource = super.getWorkerResource();
-//        ProjectResource projectResource = new ProjectResource(workerResource, gatewayResource,
"testProject");
-//        projectResource.save();
-//
-//        experimentResource = (ExperimentMetadataResource) gatewayResource.create(ResourceType.EXPERIMENT_METADATA);
-//        experimentResource.setExpID("testExpID");
-//        experimentResource.setExperimentName("testExpID");
-//        experimentResource.setExecutionUser(workerResource.getUser());
-//        experimentResource.setProject(projectResource);
-//        experimentResource.save();
-//    }
-//
-//    public void testSave() throws Exception {
-//        ExperimentInputResource experimentInputResource = new ExperimentInputResource();
-//        experimentInputResource.setExperimentMetadataResource(experimentResource);
-//        experimentInputResource.setExperimentKey("testKey");
-//        experimentInputResource.setValue("testValue");
-//        experimentInputResource.save();
-//
-//        assertTrue("Experiment input saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_INPUT,
"testExpID"));
-//    }
-//
-//    @Override
-//    public void tearDown() throws Exception {
-//        super.tearDown();
-//    }
-//}
+/*
+*
+* 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.persistance.registry.jpa;
+
+import org.apache.airavata.persistance.registry.jpa.resources.*;
+import org.junit.After;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class ExperimentInputResourceTest extends AbstractResourceTest  {
+    private ExperimentResource experimentResource;
+    private String experimentID = "testExpID";
+    ExperimentInputResource experimentInputResource;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+        experimentResource.setExpID(experimentID);
+        experimentResource.setExecutionUser(getWorkerResource().getUser());
+        experimentResource.setProject(getProjectResource());
+        experimentResource.setCreationTime(getCurrentTimestamp());
+        experimentResource.setApplicationId("testApplication");
+        experimentResource.setApplicationVersion("1.0");
+        experimentResource.setDescription("Test Application");
+        experimentResource.setExpName("TestExperiment");
+        experimentResource.save();
+
+        experimentInputResource = (ExperimentInputResource)experimentResource.create(ResourceType.EXPERIMENT_INPUT);
+        experimentInputResource.setExperimentResource(experimentResource);
+        experimentInputResource.setExperimentKey("testKey");
+        experimentInputResource.setValue("testValue");
+        experimentInputResource.setInputType("string");
+        experimentInputResource.save();
+    }
+
+    @Test
+    public void testSave() throws Exception {
+        assertTrue("Experiment Input saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_INPUT,
experimentID));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testGet () throws Exception {
+        List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs();
+        System.out.println("input counts : " + experimentInputs.size());
+        assertTrue("Experiment input retrieved successfully...", experimentInputs.size()
> 0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/0a470ce9/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentOutputResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentOutputResourceTest.java
b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentOutputResourceTest.java
new file mode 100644
index 0000000..ad8ae7f
--- /dev/null
+++ b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentOutputResourceTest.java
@@ -0,0 +1,76 @@
+/*
+*
+* 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.persistance.registry.jpa;
+
+import org.apache.airavata.persistance.registry.jpa.resources.ExperimentOutputResource;
+import org.apache.airavata.persistance.registry.jpa.resources.ExperimentResource;
+import org.junit.After;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class ExperimentOutputResourceTest extends AbstractResourceTest  {
+    private ExperimentResource experimentResource;
+    private String experimentID = "testExpID";
+    ExperimentOutputResource outputResource;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+        experimentResource.setExpID(experimentID);
+        experimentResource.setExecutionUser(getWorkerResource().getUser());
+        experimentResource.setProject(getProjectResource());
+        experimentResource.setCreationTime(getCurrentTimestamp());
+        experimentResource.setApplicationId("testApplication");
+        experimentResource.setApplicationVersion("1.0");
+        experimentResource.setDescription("Test Application");
+        experimentResource.setExpName("TestExperiment");
+        experimentResource.save();
+
+        outputResource = (ExperimentOutputResource)experimentResource.create(ResourceType.EXPERIMENT_OUTPUT);
+        outputResource.setExperimentResource(experimentResource);
+        outputResource.setExperimentKey("testKey");
+        outputResource.setValue("testValue");
+        outputResource.setOutputType("string");
+        outputResource.save();
+    }
+
+    @Test
+    public void testSave() throws Exception {
+        assertTrue("Experiment output saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_OUTPUT,
experimentID));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testGet () throws Exception {
+        List<ExperimentOutputResource> outputs = experimentResource.getExperimentOutputs();
+        System.out.println("output counts : " + outputs.size());
+        assertTrue("Experiment output retrieved successfully...", outputs.size() > 0);
+    }
+}


Mime
View raw message