You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/11/24 10:15:17 UTC

stratos git commit: cleaning GroupStartupOrderTestCase

Repository: stratos
Updated Branches:
  refs/heads/stratos-4.1.x 18b2bdc8f -> edb172b68


cleaning GroupStartupOrderTestCase


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

Branch: refs/heads/stratos-4.1.x
Commit: edb172b68f09bc80c4a38ade8db347e0fac44ddb
Parents: 18b2bdc
Author: rajkumar <rr...@gmail.com>
Authored: Tue Nov 24 14:44:55 2015 +0530
Committer: rajkumar <rr...@gmail.com>
Committed: Tue Nov 24 14:44:55 2015 +0530

----------------------------------------------------------------------
 .../application/GroupStartupOrderTestCase.java  | 101 ++++++++++---------
 ...rk-partition-group-startup-order-test-2.json |  24 -----
 2 files changed, 54 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/edb172b6/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTestCase.java
index 75781d6..2dd6d3b 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTestCase.java
@@ -40,92 +40,105 @@ import static org.testng.AssertJUnit.assertTrue;
 public class GroupStartupOrderTestCase extends StratosIntegrationTest {
     private static final Log log = LogFactory.getLog(GroupStartupOrderTestCase.class);
     private static final String RESOURCES_PATH = "/group-startup-order-test";
+    private static final String autoscalingPolicyId = "autoscaling-policy-group-startup-order-test";
+    private static final String esbCartridgeId = "esb-group-startup-order-test";
+    private static final String phpCartridgeId = "php-group-startup-order-test";
+    private static final String stratosLbCartridgeId = "stratos-lb-group-startup-order-test";
+    private static final String tomcat1CartridgeId = "tomcat1-group-startup-order-test";
+    private static final String tomcat2CartridgeId = "tomcat2-group-startup-order-test";
+    private static final String tomcat3CartridgeId = "tomcat3-group-startup-order-test";
+    private static final String tomcatCartridgeId = "tomcat-group-startup-order-test";
+    private static final String cartridgeGroupId1 = "group6-group-startup-order-test";
+    private static final String cartridgeGroupId2 = "group8-group-startup-order-test";
+    private static final String networkPartitionId1 = "network-partition-group-startup-order-test-1";
+    private static final String deploymentPolicyId = "deployment-policy-group-startup-order-test";
+    private static final String applicationPolicyId = "application-policy-group-startup-order-test";
+    private static final String applicationId = "group-startup-order-test";
     private static final int GROUP_ACTIVE_TIMEOUT = 300000;
     private static final int NODES_START_PARALLEL_TIMEOUT = 30000;
 
 
     @Test(timeOut = APPLICATION_TEST_TIMEOUT, groups = {"stratos.application.deployment"})
     public void testTerminationBehavior() throws Exception {
-        String autoscalingPolicyId = "autoscaling-policy-group-startup-order-test";
-        TopologyHandler topologyHandler = TopologyHandler.getInstance();
 
+        TopologyHandler topologyHandler = TopologyHandler.getInstance();
         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-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + esbCartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC1);
 
         boolean addedC2 = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + phpCartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC2);
 
         boolean addedC3 = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "stratos-lb-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + stratosLbCartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC3);
 
         boolean addedC5 = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat1-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + tomcat1CartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC5);
 
         boolean addedC6 = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat2-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + tomcat2CartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC6);
 
         boolean addedC7 = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat3-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + tomcat3CartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC7);
 
         boolean addedC8 = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-group-startup-order-test.json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + tomcatCartridgeId + ".json",
                 RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
         assertTrue(addedC8);
 
         boolean addedG2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
-                        "/" + "group6-group-startup-order-test.json", RestConstants.CARTRIDGE_GROUPS,
+                        "/" + cartridgeGroupId1 + ".json", RestConstants.CARTRIDGE_GROUPS,
                 RestConstants.CARTRIDGE_GROUPS_NAME);
         assertTrue(addedG2);
 
         boolean addedG3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
-                        "/" + "group8-group-startup-order-test.json", RestConstants.CARTRIDGE_GROUPS,
+                        "/" + cartridgeGroupId2 + ".json", RestConstants.CARTRIDGE_GROUPS,
                 RestConstants.CARTRIDGE_GROUPS_NAME);
         assertTrue(addedG3);
 
         boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
-                        "network-partition-group-startup-order-test-1.json",
+                        networkPartitionId1 + ".json",
                 RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
         assertTrue(addedN1);
 
         boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
-                        "deployment-policy-group-startup-order-test.json",
+                        deploymentPolicyId + ".json",
                 RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
         assertTrue(addedDep);
 
         boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
-                        "group-startup-order-test.json", RestConstants.APPLICATIONS,
+                        applicationId + ".json", RestConstants.APPLICATIONS,
                 RestConstants.APPLICATIONS_NAME);
         assertTrue(added);
 
         ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                "group-startup-order-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
-        assertEquals(bean.getApplicationId(), "group-startup-order-test");
+                applicationId, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+        assertEquals(bean.getApplicationId(), applicationId);
 
         boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
-                        "application-policy-group-startup-order-test.json", RestConstants.APPLICATION_POLICIES,
+                        applicationPolicyId + ".json", RestConstants.APPLICATION_POLICIES,
                 RestConstants.APPLICATION_POLICIES_NAME);
         assertTrue(addAppPolicy);
 
         //deploy the application
