Restructuring the integration test and adding more test cases

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

Branch: refs/heads/master
Commit: f78ab8243cb6c1ec0c602e1e83092ab3469606b0
Parents: 8d321a2
Author: reka <[email protected]>
Authored: Tue Aug 11 13:52:12 2015 +0530
Committer: reka <[email protected]>
Committed: Wed Aug 12 08:34:01 2015 +0530

----------------------------------------------------------------------
 products/stratos/modules/integration/pom.xml    |   6 +
 .../tests/StratosTestServerManager.java         |   4 +
 .../integration/tests/TopologyHandler.java      |  97 +++++-
 .../application/ApplicationBurstingTest.java    |  68 ++--
 .../application/ApplicationUpdateTest.java      | 243 +++++++++++++++
 .../PartitionOneAfterAnotherClusterTest.java    | 298 ++++++++++++++++++
 .../PartitionRoundRobinClusterTest.java         | 305 ++++++++++++++++++
 .../application/SampleApplicationsTest.java     | 310 ++++---------------
 .../application/SingleClusterScalingTest.java   | 179 ++++++-----
 .../tests/config/ApplicationBean.java           |  25 --
 .../tests/config/ApplicationConfigParser.java   |  25 --
 .../tests/group/CartridgeGroupTest.java         |  68 ++--
 .../integration/tests/group/CartridgeTest.java  |   4 +-
 .../tests/policies/ApplicationPolicyTest.java   |  28 +-
 .../tests/policies/AutoscalingPolicyTest.java   |   2 +-
 .../tests/policies/DeploymentPolicyTest.java    |  30 +-
 .../tests/policies/NetworkPartitionTest.java    |   6 +-
 .../tests/rest/IntegrationMockClient.java       | 105 +++++++
 .../integration/tests/rest/RestClient.java      |   1 +
 .../application-policy-3.json                   |  18 --
 ...cation-policy-application-bursting-test.json |  18 ++
 .../app-bursting-single-cartriddge-group.json   |  28 +-
 .../autoscaling-policy-2.json                   |  14 -
 ...caling-policy-application-bursting-test.json |  14 +
 ...esb-php-group-application-bursting-test.json |  19 ++
 .../cartridges-groups/esb-php-group.json        |  19 --
 .../mock/esb-application-bursting-test.json     |  50 +++
 .../cartridges/mock/esb.json                    |  50 ---
 .../mock/php-application-bursting-test.json     |  51 +++
 .../cartridges/mock/php.json                    |  51 ---
 .../mock/tomcat-application-bursting-test.json  |  53 ++++
 .../cartridges/mock/tomcat.json                 |  53 ----
 .../deployment-policy-4.json                    |  32 --
 ...oyment-policy-application-bursting-test.json |  32 ++
 .../mock/network-partition-10.json              |  24 --
 .../mock/network-partition-9.json               |  15 -
 ...k-partition-application-bursting-test-1.json |  15 +
 ...k-partition-application-bursting-test-2.json |  24 ++
 .../application-policy-2.json                   |  18 --
 ...lication-policy-application-policy-test.json |  18 ++
 .../mock/network-partition-7.json               |  15 -
 .../mock/network-partition-8.json               |  24 --
 ...ork-partition-application-policy-test-1.json |  24 ++
 ...ork-partition-application-policy-test-2.json |  15 +
 ...lication-policy-application-update-test.json |  18 ++
 .../g-sc-G123-1-application-update-test-v1.json |  86 +++++
 .../g-sc-G123-1-application-update-test.json    |  86 +++++
 ...oscaling-policy-application-update-test.json |  14 +
 ...rdige-nested-application-update-test-v1.json |  50 +++
 ...artrdige-nested-application-update-test.json |  50 +++
 .../mock/c1-application-update-test.json        |  45 +++
 .../mock/c2-application-update-test.json        |  45 +++
 .../mock/c3-application-update-test.json        |  45 +++
 ...yment-policy-application-update-test-v1.json |  36 +++
 ...ployment-policy-application-update-test.json |  32 ++
 ...-partition-application-update-test-1-v1.json |  28 ++
 ...ork-partition-application-update-test-1.json |  15 +
 ...ork-partition-application-update-test-2.json |  24 ++
 ...aling-policy-autoscaling-policy-test-v1.json |  14 +
 ...oscaling-policy-autoscaling-policy-test.json |  14 +
 .../autoscaling-policy-c0-v1.json               |  14 -
 .../autoscaling-policy-c0.json                  |  14 -
 .../g4-g5-g6-cartridge-group-test-v1.json       |  50 +++
 .../g4-g5-g6-cartridge-group-test.json          |  50 +++
 .../cartridges-groups/g4-g5-g6-v1.json          |  50 ---
 .../cartridges-groups/g4-g5-g6.json             |  50 ---
 .../mock/c4-cartridge-group-test.json           |  45 +++
 .../cartridges/mock/c4.json                     |  45 ---
 .../mock/c5-cartridge-group-test.json           | 124 ++++++++
 .../cartridges/mock/c5.json                     | 124 --------
 .../mock/c6-cartridge-group-test.json           |  45 +++
 .../cartridges/mock/c6.json                     |  45 ---
 .../cartridges/mock/c0-cartridge-test-v1.json   | 124 ++++++++
 .../cartridges/mock/c0-cartridge-test.json      | 124 ++++++++
 .../cartridge-test/cartridges/mock/c0-v1.json   | 124 --------
 .../cartridge-test/cartridges/mock/c0.json      | 124 --------
 .../deployment-policy-2-v1.json                 |  36 ---
 .../deployment-policy-2.json                    |  32 --
 ...oyment-policy-deployment-policy-test-v1.json |  36 +++
 ...eployment-policy-deployment-policy-test.json |  32 ++
 .../mock/network-partition-5-v1.json            |  28 --
 .../mock/network-partition-5.json               |  15 -
 .../mock/network-partition-6.json               |  24 --
 ...k-partition-deployment-policy-test-1-v1.json |  28 ++
 ...work-partition-deployment-policy-test-1.json |  15 +
 ...work-partition-deployment-policy-test-2.json |  24 ++
 .../src/test/resources/mock-iaas.xml            |  42 ++-
 .../mock/network-partition-3-v1.json            |  28 --
 .../mock/network-partition-3.json               |  15 -
 ...ork-partition-network-partition-test-v1.json |  28 ++
 ...etwork-partition-network-partition-test.json |  15 +
 ...ation-policy-partition-round-robin-test.json |  13 +
 .../partition-round-robin-test.json             |  28 ++
 ...aling-policy-partition-round-robin-test.json |  14 +
 .../mock/c7-partition-round-robin-test.json     |  45 +++
 ...yment-policy-partition-round-robin-test.json |  22 ++
 ...rk-partition-partition-round-robin-test.json |  24 ++
 .../application-policy-1.json                   |  18 --
 ...ication-policy-sample-applications-test.json |  18 ++
 ...g-sc-G123-1-sample-applications-test-v1.json |  86 +++++
 .../g-sc-G123-1-sample-applications-test.json   |  86 +++++
 .../applications/g-sc-G123-1-v1.json            |  86 -----
 .../applications/g-sc-G123-1-v2.json            |  86 -----
 .../applications/g-sc-G123-1-v3.json            |  86 -----
 .../applications/g-sc-G123-1.json               |  86 -----
 .../autoscaling-policy-1.json                   |  14 -
 ...scaling-policy-sample-applications-test.json |  14 +
 ...dige-nested-sample-applications-test-v1.json |  50 +++
 ...rtrdige-nested-sample-applications-test.json |  50 +++
 .../cartridges-groups/cartrdige-nested-v1.json  |  50 ---
 .../cartridges-groups/cartrdige-nested.json     |  50 ---
 .../mock/c1-sample-applications-test.json       |  45 +++
 .../cartridges/mock/c1.json                     |  45 ---
 .../mock/c2-sample-applications-test.json       |  45 +++
 .../cartridges/mock/c2.json                     |  45 ---
 .../mock/c3-sample-applications-test.json       |  45 +++
 .../cartridges/mock/c3.json                     |  45 ---
 .../deployment-policy-1-v1.json                 |  36 ---
 .../deployment-policy-1.json                    |  32 --
 ...ment-policy-sample-applications-test-v1.json |  36 +++
 ...loyment-policy-sample-applications-test.json |  32 ++
 .../mock/network-partition-1-v1.json            |  28 --
 .../mock/network-partition-1.json               |  15 -
 .../mock/network-partition-2.json               |  24 --
 ...partition-sample-applications-test-1-v1.json |  28 ++
 ...rk-partition-sample-applications-test-1.json |  15 +
 ...rk-partition-sample-applications-test-2.json |  24 ++
 ...tion-policy-single-cluster-scaling-test.json |  13 +
 .../single-cluster-scaling-test.json            |  28 ++
 ...ling-policy-single-cluster-scaling-test.json |  14 +
 .../mock/c7-single-cluster-scaling-test.json    |  45 +++
 ...ment-policy-single-cluster-scaling-test.json |  22 ++
 ...k-partition-single-cluster-scaling-test.json |  24 ++
 .../src/test/resources/stratos-testing.xml      |  20 +-
 134 files changed, 3921 insertions(+), 2361 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/pom.xml 
