You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by sa...@apache.org on 2015/11/11 09:46:00 UTC

stratos git commit: Adding validation logic when startup order is defined in application. Added test case. Fixing STRATOS-1545

Repository: stratos
Updated Branches:
  refs/heads/stratos-4.1.x 8bdb54a9b -> 00f624b48


Adding validation logic when startup order is defined in application. Added test case. Fixing STRATOS-1545


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

Branch: refs/heads/stratos-4.1.x
Commit: 00f624b48ed6f8a80b8bd50c08d0553fc587f129
Parents: 8bdb54a
Author: Sajith <sa...@wso2.com>
Authored: Wed Nov 11 14:15:07 2015 +0530
Committer: Sajith <sa...@wso2.com>
Committed: Wed Nov 11 14:15:07 2015 +0530

----------------------------------------------------------------------
 .../parser/DefaultApplicationParser.java        |   7 +-
 .../applications/parser/ParserUtils.java        |  43 +++++
 .../ApplicationStartupOrderTestCase.java        | 176 +++++++++++++++++++
 .../application-policy-1.json                   |  17 ++
 .../applications/application.json               | 135 ++++++++++++++
 .../autoscaling-policy-1.json                   |  14 ++
 .../cartridges-groups/app-group.json            |  20 +++
 .../cartridges-groups/db-group.json             |  13 ++
 .../cartridges/mock/esb.json                    |  50 ++++++
 .../cartridges/mock/mysql.json                  |  50 ++++++
 .../cartridges/mock/php.json                    |  51 ++++++
 .../cartridges/mock/postgres.json               |  50 ++++++
 .../cartridges/mock/tomcat.json                 |  53 ++++++
 .../deployment-policy-1.json                    |  15 ++
 .../deployment-policy-2.json                    |  29 +++
 .../mock/network-partition-1.json               |  15 ++
 .../mock/network-partition-2.json               |  24 +++
 17 files changed, 760 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
