You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/08/07 11:05:33 UTC

stratos git commit: Update cartridge update with integration test

Repository: stratos
Updated Branches:
  refs/heads/tenant-isolation 523f7726a -> 4676e749a


Update cartridge update with integration test


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4676e749
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4676e749
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4676e749

Branch: refs/heads/tenant-isolation
Commit: 4676e749a1c9a57db49e2eefba585596cf73b803
Parents: 523f772
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Fri Aug 7 14:35:15 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Fri Aug 7 14:35:15 2015 +0530

----------------------------------------------------------------------
 .../stratos/rest/endpoint/api/StratosApiV41Utils.java | 11 ++++-------
 .../rest/endpoint/util/converter/ObjectConverter.java |  6 +++---
 .../integration/tests/SampleApplicationsTest.java     | 14 +++++++-------
 3 files changed, 14 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4676e749/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index b83bde6..b65c0ea 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -1104,7 +1104,7 @@ public class StratosApiV41Utils {
         }
 
         ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(
-                serviceGroupDefinition, tenantId);
+                serviceGroupDefinition,UUID.randomUUID().toString(), tenantId);
 
         AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
         try {
@@ -1132,9 +1132,6 @@ public class StratosApiV41Utils {
         try {
             AutoscalerServiceClient autoscalerServiceClient = AutoscalerServiceClient.getInstance();
             ServiceGroup existingServiceGroup =autoscalerServiceClient.getServiceGroupByTenant(cartridgeGroup.getName(), tenantId);
-            ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(
-                    cartridgeGroup, tenantId);
-
 
             StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
 
@@ -1155,14 +1152,14 @@ public class StratosApiV41Utils {
             //validate the group definition to check for cyclic group behaviour
             validateGroupDuplicationInGroupDefinition(cartridgeGroup);
 
-            if (serviceGroup != null) {
+            if (existingServiceGroup != null) {
                 autoscalerServiceClient.updateServiceGroup(
-                        ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(cartridgeGroup, tenantId));
+                        ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(cartridgeGroup,existingServiceGroup.getUuid(), tenantId));
 
                 List<String> cartridgesBeforeUpdating = new ArrayList<String>();
                 List<String> cartridgesAfterUpdating = new ArrayList<String>();
 
-                ServiceGroup serviceGroupToBeUpdated = autoscalerServiceClient.getServiceGroup(serviceGroup.getUuid());
+                ServiceGroup serviceGroupToBeUpdated = autoscalerServiceClient.getServiceGroup(existingServiceGroup.getUuid());
                 findCartridgesInServiceGroup(serviceGroupToBeUpdated, cartridgesBeforeUpdating);
                 findCartridgesInGroupBean(cartridgeGroup, cartridgesAfterUpdating);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4676e749/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index e9c1fc7..a6688b7 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -1846,7 +1846,7 @@ public class ObjectConverter {
         return carbonTenantInfoBean;
     }
 
-    public static ServiceGroup convertServiceGroupDefinitionToASStubServiceGroup(CartridgeGroupBean groupBean,
+    public static ServiceGroup convertServiceGroupDefinitionToASStubServiceGroup(CartridgeGroupBean groupBean,String groupUuid,
                                                                                  int tenantId)
             throws ServiceGroupDefinitionException {
 
@@ -1859,7 +1859,7 @@ public class ObjectConverter {
         List<String> cartridgesDefinitions = groupBean.getCartridges();
 
         servicegroup.setName(groupBean.getName());
-        servicegroup.setUuid(UUID.randomUUID().toString());
+        servicegroup.setUuid(groupUuid);
         servicegroup.setTenantId(tenantId);
 
         if (groupsDefinitions == null) {
@@ -1875,7 +1875,7 @@ public class ObjectConverter {
 
         int i = 0;
         for (CartridgeGroupBean groupDefinition : groupsDefinitions) {
-            subGroups[i] = convertServiceGroupDefinitionToASStubServiceGroup(groupDefinition, tenantId);
+            subGroups[i] = convertServiceGroupDefinitionToASStubServiceGroup(groupDefinition,UUID.randomUUID().toString(), tenantId);
             ++i;
         }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4676e749/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index b98adad..9ba0e84 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -165,14 +165,14 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                     restClient);
             assertEquals(bean.getName(), "G1");
 
-        /*    boolean updated = cartridgeGroupTest.updateCartridgeGroup("cartrdige-nested.json",
+            boolean updated = cartridgeGroupTest.updateCartridgeGroup("cartrdige-nested.json",
                     endpoint, restClient);
             assertEquals(updated, true);
             CartridgeGroupBean updatedBean = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
                     restClient);
-            assertEquals(updatedBean.getName(), "G1");    */
+            assertEquals(updatedBean.getName(), "G1");
 
-            boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
+         /*   boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
                     restClient);
             assertEquals(removedC1, false);
 
@@ -182,7 +182,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
 
             boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
                     restClient);
-            assertEquals(removedC3, false);
+            assertEquals(removedC3, false);    */
 
 
             boolean removed = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
@@ -193,15 +193,15 @@ public class SampleApplicationsTest extends StratosTestServerManager {
                     restClient);
             assertEquals(beanRemoved, null);
 
-            removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
+            boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
                     restClient);
             assertEquals(removedC1, true);
 
-            removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
+            boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
                     restClient);
             assertEquals(removedC2, true);
 
-            removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
+            boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
                     restClient);
             assertEquals(removedC3, true);