b/products/stratos/modules/integration/pom.xml
index fc1592d..992b2a2 100755
--- a/products/stratos/modules/integration/pom.xml
+++ b/products/stratos/modules/integration/pom.xml
@@ -99,6 +99,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.mock.iaas.client</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.wso2.andes.wso2</groupId>
             <artifactId>andes-client</artifactId>
             <version>0.13.wso2v8</version>

http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
index aba5911..342df28 100755
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
@@ -27,7 +27,9 @@ import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.stratos.common.test.TestLogAppender;
 import org.apache.stratos.integration.tests.application.SampleApplicationsTest;
+import org.apache.stratos.integration.tests.rest.IntegrationMockClient;
 import org.apache.stratos.integration.tests.rest.RestClient;
+import org.apache.stratos.mock.iaas.client.MockIaasApiClient;
 import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeSuite;
 import org.wso2.carbon.integration.framework.TestServerManager;
@@ -62,11 +64,13 @@ public class StratosTestServerManager extends 
TestServerManager {
     private TestLogAppender testLogAppender = new TestLogAppender();
     private ServerUtils serverUtils;
     private String carbonHome;
+    protected IntegrationMockClient mockIaasApiClient;
 
     public StratosTestServerManager() {
         super(CARBON_ZIP, PORT_OFFSET);
         serverUtils = new ServerUtils();
         restClient = new RestClient(endpoint, "admin", "admin");
+        mockIaasApiClient = new IntegrationMockClient(endpoint + 
"/mock-iaas/api");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
index ec63f84..4f2353c 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
 import org.apache.stratos.common.client.AutoscalerServiceClient;
 import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.integration.tests.rest.IntegrationMockClient;
 import org.apache.stratos.messaging.domain.application.*;
 import org.apache.stratos.messaging.domain.instance.ClusterInstance;
 import org.apache.stratos.messaging.domain.instance.GroupInstance;
@@ -31,21 +32,27 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.Member;
 import org.apache.stratos.messaging.domain.topology.MemberStatus;
 import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.topology.MemberCreatedEvent;
+import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
+import 
org.apache.stratos.messaging.listener.topology.MemberCreatedEventListener;
 import 
org.apache.stratos.messaging.listener.topology.MemberInitializedEventListener;
+import 
org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener;
 import 
org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
 import 
org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
 import 
org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.mock.iaas.client.MockIaasApiClient;
 
 import java.io.File;
 import java.rmi.RemoteException;
 import java.util.Collection;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.*;
 
 /**
  * To start the Topology receivers
@@ -53,13 +60,16 @@ import static junit.framework.Assert.assertNull;
 public class TopologyHandler {
     private static final Log log = LogFactory.getLog(TopologyHandler.class);
 
-    public static final int APPLICATION_ACTIVATION_TIMEOUT = 120000;
+    public static final int APPLICATION_ACTIVATION_TIMEOUT = 180000;
+    public static final int APPLICATION_UNDEPLOYMENT_TIMEOUT = 60000;
     public static final int APPLICATION_TOPOLOGY_TIMEOUT = 60000;
     public static final String APPLICATION_STATUS_CREATED = "Created";
     public static final String APPLICATION_STATUS_UNDEPLOYING = "Undeploying";
     private ApplicationsEventReceiver applicationsEventReceiver;
     private TopologyEventReceiver topologyEventReceiver;
     public static TopologyHandler topologyHandler;
+    private Map<String, Long> terminatedMembers = new 
ConcurrentHashMap<String, Long>();
+    private Map<String, Long> createdMembers = new ConcurrentHashMap<String, 
Long>();
 
     private TopologyHandler() {
         // Set jndi.properties.dir system property for initializing event 
receivers
@@ -69,6 +79,7 @@ public class TopologyHandler {
         initializeTopologyEventReceiver();
         assertApplicationTopologyInitialized();
         assertTopologyInitialized();
+        addEventListeners();
     }
 
     public static TopologyHandler getInstance() {
@@ -150,10 +161,10 @@ public class TopologyHandler {
      *
      * @param applicationName
      */
-    public void assertApplicationActivation(String applicationName) {
+    public void assertApplicationStatus(String applicationName, 
ApplicationStatus status) {
         long startTime = System.currentTimeMillis();
         Application application = 
ApplicationManager.getApplications().getApplication(applicationName);
-        while (!((application != null) && (application.getStatus() == 
ApplicationStatus.Active))) {
+        while (!((application != null) && (application.getStatus() == 
status))) {
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException ignore) {
@@ -164,8 +175,9 @@ public class TopologyHandler {
             }
         }
         assertNotNull(String.format("Application is not found: 
[application-id] %s", applicationName), application);
-        assertEquals(String.format("Application status did not change to 
active: [application-id] %s", applicationName),
-                ApplicationStatus.Active, application.getStatus());
+        assertEquals(String.format("Application status did not change to %s: 
[application-id] %s",
+                        status.toString(), applicationName),
+                status, application.getStatus());
     }
 
     /**
@@ -228,6 +240,53 @@ public class TopologyHandler {
 
     }
 
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    public void terminateMemberFromCluster(String cartridgeName, String 
applicationName, IntegrationMockClient mockIaasApiClient) {
+        Application application = 
ApplicationManager.getApplications().getApplication(applicationName);
+        assertNotNull(String.format("Application is not found: 
[application-id] %s",
+                applicationName), application);
+
+        Set<ClusterDataHolder> clusterDataHolderSet = 
application.getClusterDataRecursively();
+        for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
+            String serviceName = clusterDataHolder.getServiceType();
+            if(cartridgeName.equals(serviceName)) {
+                String clusterId = clusterDataHolder.getClusterId();
+                Service service = 
TopologyManager.getTopology().getService(serviceName);
+                assertNotNull(String.format("Service is not found: 
[application-id] %s [service] %s",
+                        applicationName, serviceName), service);
+
+                Cluster cluster = service.getCluster(clusterId);
+                assertNotNull(String.format("Cluster is not found: 
[application-id] %s [service] %s [cluster-id] %s",
+                        applicationName, serviceName, clusterId), cluster);
+                boolean memberTerminated = false;
+
+                for (ClusterInstance instance : 
cluster.getInstanceIdToInstanceContextMap().values()) {
+                    for (Member member : cluster.getMembers()) {
+                        if 
(member.getClusterInstanceId().equals(instance.getInstanceId())) {
+                            if 
(member.getStatus().equals(MemberStatus.Active)) {
+                                
mockIaasApiClient.terminateInstance(member.getMemberId());
+                                memberTerminated = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if(memberTerminated) {
+                        break;
+                    }
+
+                }
+                assertTrue("Any member couldn't be terminated from the mock 
IaaS client", memberTerminated);
+            }
+
+        }
+
+    }
+
     public void assertClusterMinMemberCount(String applicationName, int 
minMembers) {
         long startTime = System.currentTimeMillis();
 
@@ -319,7 +378,7 @@ public class TopologyHandler {
             } catch (RemoteException e) {
                 log.error("Error while getting the application context for 
[application] " + applicationName);
             }
-            if ((System.currentTimeMillis() - startTime) > 
APPLICATION_ACTIVATION_TIMEOUT) {
+            if ((System.currentTimeMillis() - startTime) > 
APPLICATION_UNDEPLOYMENT_TIMEOUT) {
                 break;
             }
         }
@@ -390,4 +449,24 @@ public class TopologyHandler {
         String path = getClass().getResource("/").getPath();
         return StringUtils.removeEnd(path, File.separator);
     }
+
+    private void addEventListeners() {
+        topologyEventReceiver.addEventListener(new 
MemberTerminatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                MemberTerminatedEvent memberTerminatedEvent = 
(MemberTerminatedEvent) event;
+                terminatedMembers.put(memberTerminatedEvent.getMemberId(), 
System.currentTimeMillis());
+
+            }
+        });
+
+        topologyEventReceiver.addEventListener(new 
MemberCreatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                MemberCreatedEvent memberCreatedEvent = (MemberCreatedEvent) 
event;
+                createdMembers.put(memberCreatedEvent.getMemberId(), 
System.currentTimeMillis());
+
+            }
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
index e62c4a5..b869b37 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
@@ -26,6 +26,7 @@ import 
org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
 import org.apache.stratos.integration.tests.RestConstants;
 import org.apache.stratos.integration.tests.StratosTestServerManager;
 import org.apache.stratos.integration.tests.TopologyHandler;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
 import org.testng.annotations.Test;
 
 import static junit.framework.Assert.assertEquals;
@@ -44,47 +45,47 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
         try {
             log.info("Started application Bursting test 
case**************************************");
 
-            String autoscalingPolicyId = "autoscaling-policy-2";
+            String autoscalingPolicyId = 
"autoscaling-policy-application-bursting-test";
 
             boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.AUTOSCALING_POLICIES_PATH
                             + "/" + autoscalingPolicyId + ".json",
                     RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
             assertEquals(addedScalingPolicy, true);
 
-            boolean addedC1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "esb.json",
+            boolean addedC1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "esb-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
             assertEquals(addedC1, true);
 
-            boolean addedC2 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+            boolean addedC2 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
             assertEquals(addedC2, true);
 
-            boolean addedC3 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json",
+            boolean addedC3 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json",
                     RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
             assertEquals(addedC3, true);
 
             boolean addedG1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGE_GROUPS_PATH +
-                            "/" + "esb-php-group.json", 
RestConstants.CARTRIDGE_GROUPS,
+                            "/" + 
"esb-php-group-application-bursting-test.json", RestConstants.CARTRIDGE_GROUPS,
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(addedG1, true);
 
             CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
-                    getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, 
"esb-php-group-application-bursting-test",
                             CartridgeGroupBean.class, 
RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(beanG1.getName(), "esb-php-group");
+            assertEquals(beanG1.getName(), 
"esb-php-group-application-bursting-test");
 
             boolean addedN1 = restClient.addEntity(TEST_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-9.json",
+                            
"network-partition-application-bursting-test-1.json",
                     RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(addedN1, true);
 
             boolean addedN2 = restClient.addEntity(TEST_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                            "network-partition-10.json",
+                            
"network-partition-application-bursting-test-2.json",
                     RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(addedN2, true);
 
             boolean addedDep = restClient.addEntity(TEST_PATH + 
RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
-                            "deployment-policy-4.json",
+                            "deployment-policy-application-bursting-test.json",
                     RestConstants.DEPLOYMENT_POLICIES, 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(addedDep, true);
 
@@ -94,28 +95,29 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
             assertEquals(added, true);
 
             ApplicationBean bean = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
-                    "cartridge-group-app", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
-            assertEquals(bean.getApplicationId(), "cartridge-group-app");
+                    "application-bursting-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), "application-bursting-test");
 
             boolean addAppPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATION_POLICIES_PATH + "/" +
-                            "application-policy-3.json", 
RestConstants.APPLICATION_POLICIES,
+                            
"application-policy-application-bursting-test.json", 
RestConstants.APPLICATION_POLICIES,
                     RestConstants.APPLICATION_POLICIES_NAME);
             assertEquals(addAppPolicy, true);
 
             ApplicationPolicyBean policyBean = (ApplicationPolicyBean) 
restClient.getEntity(
                     RestConstants.APPLICATION_POLICIES,
-                    "application-policy-3", ApplicationPolicyBean.class,
+                    "application-policy-application-bursting-test", 
ApplicationPolicyBean.class,
                     RestConstants.APPLICATION_POLICIES_NAME);
 
             //deploy the application
-            String resourcePath = RestConstants.APPLICATIONS + "/" + 
"cartridge-group-app" +
-                    RestConstants.APPLICATIONS_DEPLOY + "/" + 
"application-policy-3";
+            String resourcePath = RestConstants.APPLICATIONS + "/" + 
"application-bursting-test" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + 
"application-policy-application-bursting-test";
             boolean deployed = restClient.deployEntity(resourcePath,
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(deployed, true);
 
             //Application active handling
-            
TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
+            
TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
 
             //Group active handling
             
TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
@@ -123,7 +125,7 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
             //Cluster active handling
             
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
 
-            boolean removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+            boolean removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, 
"esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(removedGroup, false);
 
@@ -132,17 +134,17 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
             assertEquals(removedAuto, false);
 
             boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-9",
+                    "network-partition-application-bursting-test-1",
                     RestConstants.NETWORK_PARTITIONS_NAME);
             //Trying to remove the used network partition
             assertEquals(removedNet, false);
 
             boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                    "deployment-policy-4", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+                    "deployment-policy-application-bursting-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, false);
 
             //Un-deploying the application
-            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"cartridge-group-app" +
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"application-bursting-test" +
                     RestConstants.APPLICATIONS_UNDEPLOY;
 
             boolean unDeployed = 
restClient.undeployEntity(resourcePathUndeploy,
@@ -163,27 +165,27 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
 
             }
 
-            boolean removed = 
restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app",
+            boolean removed = 
restClient.removeEntity(RestConstants.APPLICATIONS, "application-bursting-test",
                     RestConstants.APPLICATIONS_NAME);
             assertEquals(removed, true);
 
             ApplicationBean beanRemoved = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
-                    "cartridge-group-app", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+                    "application-bursting-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
             assertEquals(beanRemoved, null);
 
-            removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+            removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, 
"esb-php-group-application-bursting-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(removedGroup, true);
 
-            boolean removedC1 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+            boolean removedC1 = 
restClient.removeEntity(RestConstants.CARTRIDGES, 
"esb-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC1, true);
 
-            boolean removedC2 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+            boolean removedC2 = 
restClient.removeEntity(RestConstants.CARTRIDGES, 
"php-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC2, true);
 
-            boolean removedC3 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+            boolean removedC3 = 
restClient.removeEntity(RestConstants.CARTRIDGES, 
"tomcat-application-bursting-test",
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC3, true);
 
@@ -192,27 +194,27 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
             assertEquals(removedAuto, true);
 
             removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                    "deployment-policy-4", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+                    "deployment-policy-application-bursting-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, true);
 
             removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-9", 
RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, false);
 
             boolean removedN2 = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-10", 
RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedN2, false);
 
             boolean removeAppPolicy = 
restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
-                    "application-policy-3", 
RestConstants.APPLICATION_POLICIES_NAME);
+                    "application-policy-application-bursting-test", 
RestConstants.APPLICATION_POLICIES_NAME);
             assertEquals(removeAppPolicy, true);
 
             removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-9", 
RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, true);
 
             removedN2 = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                    "network-partition-10", 
RestConstants.NETWORK_PARTITIONS_NAME);
+                    "network-partition-application-bursting-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedN2, true);
 
             log.info("Ended application bursting test 
case**************************************");

http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
new file mode 100644
index 0000000..f4995f4
--- /dev/null
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Sample application tests with application add, .
+ */
+public class ApplicationUpdateTest extends StratosTestServerManager {
+    private static final Log log = 
LogFactory.getLog(ApplicationUpdateTest.class);
+    private static final String TEST_PATH = "/application-update-test";
+
+    @Test
+    public void testDeployApplication() {
+        try {
+            log.info("Started application runtime update test 
case**************************************");
+
+            String autoscalingPolicyId = 
"autoscaling-policy-application-update-test";
+
+            boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.AUTOSCALING_POLICIES_PATH
+                            + "/" + autoscalingPolicyId + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(addedScalingPolicy, true);
+
+            boolean addedC1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "c1-application-update-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC1, true);
+
+            boolean addedC2 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "c2-application-update-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC2, true);
+
+            boolean addedC3 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "c3-application-update-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC3, true);
+
+            boolean addedG1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGE_GROUPS_PATH +
+                            "/" + 
"cartrdige-nested-application-update-test.json", RestConstants.CARTRIDGE_GROUPS,
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(addedG1, true);
+
+            CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+                    getEntity(RestConstants.CARTRIDGE_GROUPS, 
"G1-application-update-test",
+                            CartridgeGroupBean.class, 
RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(beanG1.getName(), "G1-application-update-test");
+
+            boolean addedN1 = restClient.addEntity(TEST_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-application-update-test-1.json",
+                    RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN1, true);
+
+            boolean addedN2 = restClient.addEntity(TEST_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-application-update-test-2.json",
+                    RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN2, true);
+
+            boolean addedDep = restClient.addEntity(TEST_PATH + 
RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            "deployment-policy-application-update-test.json",
+                    RestConstants.DEPLOYMENT_POLICIES, 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(addedDep, true);
+
+            boolean added = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATIONS_PATH + "/" +
+                            "g-sc-G123-1-application-update-test.json", 
RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(added, true);
+
+            ApplicationBean bean = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "g-sc-G123-1-application-update-test", 
ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), 
"g-sc-G123-1-application-update-test");
+
+            boolean addAppPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            "application-policy-application-update-test.json", 
RestConstants.APPLICATION_POLICIES,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(addAppPolicy, true);
+
+            ApplicationPolicyBean policyBean = (ApplicationPolicyBean) 
restClient.getEntity(
+                    RestConstants.APPLICATION_POLICIES,
+                    "application-policy-application-update-test", 
ApplicationPolicyBean.class,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+
+            //deploy the application
+            String resourcePath = RestConstants.APPLICATIONS + "/" + 
"g-sc-G123-1-application-update-test" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + 
"application-policy-application-update-test";
+            boolean deployed = restClient.deployEntity(resourcePath,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(deployed, true);
+
+            //Application active handling
+            
TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
+
+            //Group active handling
+            
TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+
+            //Cluster active handling
+            
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+            //Updating application
+            boolean updated = restClient.updateEntity(TEST_PATH + 
RestConstants.APPLICATIONS_PATH + "/" +
+                            "g-sc-G123-1-application-update-test-v1.json", 
RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(updated, true);
+
+            
TopologyHandler.getInstance().assertGroupInstanceCount(bean.getApplicationId(), 
"group3-application-update-test", 2);
+
+            
TopologyHandler.getInstance().assertClusterMinMemberCount(bean.getApplicationId(),
 2);
+
+            ApplicationBean updatedBean = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "g-sc-G123-1-application-update-test", 
ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(updatedBean.getApplicationId(), 
"g-sc-G123-1-application-update-test");
+
+            boolean removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, 
"G1-application-update-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(removedGroup, false);
+
+            boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, false);
+
+            boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-update-test-1",
+                    RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertEquals(removedNet, false);
+
+            boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-application-update-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, false);
+
+            //Un-deploying the application
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"g-sc-G123-1-application-update-test" +
+                    RestConstants.APPLICATIONS_UNDEPLOY;
+
+            boolean unDeployed = 
restClient.undeployEntity(resourcePathUndeploy,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(unDeployed, true);
+
+            boolean undeploy = 
TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1-application-update-test");
+            if (!undeploy) {
+                //Need to forcefully undeploy the application
+                log.info("Force undeployment is going to start for the 
[application] " + "g-sc-G123-1-application-update-test");
+
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + 
"g-sc-G123-1-application-update-test" +
+                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", 
RestConstants.APPLICATIONS);
+
+                boolean forceUndeployed = 
TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1-application-update-test");
+                assertEquals(String.format("Forceful undeployment failed for 
the application %s",
+                        "g-sc-G123-1-application-update-test"), 
forceUndeployed, true);
+
+            }
+
+            boolean removed = 
restClient.removeEntity(RestConstants.APPLICATIONS, 
"g-sc-G123-1-application-update-test",
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "g-sc-G123-1-application-update-test", 
ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+            assertEquals(beanRemoved, null);
+
+            removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, 
"G1-application-update-test",
+                    RestConstants.CARTRIDGE_GROUPS_NAME);
+            assertEquals(removedGroup, true);
+
+            boolean removedC1 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "c1-application-update-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC1, true);
+
+            boolean removedC2 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "c2-application-update-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC2, true);
+
+            boolean removedC3 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "c3-application-update-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC3, true);
+
+            removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-application-update-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-update-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, false);
+
+            boolean removedN2 = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-update-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, false);
+
+            boolean removeAppPolicy = 
restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    "application-policy-application-update-test", 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(removeAppPolicy, true);
+
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-update-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, true);
+
+            removedN2 = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-application-update-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedN2, true);
+
+            log.info("Ended application runtime update test 
case**************************************");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling application 
deployment/undeployment and update", e);
+            assertTrue("An error occurred while handling application 
deployment/undeployment and update", false);
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
new file mode 100644
index 0000000..1bb4ddf
--- /dev/null
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java
@@ -0,0 +1,298 @@
+/*
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.apache.stratos.messaging.domain.application.Application;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.apache.stratos.messaging.domain.application.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.instance.ClusterInstance;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.Member;
+import org.apache.stratos.messaging.domain.topology.Service;
+import 
org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.testng.annotations.Test;
+
+import java.util.*;
+
+import static junit.framework.Assert.*;
+
+/**
+ * This will handle the scale-up and scale-down of a particular cluster 
bursting test cases
+ */
+public class PartitionOneAfterAnotherClusterTest extends 
StratosTestServerManager {
+    private static final Log log = 
LogFactory.getLog(SampleApplicationsTest.class);
+    private static final String TEST_PATH = 
"/partition-round-robin-cluster-test";
+
+
+    @Test
+    public void testDeployApplication() {
+        try {
+            log.info("Started Partition One after another test 
case**************************************");
+
+            String autoscalingPolicyId = "autoscaling-policy-3";
+
+            boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.AUTOSCALING_POLICIES_PATH
+                            + "/" + autoscalingPolicyId + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(addedScalingPolicy, true);
+
+            boolean addedC1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "c7.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC1, true);
+
+            boolean addedN1 = restClient.addEntity(TEST_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            "network-partition-11.json",
+                    RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN1, true);
+
+            boolean addedDep = restClient.addEntity(TEST_PATH + 
RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            "deployment-policy-5.json",
+                    RestConstants.DEPLOYMENT_POLICIES, 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(addedDep, true);
+
+            boolean added = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATIONS_PATH + "/" +
+                            "single-cluster-scaling-test.json", 
RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(added, true);
+
+            ApplicationBean bean = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "single-cluster-scaling-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), 
"single-cluster-scaling-test");
+
+            boolean addAppPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            "application-policy-4.json", 
RestConstants.APPLICATION_POLICIES,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(addAppPolicy, true);
+
+            ApplicationPolicyBean policyBean = (ApplicationPolicyBean) 
restClient.getEntity(
+                    RestConstants.APPLICATION_POLICIES,
+                    "application-policy-4", ApplicationPolicyBean.class,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+
+            //deploy the application
+            String resourcePath = RestConstants.APPLICATIONS + "/" + 
"single-cluster-scaling-test" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + 
"application-policy-4";
+            boolean deployed = restClient.deployEntity(resourcePath,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(deployed, true);
+
+            //Application active handling
+            
TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
+
+            //Cluster active handling
+            
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+            //Verifying whether members got created using round robin algorithm
+            assertClusterWithRoundRobinAlgorithm(bean.getApplicationId());
+
+            //Removing one member from cluster and check for auto healing
+
+
+            boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, false);
+
+            boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-11",
+                    RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertEquals(removedNet, false);
+
+            boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-5", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, false);
+
+            //Un-deploying the application
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"single-cluster-scaling-test" +
+                    RestConstants.APPLICATIONS_UNDEPLOY;
+
+            boolean unDeployed = 
restClient.undeployEntity(resourcePathUndeploy,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(unDeployed, true);
+
+            boolean undeploy = 
TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test");
+            if (!undeploy) {
+                //Need to forcefully undeploy the application
+                log.info("Force undeployment is going to start for the 
[application] " + "single-cluster-scaling-test");
+
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + 
"single-cluster-scaling-test" +
+                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", 
RestConstants.APPLICATIONS);
+
+                boolean forceUndeployed = 
TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test");
+                assertEquals(String.format("Forceful undeployment failed for 
the application %s",
+                        "single-cluster-scaling-test"), forceUndeployed, true);
+
+            }
+
+            boolean removed = 
restClient.removeEntity(RestConstants.APPLICATIONS, 
"single-cluster-scaling-test",
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "single-cluster-scaling-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+            assertEquals(beanRemoved, null);
+
+            boolean removedC1 = 
restClient.removeEntity(RestConstants.CARTRIDGES, "c7",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC1, true);
+
+
+            removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-5", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-11", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, false);
+
+
+            boolean removeAppPolicy = 
restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    "application-policy-4", 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(removeAppPolicy, true);
+
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-11", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, true);
+
+            log.info("Ended Partition one after another test 
case**************************************");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling  application 
bursting", e);
+            assertTrue("An error occurred while handling  application 
bursting", false);
+        }
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    private void assertClusterWithRoundRobinAlgorithm(String applicationName) {
+        Application application = 
ApplicationManager.getApplications().getApplication(applicationName);
+        assertNotNull(String.format("Application is not found: 
[application-id] %s",
+                applicationName), application);
+
+        Set<ClusterDataHolder> clusterDataHolderSet = 
application.getClusterDataRecursively();
+        for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
+            String serviceName = clusterDataHolder.getServiceType();
+            String clusterId = clusterDataHolder.getClusterId();
+            Service service = 
TopologyManager.getTopology().getService(serviceName);
+            assertNotNull(String.format("Service is not found: 
[application-id] %s [service] %s",
+                    applicationName, serviceName), service);
+
+            Cluster cluster = service.getCluster(clusterId);
+            assertNotNull(String.format("Cluster is not found: 
[application-id] %s [service] %s [cluster-id] %s",
+                    applicationName, serviceName, clusterId), cluster);
+
+            for (ClusterInstance instance : 
cluster.getInstanceIdToInstanceContextMap().values()) {
+                List<String> partitionsUsedInMembers = new ArrayList<String>();
+                Map<String, List<Long>> partitionIdToMembersMap = new 
HashMap<String, List<Long>>();
+                for (Member member : cluster.getMembers()) {
+                    String partitionId = member.getPartitionId();
+                    if (!partitionIdToMembersMap.containsKey(partitionId)) {
+                        List<Long> members = new ArrayList<Long>();
+                        members.add(member.getInitTime());
+                        partitionIdToMembersMap.put(partitionId, members);
+                    } else {
+                        
partitionIdToMembersMap.get(partitionId).add(member.getInitTime());
+                    }
+                    if (!partitionsUsedInMembers.contains(partitionId)) {
+                        partitionsUsedInMembers.add(partitionId);
+                    }
+                }
+                String p1 = "network-partition-11-partition-1";
+                String p2 = "network-partition-11-partition-2";
+                List<Long> p1InitTime = partitionIdToMembersMap.get(p1);
+                Collections.sort(p1InitTime);
+
+                List<Long> p2InitTime = partitionIdToMembersMap.get(p2);
+                Collections.sort(p2InitTime);
+
+                List<Long> allInitTime = new ArrayList<Long>();
+                allInitTime.addAll(p1InitTime);
+                allInitTime.addAll(p2InitTime);
+                Collections.sort(allInitTime);
+
+                int p1Index = -1;
+                int p2Index = -1;
+                String previousPartition = null;
+                for (int i = 0; i < allInitTime.size(); i++) {
+                    if (previousPartition == null) {
+                        if (p1InitTime.get(0) == allInitTime.get(i)) {
+                            previousPartition = p1;
+                            p1Index++;
+                        } else if (p2InitTime.get(0) == allInitTime.get(i)) {
+                            previousPartition = p2;
+                            p2Index++;
+
+                        }
+                    } else if (previousPartition.equals(p1)) {
+                        p2Index++;
+                        previousPartition = p2;
+                        assertEquals("Partition-2 doesn't not contain correct 
values in current " +
+                                "iteration", allInitTime.get(i), 
p2InitTime.get(p2Index));
+                        if (p1Index >= 0) {
+                            assertEquals("Partition-1 doesn't not contain 
correct values in the " +
+                                    "previous iteration", allInitTime.get(i - 
1), p1InitTime.get(p1Index));
+                            if (p1Index + 1 <= (p1InitTime.size() - 1) && i + 
1 <= (allInitTime.size() - 1)) {
+                                assertEquals("Partition-1 doesn't not contain 
correct " +
+                                                "values in the next iteration",
+                                        allInitTime.get(i + 1), 
p1InitTime.get(p1Index + 1));
+
+                            }
+                        }
+                    } else {
+                        p1Index++;
+                        previousPartition = p1;
+                        assertEquals("Partition-1 doesn't not contain correct 
values in current " +
+                                "iteration", allInitTime.get(i), 
p1InitTime.get(p1Index));
+                        if (p2Index >= 0) {
+                            assertEquals("Partition-2 doesn't not contain 
correct values  " +
+                                    "in the previous iteration", 
allInitTime.get(i - 1), p2InitTime.get(p2Index));
+                            if ((p2Index + 1) <= (p2InitTime.size() - 1) && (i 
+ 1) <= (allInitTime.size() - 1)) {
+                                assertEquals("Partition-2 doesn't not contain 
correct values  " +
+                                                "in the next iteration",
+                                        allInitTime.get(i + 1), 
p2InitTime.get(p2Index + 1));
+                            }
+                        }
+                    }
+
+                }
+
+
+            }
+
+        }
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f78ab824/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
new file mode 100644
index 0000000..d27c0db
--- /dev/null
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTest.java
@@ -0,0 +1,305 @@
+/*
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.apache.stratos.messaging.domain.application.Application;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.apache.stratos.messaging.domain.application.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.instance.ClusterInstance;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.Member;
+import org.apache.stratos.messaging.domain.topology.Service;
+import 
org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.testng.annotations.Test;
+
+import java.util.*;
+
+import static junit.framework.Assert.*;
+
+/**
+ * This will handle the scale-up and scale-down of a particular cluster 
bursting test cases
+ */
+public class PartitionRoundRobinClusterTest extends StratosTestServerManager {
+    private static final Log log = 
LogFactory.getLog(SampleApplicationsTest.class);
+    private static final String TEST_PATH = 
"/partition-round-robin-cluster-test";
+
+
+    @Test
+    public void testDeployApplication() {
+        try {
+            log.info("Started application Bursting test 
case**************************************");
+
+            String autoscalingPolicyId = 
"autoscaling-policy-partition-round-robin-test";
+
+            boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.AUTOSCALING_POLICIES_PATH
+                            + "/" + autoscalingPolicyId + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(addedScalingPolicy, true);
+
+            boolean addedC1 = restClient.addEntity(TEST_PATH + 
RestConstants.CARTRIDGES_PATH + "/" + "c7-partition-round-robin-test.json",
+                    RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+            assertEquals(addedC1, true);
+
+            boolean addedN1 = restClient.addEntity(TEST_PATH + 
RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+                            
"network-partition-partition-round-robin-test.json",
+                    RestConstants.NETWORK_PARTITIONS, 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(addedN1, true);
+
+            boolean addedDep = restClient.addEntity(TEST_PATH + 
RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                            
"deployment-policy-partition-round-robin-test.json",
+                    RestConstants.DEPLOYMENT_POLICIES, 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(addedDep, true);
+
+            boolean added = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATIONS_PATH + "/" +
+                            "partition-round-robin-test.json", 
RestConstants.APPLICATIONS,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(added, true);
+
+            ApplicationBean bean = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "partition-round-robin-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+            assertEquals(bean.getApplicationId(), 
"partition-round-robin-test");
+
+            boolean addAppPolicy = restClient.addEntity(TEST_PATH + 
RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                            
"application-policy-partition-round-robin-test.json", 
RestConstants.APPLICATION_POLICIES,
+                    RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(addAppPolicy, true);
+
+            //deploy the application
+            String resourcePath = RestConstants.APPLICATIONS + "/" + 
"partition-round-robin-test" +
+                    RestConstants.APPLICATIONS_DEPLOY + "/" + 
"application-policy-partition-round-robin-test";
+            boolean deployed = restClient.deployEntity(resourcePath,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(deployed, true);
+
+
+            //Application active handling
+            
TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
+
+            //Cluster active handling
+            
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+            //Verifying whether members got created using round robin algorithm
+            assertClusterWithRoundRobinAlgorithm(bean.getApplicationId());
+
+            //Application in-active handling
+            log.info("Waiting for the faulty member detection from " +
+                    "CEP as the statistics are stopped...");
+            
TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Inactive);
+
+            //Application active handling after application becomes active 
again
+            
TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(),
+                    ApplicationStatus.Active);
+
+            //Cluster active handling
+            
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+            boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, false);
+
+            boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-partition-round-robin-test",
+                    RestConstants.NETWORK_PARTITIONS_NAME);
+            //Trying to remove the used network partition
+            assertEquals(removedNet, false);
+
+            boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-partition-round-robin-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, false);
+
+            //Un-deploying the application
+            String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"partition-round-robin-test" +
+                    RestConstants.APPLICATIONS_UNDEPLOY;
+
+            boolean unDeployed = 
restClient.undeployEntity(resourcePathUndeploy,
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(unDeployed, true);
+
+            boolean undeploy = 
TopologyHandler.getInstance().assertApplicationUndeploy("partition-round-robin-test");
+            if (!undeploy) {
+                //Need to forcefully undeploy the application
+                log.info("Force undeployment is going to start for the 
[application] " + "partition-round-robin-test");
+
+                restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + 
"partition-round-robin-test" +
+                        RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", 
RestConstants.APPLICATIONS);
+
+                boolean forceUndeployed = 
TopologyHandler.getInstance().assertApplicationUndeploy("partition-round-robin-test");
+                assertEquals(String.format("Forceful undeployment failed for 
the application %s",
+                        "partition-round-robin-test"), forceUndeployed, true);
+
+            }
+
+            boolean removed = 
restClient.removeEntity(RestConstants.APPLICATIONS, 
"partition-round-robin-test",
+                    RestConstants.APPLICATIONS_NAME);
+            assertEquals(removed, true);
+
+            ApplicationBean beanRemoved = (ApplicationBean) 
restClient.getEntity(RestConstants.APPLICATIONS,
+                    "partition-round-robin-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+            assertEquals(beanRemoved, null);
+
+            boolean removedC1 = 
restClient.removeEntity(RestConstants.CARTRIDGES, 
"c7-partition-round-robin-test",
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removedC1, true);
+
+
+            removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(removedAuto, true);
+
+            removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                    "deployment-policy-partition-round-robin-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+            assertEquals(removedDep, true);
+
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-partition-round-robin-test", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, false);
+
+
+            boolean removeAppPolicy = 
restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+                    "application-policy-partition-round-robin-test", 
RestConstants.APPLICATION_POLICIES_NAME);
+            assertEquals(removeAppPolicy, true);
+
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                    "network-partition-partition-round-robin-test", 
RestConstants.NETWORK_PARTITIONS_NAME);
+            assertEquals(removedNet, true);
+
+            log.info("Ended application bursting test 
case**************************************");
+
+        } catch (Exception e) {
+            log.error("An error occurred while handling  application 
bursting", e);
+            assertTrue("An error occurred while handling  application 
bursting", false);
+        }
+    }
+
+    /**
+     * Assert application activation
+     *
+     * @param applicationName
+     */
+    private void assertClusterWithRoundRobinAlgorithm(String applicationName) {
+        Application application = 
ApplicationManager.getApplications().getApplication(applicationName);
+        assertNotNull(String.format("Application is not found: 
[application-id] %s",
+                applicationName), application);
+
+        Set<ClusterDataHolder> clusterDataHolderSet = 
application.getClusterDataRecursively();
+        for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
+            String serviceName = clusterDataHolder.getServiceType();
+            String clusterId = clusterDataHolder.getClusterId();
+            Service service = 
TopologyManager.getTopology().getService(serviceName);
+            assertNotNull(String.format("Service is not found: 
[application-id] %s [service] %s",
+                    applicationName, serviceName), service);
+
+            Cluster cluster = service.getCluster(clusterId);
+            assertNotNull(String.format("Cluster is not found: 
[application-id] %s [service] %s [cluster-id] %s",
+                    applicationName, serviceName, clusterId), cluster);
+
+            for (ClusterInstance instance : 
cluster.getInstanceIdToInstanceContextMap().values()) {
+                List<String> partitionsUsedInMembers = new ArrayList<String>();
+                Map<String, List<Long>> partitionIdToMembersMap = new 
HashMap<String, List<Long>>();
+                for (Member member : cluster.getMembers()) {
+                    String partitionId = member.getPartitionId();
+                    if (!partitionIdToMembersMap.containsKey(partitionId)) {
+                        List<Long> members = new ArrayList<Long>();
+                        members.add(member.getInitTime());
+                        partitionIdToMembersMap.put(partitionId, members);
+                    } else {
+                        
partitionIdToMembersMap.get(partitionId).add(member.getInitTime());
+                    }
+                    if (!partitionsUsedInMembers.contains(partitionId)) {
+                        partitionsUsedInMembers.add(partitionId);
+                    }
+                }
+                String p1 = "network-partition-11-partition-1";
+                String p2 = "network-partition-11-partition-2";
+                List<Long> p1InitTime = partitionIdToMembersMap.get(p1);
+                Collections.sort(p1InitTime);
+
+                List<Long> p2InitTime = partitionIdToMembersMap.get(p2);
+                Collections.sort(p2InitTime);
+
+                List<Long> allInitTime = new ArrayList<Long>();
+                allInitTime.addAll(p1InitTime);
+                allInitTime.addAll(p2InitTime);
+                Collections.sort(allInitTime);
+
+                int p1Index = -1;
+                int p2Index = -1;
+                String previousPartition = null;
+                for (int i = 0; i < allInitTime.size(); i++) {
+                    if (previousPartition == null) {
+                        if (p1InitTime.get(0) == allInitTime.get(i)) {
+                            previousPartition = p1;
+                            p1Index++;
+                        } else if (p2InitTime.get(0) == allInitTime.get(i)) {
+                            previousPartition = p2;
+                            p2Index++;
+
+                        }
+                    } else if (previousPartition.equals(p1)) {
+                        p2Index++;
+                        previousPartition = p2;
+                        assertEquals("Partition-2 doesn't not contain correct 
values in current " +
+                                "iteration", allInitTime.get(i), 
p2InitTime.get(p2Index));
+                        if (p1Index >= 0) {
+                            assertEquals("Partition-1 doesn't not contain 
correct values in the " +
+                                    "previous iteration", allInitTime.get(i - 
1), p1InitTime.get(p1Index));
+                            if (p1Index + 1 <= (p1InitTime.size() - 1) && i + 
1 <= (allInitTime.size() - 1)) {
+                                assertEquals("Partition-1 doesn't not contain 
correct " +
+                                                "values in the next iteration",
+                                        allInitTime.get(i + 1), 
p1InitTime.get(p1Index + 1));
+
+                            }
+                        }
+                    } else {
+                        p1Index++;
+                        previousPartition = p1;
+                        assertEquals("Partition-1 doesn't not contain correct 
values in current " +
+                                "iteration", allInitTime.get(i), 
p1InitTime.get(p1Index));
+                        if (p2Index >= 0) {
+                            assertEquals("Partition-2 doesn't not contain 
correct values  " +
+                                    "in the previous iteration", 
allInitTime.get(i - 1), p2InitTime.get(p2Index));
+                            if ((p2Index + 1) <= (p2InitTime.size() - 1) && (i 
+ 1) <= (allInitTime.size() - 1)) {
+                                assertEquals("Partition-2 doesn't not contain 
correct values  " +
+                                                "in the next iteration",
+                                        allInitTime.get(i + 1), 
p2InitTime.get(p2Index + 1));
+                            }
+                        }
+                    }
+
+                }
+
+
+            }
+
+        }
+
+
+    }
+    
+}

Reply via email to