stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject stratos git commit: Update application update with integration test
Date Fri, 07 Aug 2015 07:59:01 GMT
Repository: stratos
Updated Branches:
  refs/heads/tenant-isolation 464ee1e1a -> 523f7726a


Update application 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/523f7726
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/523f7726
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/523f7726

Branch: refs/heads/tenant-isolation
Commit: 523f7726af2691e9ae005fd4c57cd39e09a0a451
Parents: 464ee1e
Author: Gayan Gunarathne <gayang@wso2.com>
Authored: Fri Aug 7 13:27:32 2015 +0530
Committer: Gayan Gunarathne <gayang@wso2.com>
Committed: Fri Aug 7 13:27:32 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41.java        |  2 +-
 .../rest/endpoint/api/StratosApiV41Utils.java   | 47 ++++++++++----------
 .../util/converter/ObjectConverter.java         | 10 ++---
 .../tests/SampleApplicationsTest.java           | 10 ++---
 .../update/g-sc-G123-1.json                     |  2 +-
 5 files changed, 36 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/523f7726/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index f0d9bc8..e7f16b3 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -825,7 +825,7 @@ public class StratosApiV41 extends AbstractApi {
         try {
             StratosApiV41Utils.updateApplication(applicationDefinition, getConfigContext(),
                     getUsername(), getTenantDomain());
-            URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinition.getApplicationUuid()).build();
+            URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinition.getApplicationId()).build();
             return Response.created(url).entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS,
                     String.format("Application updated successfully: [application] %s",
                             applicationDefinition.getApplicationUuid()))).build();

http://git-wip-us.apache.org/repos/asf/stratos/blob/523f7726/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 d9934b3..b83bde6 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
@@ -1466,10 +1466,10 @@ public class StratosApiV41Utils {
 
         // To validate groups have unique alias in the application definition
         validateGroupsInApplicationDefinition(appDefinition);
-
-
+        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+        String applicationUuid=UUID.randomUUID().toString();
         ApplicationContext applicationContext = ObjectConverter.convertApplicationDefinitionToStubApplicationContext(
-                appDefinition);
+                appDefinition,applicationUuid,carbonContext.getTenantId());
         applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
         applicationContext.setTenantDomain(tenantDomain);
         applicationContext.setTenantAdminUsername(userName);
@@ -1521,32 +1521,33 @@ public class StratosApiV41Utils {
                                          String userName, String tenantDomain)
             throws RestAPIException, AutoscalerServiceCartridgeNotFoundExceptionException,