index d9378ab..1d93a0e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java
@@ -294,7 +294,9 @@ public class DefaultApplicationParser implements ApplicationParser {
                     if (log.isDebugEnabled()) {
                         log.debug("Parsing application: startupOrders != null for app alias: " +
                                 applicationContext.getAlias() + " #: " + startupOrders.length);
-                    }
+                    }                    
+                    // validate alias
+                    ParserUtils.validateStartupOrderAlias(startupOrders, applicationContext);
                     dependencyOrder.setStartupOrders(ParserUtils.convertStartupOrder(startupOrders));
                 } else {
                     if (log.isDebugEnabled()) {
@@ -355,8 +357,9 @@ public class DefaultApplicationParser implements ApplicationParser {
         }
         return application;
     }
+   
 
-    /**
+	/**
      * Parse Subscription Information
      *
      * @param appId                Application id

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
index aa42b7f..5cd44f1 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java
@@ -19,7 +19,9 @@
 
 package org.apache.stratos.autoscaler.applications.parser;
 
+import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext;
 import org.apache.stratos.autoscaler.applications.pojo.CartridgeContext;
+import org.apache.stratos.autoscaler.applications.pojo.ComponentContext;
 import org.apache.stratos.autoscaler.applications.pojo.GroupContext;
 import org.apache.stratos.autoscaler.exception.application.ApplicationDefinitionException;
 import org.apache.stratos.autoscaler.util.AutoscalerConstants;
@@ -110,6 +112,47 @@ public class ParserUtils {
         return startupOrders;
     }
 
+    
+    public static void validateStartupOrderAlias(String[] startupOrderArr, ApplicationContext applicationContext)
+            throws ApplicationDefinitionException {
+
+        for (String commaSeparatedStartupOrder : startupOrderArr) {
+            List<String> components = Arrays.asList(commaSeparatedStartupOrder.split(","));
+            for (String component : components) {
+                boolean aliasFound = false;
+                if (component.startsWith(AutoscalerConstants.GROUP)) {
+                    String groupAlias = component.substring(AutoscalerConstants.GROUP.length() + 1);
+                    if (applicationContext.getComponents().getGroupContexts() != null) {
+                        for (GroupContext context : applicationContext.getComponents().getGroupContexts()) {
+                            if (context.getAlias().equals(groupAlias)) {
+                                aliasFound = true;
+                            }
+                        }
+                    }
+
+                } else {
+                    String cartridgeAlias = component.substring(
+                            AutoscalerConstants.CARTRIDGE.length() + 1);
+                    if (applicationContext.getComponents().getCartridgeContexts() != null) {
+                        for (CartridgeContext context : applicationContext.getComponents().getCartridgeContexts()) {
+                            if (context.getSubscribableInfoContext().getAlias().equals(cartridgeAlias)) {
+                                aliasFound = true;
+                            }
+                        }
+                    }
+                }
+                if (!aliasFound) {
+                    String msg = "The startup-order defined in the [application] " + applicationContext.getApplicationId()
+                            + " is not correct. [startup-order-alias] " + component +
+                            " is not there in the application.";
+                    throw new ApplicationDefinitionException(msg);
+                }
+            }
+        }
+
+    }
+    
+    
     private static StartupOrder getStartupOrder(List<String> components, GroupContext groupContext)
             throws ApplicationDefinitionException {
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationStartupOrderTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationStartupOrderTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationStartupOrderTestCase.java
new file mode 100644
index 0000000..46acc97
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationStartupOrderTestCase.java
@@ -0,0 +1,176 @@
+/*
+ * 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.stratos.integration.tests.application;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.testng.AssertJUnit.assertTrue;
+
+import org.apache.stratos.integration.common.RestConstants;
+import org.apache.stratos.integration.tests.StratosIntegrationTest;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
+import org.testng.annotations.Test;
+
+/**
+ * Handling the startup order of the application
+ */
+public class ApplicationStartupOrderTestCase extends StratosIntegrationTest {
+    private static final String RESOURCES_PATH = "/application-startup-order-test";
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Test(timeOut = APPLICATION_TEST_TIMEOUT, groups = {"stratos.application.deployment"})
+    public void testApplicationStartupOrder() throws Exception {
+    	
+    	thrown.expect(RuntimeException.class);
+    	thrown.expectMessage(
+    			"{\"status\":\"error\",\"message\":\"The startup-order defined in the [application] my-compositeapp is not correct. [startup-order-alias] group.my-dbgroup3333 is not there in the application.\"}");
+        String autoscalingPolicyId = "autoscaling-policy-1";
+
+        boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+                        + "/" + autoscalingPolicyId + ".json",
+                RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+        assertTrue(addedScalingPolicy);
+
+        boolean addedC1 = restClient.addEntity(
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb.json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue(addedC1);
+
+        boolean addedC2 = restClient.addEntity(
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue(addedC2);
+
+        boolean addedC3 = restClient.addEntity(
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "mysql.json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue(addedC3);
+
+        boolean addedC5 = restClient.addEntity(
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "postgres.json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue(addedC5);
+
+        boolean addedC6 = restClient.addEntity(
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue(addedC6);
+
+        boolean addedG2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                        "/" + "app-group.json", RestConstants.CARTRIDGE_GROUPS,
+                RestConstants.CARTRIDGE_GROUPS_NAME);
+        assertTrue(addedG2);
+
+        boolean addedG3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+                        "/" + "db-group.json", RestConstants.CARTRIDGE_GROUPS,
+                RestConstants.CARTRIDGE_GROUPS_NAME);
+        assertTrue(addedG3);
+
+        boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                        "network-partition-1.json",
+                RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(addedN1);
+        
+        boolean addedN2 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                		"network-partition-2.json",
+        RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(addedN2);
+        
+        boolean addedDep1 = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                        "deployment-policy-1.json",
+                RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(addedDep1);
+        
+        boolean addedDep2 = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                        "deployment-policy-2.json",
+                RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(addedDep2);
+            	     			
+    	try {
+    	  restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+                        "application.json", RestConstants.APPLICATIONS,
+                RestConstants.APPLICATIONS_NAME);
+        	fail("Should throw an exception if the aliases mentioned in dependency order section are not defined");
+    	} catch (Exception e) {
+    		assertThat(
+    				e.getMessage(),containsString("The startup-order defined in the [application] my-compositeapp is not correct. [startup-order-alias] group.my-dbgroup3333 is not there in the application."));
+    	}
+
+    	
+    	// Clean up        
+        boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
+                "app-group",
+                RestConstants.CARTRIDGE_GROUPS_NAME);
+        assertTrue(removedGroup);
+
+        removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
+                "db-group",
+                RestConstants.CARTRIDGE_GROUPS_NAME);
+        assertTrue(removedGroup);
+
+        boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+        assertTrue(removedAuto);   
+                
+        boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(removedDep);
+        
+        removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                "deployment-policy-2", RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(removedDep);
+        
+        boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                "network-partition-1",
+                RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(removedNet);
+        
+        removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                "network-partition-2",
+                RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(removedNet);
+        
+        boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC1);
+
+        boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC2);
+
+        boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "postgres",
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC3);
+
+        boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, "mysql",
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC4);
+
+        boolean removedC5 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC5);
+
+        assertTrue(true);
+    }
+   
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/application-policies/application-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/application-policies/application-policy-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/application-policies/application-policy-1.json
new file mode 100644
index 0000000..3ae0932
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/application-policies/application-policy-1.json
@@ -0,0 +1,17 @@
+	{
+    "id": "application-policy-1",
+    "algorithm": "one-after-another",
+    "networkPartitions": [
+        "network-partition-1"
+    ],
+    "properties": [
+        {
+            "name": "key-1",
+            "value": "value-1"
+        },
+        {
+            "name": "key-2",
+            "value": "value-2"
+        }
+    ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/applications/application.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/applications/application.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/applications/application.json
new file mode 100644
index 0000000..cc38810
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/applications/application.json
@@ -0,0 +1,135 @@
+{
+    "alias": "mycompositeapp",
+    "applicationId": "my-compositeapp",
+    "components": {
+        "groups": [
+            {
+                "name": "app-group",
+                "alias": "my-appgroup",
+                "cartridges": [
+                    {
+                        "type": "tomcat",
+                        "cartridgeMax": 2,
+                        "cartridgeMin": 1,
+                        "subscribableInfo": {
+                            "alias": "my-tomcat",
+                            "artifactRepository": {
+                                "alias": "my-tomcat",
+                                "privateRepo": true,
+                                "repoPassword": "password",
+                                "repoUrl": "http://xxx:10080/git/default.git",
+                                "repoUsername": "user"
+                            },
+                            "autoscalingPolicy": "autoscaling-policy-1",
+                            "deploymentPolicy": "deployment-policy-1"
+                        }
+                    },
+                    {
+                        "type": "php",
+                        "cartridgeMax": 2,
+                        "cartridgeMin": 1,
+                        "subscribableInfo": {
+                            "alias": "my-php",
+                            "artifactRepository": {
+                                "privateRepo": true,
+                                "repoPassword": "password",
+                                "repoUrl": "http://xxx:10080/git/default.git",
+                                "repoUsername": "user"
+                            },
+                            "autoscalingPolicy": "autoscaling-policy-1",
+                            "deploymentPolicy": "deployment-policy-1"
+                        }
+                    }
+                ],
+                "groupMaxInstances": 2,
+                "groupMinInstances": 1,
+                "groupScalingEnabled": true
+            },
+            {
+                "name": "db-group",
+                "alias": "my-dbgroup",
+                "cartridges": [
+                    {
+                        "type": "postgres",
+                        "cartridgeMax": 2,
+                        "cartridgeMin": 1,
+                        "subscribableInfo": {
+                            "alias": "my-postgres",
+                            "artifactRepository": {
+                                "alias": "my-postgres",
+                                "privateRepo": false,
+                                "repoPassword": "password",
+                                "repoUrl": "http://xxx:10080/git/default.git",
+                                "repoUsername": "user"
+                            },
+                            "autoscalingPolicy": "autoscaling-policy-1",
+                            "deploymentPolicy": "deployment-policy-1"
+                        }
+                    },
+                    {
+                        "type": "mysql",
+                        "cartridgeMax": 2,
+                        "cartridgeMin": 1,
+                        "subscribableInfo": {
+                            "alias": "my-mysql",
+                            "artifactRepository": {
+                                "alias": "my-mysql",
+                                "privateRepo": true,
+                                "repoPassword": "password",
+                                "repoUrl": "http://xxx:10080/git/default.git",
+                                "repoUsername": "user"
+                            },
+                            "autoscalingPolicy": "autoscaling-policy-1",
+                            "deploymentPolicy": "deployment-policy-1"
+                        }
+                    }
+                ],
+                "groupMaxInstances": 2,
+                "groupMinInstances": 1,
+                "groupScalingEnabled": true
+            }
+        ],
+        "cartridges": [
+            {
+                "type": "esb",
+                "cartridgeMax": 2,
+                "cartridgeMin": 1,
+                "subscribableInfo": {
+                    "alias": "my-esb",
+                    "artifactRepository": {
+                        "privateRepo": true,
+                        "repoPassword": "password",
+                        "repoUrl": "http://xxx:10080/git/default.git",
+                        "repoUsername": "user"
+                    },
+                    "autoscalingPolicy": "autoscaling-policy-1",
+                    "deploymentPolicy": "deployment-policy-1"
+                }
+            }
+        ],
+        "dependencies": {
+            "scalingDependents": [
+                {
+                    "aliases": [
+                        "group.my-appgroup, cartridge.my-esb"
+                    ]
+                }
+            ],
+            "startupOrders": [
+                {
+                    "aliases": [
+                        "group.my-dbgroup3333",
+                        "group.my-appgroup5555"
+                    ]
+                },
+                {
+                    "aliases": [
+                        "group.my-dbgroup555",
+                        "cartridge.my-esb66666"
+                    ]
+                }
+            ],
+            "terminationBehaviour": "terminate-none"
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/autoscaling-policies/autoscaling-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/autoscaling-policies/autoscaling-policy-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/autoscaling-policies/autoscaling-policy-1.json
new file mode 100644
index 0000000..a95d4fc
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/autoscaling-policies/autoscaling-policy-1.json
@@ -0,0 +1,14 @@
+{
+    "id": "autoscaling-policy-1",
+    "loadThresholds": {
+        "requestsInFlight": {
+            "threshold": 20
+        },
+        "memoryConsumption": {
+            "threshold": 70
+        },
+        "loadAverage": {
+            "threshold": 70
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/app-group.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/app-group.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/app-group.json
new file mode 100644
index 0000000..9644bc3
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/app-group.json
@@ -0,0 +1,20 @@
+{
+    "name": "app-group",
+    "cartridges": [
+        "tomcat",
+        "php"
+    ],
+    "dependencies": {
+        "terminationBehaviour": "terminate-all",
+        "startupOrders": [
+            {
+                "aliases": [
+                    "cartridge.my-php",
+                    "cartridge.my-tomcat"
+                ]
+            }
+        ]
+    },
+    "groupScalingEnabled": true
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/db-group.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/db-group.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/db-group.json
new file mode 100644
index 0000000..1ca2cd1
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges-groups/db-group.json
@@ -0,0 +1,13 @@
+{
+    "name": "db-group",
+    "cartridges": [
+        "mysql",
+        "postgres"
+    ],
+    "dependencies": {
+        "terminationBehaviour": "terminate-all"
+    },
+    "groupScalingEnabled": true
+}
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/esb.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/esb.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/esb.json
new file mode 100644
index 0000000..88c6348
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/esb.json
@@ -0,0 +1,50 @@
+{
+    "type": "esb",
+    "provider": "apache",
+    "host": "stratos.apache.org",
+    "category": "framework",
+    "displayName": "c4",
+    "description": "mysql Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ],
+    "metadataKeys": [
+        "server_ip",
+        "username",
+        "password"
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/mysql.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/mysql.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/mysql.json
new file mode 100644
index 0000000..9fc328d
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/mysql.json
@@ -0,0 +1,50 @@
+{
+    "type": "mysql",
+    "provider": "apache",
+    "host": "stratos.apache.org",
+    "category": "data",
+    "displayName": "c4",
+    "description": "mysql Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ],
+    "metadataKeys": [
+        "server_ip",
+        "username",
+        "password"
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/php.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/php.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/php.json
new file mode 100644
index 0000000..5d53e3a
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/php.json
@@ -0,0 +1,51 @@
+{
+    "type": "php",
+    "provider": "apache",
+    "category": "framework",
+    "host": "php.stratos.org",
+    "displayName": "php",
+    "description": "php Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-80",
+            "protocol": "http",
+            "port": "8080",
+            "proxyPort": "8280"
+        },
+        {
+            "name": "http-22",
+            "protocol": "tcp",
+            "port": "22",
+            "proxyPort": "8222"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "reka"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/postgres.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/postgres.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/postgres.json
new file mode 100644
index 0000000..05a510a
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/postgres.json
@@ -0,0 +1,50 @@
+{
+    "type": "postgres",
+    "provider": "apache",
+    "host": "stratos.apache.org",
+    "category": "data",
+    "displayName": "c4",
+    "description": "mysql Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ],
+    "metadataKeys": [
+        "server_ip",
+        "username",
+        "password"
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/tomcat.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/tomcat.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/tomcat.json
new file mode 100644
index 0000000..395687d
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/cartridges/mock/tomcat.json
@@ -0,0 +1,53 @@
+{
+    "type": "tomcat",
+    "provider": "apache",
+    "host": "tomcat.stratos.org",
+    "category": "framework",
+    "displayName": "tomcat",
+    "description": "tomcat Cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-22",
+            "protocol": "http",
+            "port": "22",
+            "proxyPort": "8280"
+        },
+        {
+            "protocol": "http",
+            "port": "8080",
+            "proxyPort": "80"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "vishanth-key"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ],
+    "metadataKeys": [
+        "url"
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-1.json
new file mode 100644
index 0000000..a434226
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-1.json
@@ -0,0 +1,15 @@
+{
+    "id": "deployment-policy-1",
+    "networkPartitions": [
+        {
+            "id": "network-partition-1",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 20
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-2.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-2.json
new file mode 100644
index 0000000..c62eda7
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/deployment-policies/deployment-policy-2.json
@@ -0,0 +1,29 @@
+{
+    "id": "deployment-policy-2",
+    "networkPartitions": [
+        {
+            "id": "network-partition-1",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 5
+                }
+            ]
+        },
+        {
+            "id": "network-partition-2",
+            "partitionAlgo": "round-robin",
+            "partitions": [
+                {
+                    "id": "network-partition-2-partition-1",
+                    "partitionMax": 5
+                },
+                {
+                    "id": "network-partition-2-partition-2",
+                    "partitionMax": 5
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-1.json
new file mode 100644
index 0000000..466da28
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-1.json
@@ -0,0 +1,15 @@
+{
+    "id": "network-partition-1",
+    "provider": "mock",
+    "partitions": [
+        {
+            "id": "partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/00f624b4/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-2.json b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-2.json
new file mode 100644
index 0000000..23236e2
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/application-startup-order-test/network-partitions/mock/network-partition-2.json
@@ -0,0 +1,24 @@
+{
+    "id": "network-partition-2",
+    "provider": "mock",
+    "partitions": [
+        {
+            "id": "network-partition-2-partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        },
+        {
+            "id": "network-partition-2-partition-2",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}