-        String resourcePath = RestConstants.APPLICATIONS + "/" + "group-startup-order-test" +
-                RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-group-startup-order-test";
+        String resourcePath = RestConstants.APPLICATIONS + "/" + applicationId +
+                RestConstants.APPLICATIONS_DEPLOY + "/" + applicationPolicyId;
         boolean deployed = restClient.deployEntity(resourcePath,
                 RestConstants.APPLICATIONS_NAME);
         assertTrue(deployed);
@@ -201,12 +214,12 @@ public class GroupStartupOrderTestCase extends StratosIntegrationTest {
         topologyHandler.assertClusterActivation(bean.getApplicationId());
 
         boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
-                "group6-group-startup-order-test",
+                cartridgeGroupId1,
                 RestConstants.CARTRIDGE_GROUPS_NAME);
         assertFalse(removedGroup);
 
         removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
-                "group8-group-startup-order-test",
+                cartridgeGroupId2,
                 RestConstants.CARTRIDGE_GROUPS_NAME);
         assertFalse(removedGroup);
 
@@ -215,72 +228,70 @@ public class GroupStartupOrderTestCase extends StratosIntegrationTest {
         assertFalse(removedAuto);
 
         boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                "network-partition-group-startup-order-test-1",
+                networkPartitionId1,
                 RestConstants.NETWORK_PARTITIONS_NAME);
         //Trying to remove the used network partition
         assertFalse(removedNet);
 
         boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                "deployment-policy-group-startup-order-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+                deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
         assertFalse(removedDep);
 
         //Un-deploying the application
-        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "group-startup-order-test" +
+        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + applicationId +
                 RestConstants.APPLICATIONS_UNDEPLOY;
 
         boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
                 RestConstants.APPLICATIONS_NAME);
         assertTrue(unDeployed);
 
-        boolean undeploy = topologyHandler.assertApplicationUndeploy("group-startup-order-test");
+        boolean undeploy = topologyHandler.assertApplicationUndeploy(applicationId);
         if (!undeploy) {
             //Need to forcefully undeploy the application
-            log.info("Force undeployment is going to start for the [application] " + "group-startup-order-test");
+            log.info(String.format("Force undeployment is going to start for the [application] %s", applicationId));
 
-            restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "group-startup-order-test" +
+            restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + applicationId +
                     RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
 
-            boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("group-startup-order-test");
+            boolean forceUndeployed = topologyHandler.assertApplicationUndeploy(applicationId);
             assertTrue(String.format("Forceful undeployment failed for the application %s",
-                    "group-startup-order-test"), forceUndeployed);
+                    applicationId), forceUndeployed);
 
         }
 
-        boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "group-startup-order-test",
+        boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, applicationId,
                 RestConstants.APPLICATIONS_NAME);
         assertTrue(removed);
 
         ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
-                "group-startup-order-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+                applicationId, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
         assertNull(beanRemoved);
 
         removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
-                "group6-group-startup-order-test",
-                RestConstants.CARTRIDGE_GROUPS_NAME);
+                cartridgeGroupId1, RestConstants.CARTRIDGE_GROUPS_NAME);
         assertTrue(removedGroup);
 
         removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
-                "group8-group-startup-order-test",
-                RestConstants.CARTRIDGE_GROUPS_NAME);
+                cartridgeGroupId2, RestConstants.CARTRIDGE_GROUPS_NAME);
         assertTrue(removedGroup);
 
-        boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "stratos-lb-group-startup-order-test",
+        boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, stratosLbCartridgeId,
                 RestConstants.CARTRIDGES_NAME);
         assertTrue(removedC1);
 
-        boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat-group-startup-order-test",
+        boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES,tomcatCartridgeId,
                 RestConstants.CARTRIDGES_NAME);
         assertTrue(removedC2);
 
-        boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat1-group-startup-order-test",
+        boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, tomcat1CartridgeId,
                 RestConstants.CARTRIDGES_NAME);
         assertTrue(removedC3);
 
-        boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat2-group-startup-order-test",
+        boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, tomcat2CartridgeId,
                 RestConstants.CARTRIDGES_NAME);
         assertTrue(removedC4);
 
-        boolean removedC5 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat3-group-startup-order-test",
+        boolean removedC5 = restClient.removeEntity(RestConstants.CARTRIDGES, tomcat3CartridgeId,
                 RestConstants.CARTRIDGES_NAME);
         assertTrue(removedC5);
 
@@ -289,20 +300,16 @@ public class GroupStartupOrderTestCase extends StratosIntegrationTest {
         assertTrue(removedAuto);
 
         removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
-                "deployment-policy-group-startup-order-test", RestConstants.DEPLOYMENT_POLICIES_NAME);
+                deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
         assertTrue(removedDep);
 
         removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                "network-partition-group-startup-order-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
+                networkPartitionId1, RestConstants.NETWORK_PARTITIONS_NAME);
         assertFalse(removedNet);
 
         boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
-                "application-policy-group-startup-order-test", RestConstants.APPLICATION_POLICIES_NAME);
+                applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
         assertTrue(removeAppPolicy);
-
-        removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
-                "network-partition-group-startup-order-test-1", RestConstants.NETWORK_PARTITIONS_NAME);
-        assertTrue(removedNet);
     }
 
     private void assertCreationOfNodes(String firstNodeId, String secondNodeId) {

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