AutoscalerServiceCartridgeGroupNotFoundExceptionException {
 
-        if (StringUtils.isBlank(appDefinition.getApplicationUuid())) {
+        if (StringUtils.isBlank(appDefinition.getApplicationId())) {
             String message = "Please specify the application name";
             log.error(message);
             throw new RestAPIException(message);
         }
-
-        validateApplication(appDefinition);
-
-        ApplicationContext applicationContext = ObjectConverter.convertApplicationDefinitionToStubApplicationContext(
-                appDefinition);
-        applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
-        applicationContext.setTenantDomain(tenantDomain);
-        applicationContext.setTenantAdminUsername(userName);
-
-        if (appDefinition.getProperty() != null) {
-            org.apache.stratos.autoscaler.stub.Properties properties = new org.apache.stratos.autoscaler.stub.Properties();
-            for (PropertyBean propertyBean : appDefinition.getProperty()) {
-                org.apache.stratos.autoscaler.stub.Property property = new org.apache.stratos.autoscaler.stub.Property();
-                property.setName(propertyBean.getName());
-                property.setValue(propertyBean.getValue());
-                properties.addProperties(property);
+        try {
+            validateApplication(appDefinition);
+            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            String applicationUuid = AutoscalerServiceClient.getInstance().getApplicationByTenant(appDefinition.getApplicationId(),
carbonContext.getTenantId()).getApplicationUuid();
+            ApplicationContext applicationContext = ObjectConverter.convertApplicationDefinitionToStubApplicationContext(
+                    appDefinition,applicationUuid,carbonContext.getTenantId());
+            applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
+            applicationContext.setTenantDomain(tenantDomain);
+            applicationContext.setTenantAdminUsername(userName);
+
+            if (appDefinition.getProperty() != null) {
+                org.apache.stratos.autoscaler.stub.Properties properties = new org.apache.stratos.autoscaler.stub.Properties();
+                for (PropertyBean propertyBean : appDefinition.getProperty()) {
+                    org.apache.stratos.autoscaler.stub.Property property = new org.apache.stratos.autoscaler.stub.Property();
+                    property.setName(propertyBean.getName());
+                    property.setValue(propertyBean.getValue());
+                    properties.addProperties(property);
+                }
+                applicationContext.setProperties(properties);
             }
-            applicationContext.setProperties(properties);
-        }
 
-        try {
+
             AutoscalerServiceClient.getInstance().updateApplication(applicationContext);
         } catch (AutoscalerServiceApplicationDefinitionExceptionException e) {
             String message = e.getFaultMessage().getApplicationDefinitionException().getMessage();

http://git-wip-us.apache.org/repos/asf/stratos/blob/523f7726/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 861fd20..e9c1fc7 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
@@ -1132,18 +1132,18 @@ public class ObjectConverter {
     }
 
     public static ApplicationContext convertApplicationDefinitionToStubApplicationContext(
-            ApplicationBean applicationDefinition) throws RestAPIException {
+            ApplicationBean applicationDefinition,String applicationUuid,int tenantId) throws
RestAPIException {
 
         org.apache.stratos.autoscaler.stub.pojo.ApplicationContext applicationContext =
                 new org.apache.stratos.autoscaler.stub.pojo.ApplicationContext();
-        applicationContext.setApplicationUuid(applicationDefinition.getApplicationUuid());
+        applicationContext.setApplicationUuid(applicationUuid);
         applicationContext.setApplicationId(applicationDefinition.getApplicationId());
         applicationContext.setAlias(applicationDefinition.getAlias());
         applicationContext.setMultiTenant(applicationDefinition.isMultiTenant());
         applicationContext.setName(applicationDefinition.getName());
         applicationContext.setDescription(applicationDefinition.getDescription());
         applicationContext.setStatus(applicationDefinition.getStatus());
-        applicationContext.setTenantId(applicationDefinition.getTenantId());
+        applicationContext.setTenantId(tenantId);
 
         // convert and set components
         if (applicationDefinition.getComponents() != null) {
@@ -1154,7 +1154,7 @@ public class ObjectConverter {
             if (applicationDefinition.getComponents().getGroups() != null) {
                 componentContext.setGroupContexts(
                         convertGroupDefinitionsToStubGroupContexts(applicationDefinition.getComponents().getGroups(),
-                                applicationDefinition.getTenantId()));
+                                tenantId));
             }
             // top level dependency information
             if (applicationDefinition.getComponents().getDependencies() != null) {
@@ -1164,7 +1164,7 @@ public class ObjectConverter {
             // top level cartridge context information
             if (applicationDefinition.getComponents().getCartridges() != null) {
                 componentContext.setCartridgeContexts(convertCartridgeReferenceBeansToStubCartridgeContexts
-                        (applicationDefinition.getComponents().getCartridges(), applicationDefinition.getTenantId()));
+                        (applicationDefinition.getComponents().getCartridges(),tenantId));
             }
             applicationContext.setComponents(componentContext);
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/523f7726/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 3b89161..b98adad 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
@@ -279,7 +279,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(),
"c3");
             assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(),
1);
             assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(),
2);
-            /*
+
             boolean updated = applicationTest.updateApplication("g-sc-G123-1.json",
                     endpoint, restClient);
             assertEquals(updated, true);
@@ -315,7 +315,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(),
2);
             assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(),
3);
 
-
+            /*
             boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
                     restClient);
             assertEquals(removedGroup, false);
@@ -451,15 +451,15 @@ public class SampleApplicationsTest extends StratosTestServerManager
{
             assertClusterActivation(bean.getApplicationUuid());
 
             //Updating application
-          /*  boolean updated = applicationTest.updateApplication("g-sc-G123-1.json",
+            boolean updated = applicationTest.updateApplication("g-sc-G123-1.json",
                     endpoint, restClient);
             assertEquals(updated, true);
 
-            assertGroupInstanceCount(bean.getApplicationId(), "group3", 2);
+            assertGroupInstanceCount(bean.getApplicationUuid(), "group3", 2);
             ApplicationBean updatedBean = applicationTest.getApplication("g-sc-G123-1", endpoint,
                     restClient);
             assertEquals(updatedBean.getApplicationId(), "g-sc-G123-1");
-
+            /*
             boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
                     restClient);
             assertEquals(removedGroup, false);

http://git-wip-us.apache.org/repos/asf/stratos/blob/523f7726/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
index ff332c0..a91c4e0 100644
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
+++ b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
@@ -56,7 +56,7 @@
                                 "name": "G3",
                                 "groupMaxInstances": 3,
                                 "groupMinInstances": 2,
-                                "deploymentPolicy": "static-1",
+                                "deploymentPolicy": "deployment-policy-1",
                                 "alias": "group3",
                                 "cartridges": [
                                     {


Mime
View raw message