http://git-wip-us.apache.org/repos/asf/stratos/blob/4b864473/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 index 9ba62f6..f3f1b91 100644 --- 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 @@ -27,7 +27,6 @@ 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.integration.tests.rest.RestClient; import org.apache.stratos.messaging.domain.application.ApplicationStatus; import org.testng.annotations.Test; @@ -44,218 +43,201 @@ public class ApplicationUpdateTest extends StratosTestServerManager { @Test public void testDeployApplication() { try { - + log.info("-------------------------Started application runtime update test case-------------------------"); + TopologyHandler topologyHandler = TopologyHandler.getInstance(); String autoscalingPolicyId = "autoscaling-policy-application-update-test"; - String applicationId="g-sc-G123-1-application-update-test"; - testApplicationRuntimeForTenant(restClientTenant1,tenant1Id,autoscalingPolicyId) ; + boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + + "/" + autoscalingPolicyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(addedScalingPolicy, true); + + boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1-application-update-test.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC1, true); + + boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2-application-update-test.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC2, true); + + boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3-application-update-test.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC3, true); + + boolean addedG1 = restClient.addEntity(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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(RESOURCES_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.assertApplicationStatus(bean.getApplicationId(), + ApplicationStatus.Active); + + //Group active handling + topologyHandler.assertGroupActivation(bean.getApplicationId()); - TopologyHandler.getInstance().assertApplicationForNonAvailability(applicationId,tenant2Id); + //Cluster active handling + topologyHandler.assertClusterActivation(bean.getApplicationId()); //Updating application - boolean updated = restClientTenant1.updateEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + + boolean updated = restClient.updateEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + "g-sc-G123-1-application-update-test-v1.json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME); assertEquals(updated, true); - TopologyHandler.getInstance().assertGroupInstanceCount(applicationId, "group3-application-update-test", 1, tenant1Id); + topologyHandler.assertGroupInstanceCount(bean.getApplicationId(), "group3-application-update-test", 2); - TopologyHandler.getInstance().assertClusterMinMemberCount(applicationId, 1, tenant1Id); + topologyHandler.assertClusterMinMemberCount(bean.getApplicationId(), 2); - ApplicationBean updatedBean = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, + 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"); - TopologyHandler.getInstance().assertApplicationForNonAvailability(applicationId,tenant2Id); - - boolean removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-application-update-test", + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-application-update-test", RestConstants.CARTRIDGE_GROUPS_NAME); assertEquals(removedGroup, false); - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); assertEquals(removedAuto, false); - boolean removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + 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 = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-application-update-test", RestConstants.DEPLOYMENT_POLICIES_NAME); assertEquals(removedDep, false); - testApplicationRuntimeForTenant(restClientTenant2,tenant2Id,autoscalingPolicyId); - - testApplicationUndeplymentForTenant(restClientTenant1,tenant1Id,autoscalingPolicyId); - - TopologyHandler.getInstance().assertApplicationForNonAvailability(applicationId,tenant1Id); + //Un-deploying the application + String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1-application-update-test" + + RestConstants.APPLICATIONS_UNDEPLOY; - testApplicationUndeplymentForTenant(restClientTenant2,tenant2Id,autoscalingPolicyId); - - 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); - } - } + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, + RestConstants.APPLICATIONS_NAME); + assertEquals(unDeployed, true); - private void testApplicationRuntimeForTenant(RestClient restClientTenant,int tenantId, String autoscalingPolicyId ){ - - boolean addedScalingPolicy = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH - + "/" + autoscalingPolicyId + ".json", - RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(addedScalingPolicy, true); - - boolean addedC1 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1-application-update-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC1, true); - - boolean addedC2 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2-application-update-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC2, true); - - boolean addedC3 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3-application-update-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC3, true); - - boolean addedG1 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + - "/" + "cartrdige-nested-application-update-test.json", RestConstants.CARTRIDGE_GROUPS, - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(addedG1, true); - - CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClientTenant. - getEntity(RestConstants.CARTRIDGE_GROUPS, "G1-application-update-test", - CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(beanG1.getName(), "G1-application-update-test"); - - boolean addedN1 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + - "network-partition-application-update-test-1.json", - RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(addedN1, true); - - boolean addedN2 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + - "network-partition-application-update-test-2.json", - RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(addedN2, true); - - boolean addedDep = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + - "deployment-policy-application-update-test.json", - RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(addedDep, true); - - boolean added = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + - "g-sc-G123-1-application-update-test.json", RestConstants.APPLICATIONS, - RestConstants.APPLICATIONS_NAME); - assertEquals(added, true); - - ApplicationBean bean = (ApplicationBean) restClientTenant.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 = restClientTenant.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + - "application-policy-application-update-test.json", RestConstants.APPLICATION_POLICIES, - RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(addAppPolicy, true); - - ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant.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 = restClientTenant.deployEntity(resourcePath, - RestConstants.APPLICATIONS_NAME); - assertEquals(deployed, true); - - //Application active handling - TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active, tenantId); - - //Group active handling - TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId(), tenantId); - - //Cluster active handling - TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenantId); - } + boolean undeploy = topologyHandler.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"); - private void testApplicationUndeplymentForTenant(RestClient restClientTenant,int tenantId,String autoscalingPolicyId){ + restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "g-sc-G123-1-application-update-test" + + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); - String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1-application-update-test" + - RestConstants.APPLICATIONS_UNDEPLOY; + boolean forceUndeployed = topologyHandler.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 unDeployed = restClientTenant.undeployEntity(resourcePathUndeploy, - RestConstants.APPLICATIONS_NAME); - assertEquals(unDeployed, true); + } - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1-application-update-test", tenantId); - 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"); + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1-application-update-test", + RestConstants.APPLICATIONS_NAME); + assertEquals(removed, true); - restClientTenant.undeployEntity(RestConstants.APPLICATIONS + "/" + "g-sc-G123-1-application-update-test" + - RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1-application-update-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(beanRemoved, null); - boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1-application-update-test", tenantId); - assertEquals(String.format("Forceful undeployment failed for the application %s", - "g-sc-G123-1-application-update-test"), forceUndeployed, true); + 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 removed = restClientTenant.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1-application-update-test", - RestConstants.APPLICATIONS_NAME); - assertEquals(removed, true); + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2-application-update-test", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC2, true); - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant.getEntity(RestConstants.APPLICATIONS, - "g-sc-G123-1-application-update-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(beanRemoved, null); + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3-application-update-test", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC3, true); - boolean removedGroup = restClientTenant.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-application-update-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, true); + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, true); - boolean removedC1 = restClientTenant.removeEntity(RestConstants.CARTRIDGES, "c1-application-update-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC1, true); + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-application-update-test", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, true); - boolean removedC2 = restClientTenant.removeEntity(RestConstants.CARTRIDGES, "c2-application-update-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC2, true); + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-application-update-test-1", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, false); - boolean removedC3 = restClientTenant.removeEntity(RestConstants.CARTRIDGES, "c3-application-update-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC3, true); + boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-application-update-test-2", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, false); - boolean removedAuto = restClientTenant.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, true); + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, + "application-policy-application-update-test", RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(removeAppPolicy, true); - boolean removedDep = restClientTenant.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, true); - boolean removedNet = restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-update-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, false); + removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-application-update-test-2", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, true); - boolean removedN2 = restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-update-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, false); + log.info("-------------------------Ended application runtime update test case-------------------------"); - boolean removeAppPolicy = restClientTenant.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-application-update-test", RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(removeAppPolicy, true); + } 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); + } + } - removedNet = restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-update-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, true); - removedN2 = restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-update-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, true); - } }
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b864473/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java index 07af23d..4b68695 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java @@ -21,240 +21,342 @@ 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 java.util.Map; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - - - +import static junit.framework.Assert.*; /** * Handling the startup order of the group */ public class GroupStartupOrderTest extends StratosTestServerManager { private static final Log log = LogFactory.getLog(SampleApplicationsTest.class); - private static final String RESOURCES_PATH = "/application-bursting-test"; + private static final String RESOURCES_PATH = "/group-startup-order-test"; + private static final int GROUP_ACTIVE_TIMEOUT = 300000; + private static final int NODES_START_PARALLEL_TIMEOUT = 30000; + @Test - public void testApplicationBusting() { + public void testTerminationBehavior() { try { - log.info("-------------------------------Started application Bursting test case-------------------------------"); + log.info("-------------------------------Started application startup order test case-------------------------------"); - String autoscalingPolicyId = "autoscaling-policy-application-bursting-test"; + String autoscalingPolicyId = "autoscaling-policy-group-startup-order-test"; + TopologyHandler topologyHandler = TopologyHandler.getInstance(); - boolean addedScalingPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json", RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(addedScalingPolicy, true); + assertTrue(addedScalingPolicy); - boolean addedC1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb-application-bursting-test.json", + boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC1, true); + assertTrue(addedC1); - boolean addedC2 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json", + boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC2, true); + assertTrue(addedC2); - boolean addedC3 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json", + boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "stratos-lb-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC3, true); + assertTrue(addedC3); - - boolean addedC5 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat1-group-startup-order-test.json", + boolean addedC5 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat1-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC5); - boolean addedC6 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat2-group-startup-order-test.json", + boolean addedC6 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat2-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC6); - boolean addedC7 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat3-group-startup-order-test.json", + boolean addedC7 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat3-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC7); - boolean addedC8 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-group-startup-order-test.json", + boolean addedC8 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-group-startup-order-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC8); - boolean addedG1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + - "/" + "esb-php-group-startup-order-test.json", RestConstants.CARTRIDGE_GROUPS, - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(addedG1, true); - - CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClientTenant1. - getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(beanG1.getName(), "esb-php-group-application-bursting-test"); - - boolean addedG2 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + boolean addedG2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "/" + "group6-group-startup-order-test.json", RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME); assertTrue(addedG2); - boolean addedG3 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + boolean addedG3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "/" + "group8-group-startup-order-test.json", RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME); assertTrue(addedG3); - boolean addedN1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + - "network-partition-application-bursting-test-1.json", + boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-group-startup-order-test-1.json", RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(addedN1, true); + assertTrue(addedN1); - - boolean addedN2 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + - "network-partition-application-bursting-test-2.json", - RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(addedN2, true); - - boolean addedDep = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + - "deployment-policy-application-bursting-test.json", + boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + "deployment-policy-group-startup-order-test.json", RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(addedDep, true); + assertTrue(addedDep); - boolean added = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + - "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS, + boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + + "group-startup-order-test.json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME); - assertEquals(added, true); + assertTrue(added); - ApplicationBean bean = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(bean.getApplicationId(), "application-bursting-test"); + ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "group-startup-order-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(bean.getApplicationId(), "group-startup-order-test"); - boolean addAppPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + - "application-policy-application-bursting-test.json", RestConstants.APPLICATION_POLICIES, - RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(addAppPolicy, true); - - ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant1.getEntity( - RestConstants.APPLICATION_POLICIES, - "application-policy-application-bursting-test", ApplicationPolicyBean.class, + boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + "application-policy-group-startup-order-test.json", RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME); + assertTrue(addAppPolicy); //deploy the application - String resourcePath = RestConstants.APPLICATIONS + "/" + "application-bursting-test" + - RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-application-bursting-test"; - boolean deployed = restClientTenant1.deployEntity(resourcePath, + String resourcePath = RestConstants.APPLICATIONS + "/" + "group-startup-order-test" + + RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-group-startup-order-test"; + boolean deployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME); - assertEquals(deployed, true); + assertTrue(deployed); - //Application active handling - TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active, tenant1Id); + String group6 = topologyHandler.generateId(bean.getApplicationId(), + "my-group6-group-startup-order-test", bean.getApplicationId() + "-1"); + + String group8 = topologyHandler.generateId(bean.getApplicationId(), + "my-group8-group-startup-order-test", bean.getApplicationId() + "-1"); + + String lb = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-stratos-lb-group-startup-order-test"); + + String tomcat = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-tomcat-group-startup-order-test"); + + assertCreationOfNodes(lb, tomcat); + + assertCreationOfNodes(tomcat, group6); + + assertCreationOfNodesInParallel(group6, group8); + + assertCreationOfNodes(tomcat, group8); + + String group7 = topologyHandler.generateId(bean.getApplicationId(), + "my-group7-group-startup-order-test", bean.getApplicationId() + "-1"); + + String groupTom2 = topologyHandler.generateId(bean.getApplicationId(), + "my-group6-group-tom2-group-startup-order-test", bean.getApplicationId() + "-1"); + + assertCreationOfNodesInParallel(group7, groupTom2); + + String group7Tomcat = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-group7-tomcat-group-startup-order-test"); + + String group7Tomcat1 = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-group7-tomcat1-group-startup-order-test"); + + assertCreationOfNodes(group7Tomcat, group7Tomcat1); + + String groupTom2Tomcat2 = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-group-tom2-tomcat2-group-startup-order-test"); + + String groupTom2Tomcat3 = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-group-tom2-tomcat3-group-startup-order-test"); + + assertCreationOfNodes(groupTom2Tomcat2, groupTom2Tomcat3); - TopologyHandler.getInstance().assertApplicationForNonAvailability(bean.getApplicationId(),tenant2Id); + String group8Tomcat2 = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-tomcat2-group8-group-startup-order-test"); + + String group8Tomcat = topologyHandler. + getClusterIdFromAlias(bean.getApplicationId(), + "my-tomcat-group8-group-startup-order-test"); + + assertCreationOfNodesInParallel(group8Tomcat2, group8Tomcat); + + //Application active handling + topologyHandler.assertApplicationStatus(bean.getApplicationId(), + ApplicationStatus.Active); //Group active handling - TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId(), tenant1Id); + topologyHandler.assertGroupActivation(bean.getApplicationId()); //Cluster active handling - TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenant1Id); + topologyHandler.assertClusterActivation(bean.getApplicationId()); - boolean removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, + "group6-group-startup-order-test", RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, false); + assertFalse(removedGroup); - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, + "group8-group-startup-order-test", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertFalse(removedGroup); + + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, false); + assertFalse(removedAuto); - boolean removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-group-startup-order-test-1", RestConstants.NETWORK_PARTITIONS_NAME); //Trying to remove the used network partition - assertEquals(removedNet, false); + assertFalse(removedNet); - boolean removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, false); + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-group-startup-order-test", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertFalse(removedDep); //Un-deploying the application - String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "application-bursting-test" + + String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "group-startup-order-test" + RestConstants.APPLICATIONS_UNDEPLOY; - boolean unDeployed = restClientTenant1.undeployEntity(resourcePathUndeploy, + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME); - assertEquals(unDeployed, true); + assertTrue(unDeployed); - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", tenant1Id); + boolean undeploy = topologyHandler.assertApplicationUndeploy("group-startup-order-test"); if (!undeploy) { //Need to forcefully undeploy the application - log.info("Force undeployment is going to start for the [application] " + "application-bursting-test"); + log.info("Force undeployment is going to start for the [application] " + "group-startup-order-test"); - restClientTenant1.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-test" + + restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "group-startup-order-test" + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); - boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", tenant1Id); - assertEquals(String.format("Forceful undeployment failed for the application %s", - "application-bursting-test"), forceUndeployed, true); + boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("group-startup-order-test"); + assertTrue(String.format("Forceful undeployment failed for the application %s", + "group-startup-order-test"), forceUndeployed); } - boolean removed = restClientTenant1.removeEntity(RestConstants.APPLICATIONS, "application-bursting-test", + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "group-startup-order-test", RestConstants.APPLICATIONS_NAME); - assertEquals(removed, true); + assertTrue(removed); - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(beanRemoved, null); + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "group-startup-order-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertNull(beanRemoved); + + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, + "group6-group-startup-order-test", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertTrue(removedGroup); - removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, + "group8-group-startup-order-test", RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, true); + assertTrue(removedGroup); - boolean removedC1 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test", + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "stratos-lb-group-startup-order-test", RestConstants.CARTRIDGES_NAME); - assertEquals(removedC1, true); + assertTrue(removedC1); - boolean removedC2 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test", + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat-group-startup-order-test", RestConstants.CARTRIDGES_NAME); - assertEquals(removedC2, true); + assertTrue(removedC2); - boolean removedC3 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test", + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat1-group-startup-order-test", RestConstants.CARTRIDGES_NAME); - assertEquals(removedC3, true); + assertTrue(removedC3); - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, true); + boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat2-group-startup-order-test", + RestConstants.CARTRIDGES_NAME); + assertTrue(removedC4); - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, true); + boolean removedC5 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat3-group-startup-order-test", + RestConstants.CARTRIDGES_NAME); + assertTrue(removedC5); - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, false); + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertTrue(removedAuto); - boolean removedN2 = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, false); + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-group-startup-order-test", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertTrue(removedDep); - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-application-bursting-test", RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(removeAppPolicy, true); + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-group-startup-order-test-1", RestConstants.NETWORK_PARTITIONS_NAME); + assertFalse(removedNet); - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, true); + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, + "application-policy-group-startup-order-test", RestConstants.APPLICATION_POLICIES_NAME); + assertTrue(removeAppPolicy); - removedN2 = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, true); + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-group-startup-order-test-1", RestConstants.NETWORK_PARTITIONS_NAME); + assertTrue(removedNet); - log.info("-------------------------------Ended application bursting test case-------------------------------"); + log.info("-------------------------------Ended application termination behavior test case-------------------------------"); } catch (Exception e) { - log.error("An error occurred while handling application bursting", e); - assertTrue("An error occurred while handling application bursting", false); + log.error("An error occurred while handling application termination behavior", e); + assertTrue("An error occurred while handling application termination behavior", false); + } + } + + private void assertCreationOfNodes(String firstNodeId, String secondNodeId) { + //group1 started first, then cluster started later + long startTime = System.currentTimeMillis(); + Map<String, Long> activeMembers = TopologyHandler.getInstance().getActivateddMembers(); + Map<String, Long> createdMembers = TopologyHandler.getInstance().getCreatedMembers(); + //Active member should be available at the time cluster is started to create. + while (!activeMembers.containsKey(firstNodeId)) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + activeMembers = TopologyHandler.getInstance().getActivateddMembers(); + if ((System.currentTimeMillis() - startTime) > GROUP_ACTIVE_TIMEOUT) { + break; + } + } + assertTrue(activeMembers.containsKey(firstNodeId)); + + while (!createdMembers.containsKey(secondNodeId)) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + createdMembers = TopologyHandler.getInstance().getCreatedMembers(); + if ((System.currentTimeMillis() - startTime) > GROUP_ACTIVE_TIMEOUT) { + break; + } } + + assertTrue(createdMembers.containsKey(secondNodeId)); + + assertTrue(createdMembers.get(secondNodeId) > activeMembers.get(firstNodeId)); + } + + private void assertCreationOfNodesInParallel(String firstNodeId, String secondNodeId) { + //group1 started first, then cluster started later + long startTime = System.currentTimeMillis(); + Map<String, Long> createdMembers = TopologyHandler.getInstance().getCreatedMembers(); + //Active member should be available at the time cluster is started to create. + + while (!(createdMembers.containsKey(firstNodeId) && createdMembers.containsKey(firstNodeId))) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + createdMembers = TopologyHandler.getInstance().getCreatedMembers(); + if ((System.currentTimeMillis() - startTime) > NODES_START_PARALLEL_TIMEOUT) { + break; + } + } + assertTrue(createdMembers.containsKey(firstNodeId)); + assertTrue(createdMembers.containsKey(firstNodeId)); + } } http://git-wip-us.apache.org/repos/asf/stratos/blob/4b864473/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java index 475ddd4..3cc4ebd 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java @@ -26,7 +26,6 @@ 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.testng.annotations.Test; @@ -42,7 +41,7 @@ import static junit.framework.Assert.*; public class GroupTerminationBehaviorTest extends StratosTestServerManager { private static final Log log = LogFactory.getLog(GroupTerminationBehaviorTest.class); private static final String RESOURCES_PATH = "/group-termination-behavior-test"; - private static final int GROUP_INACTIVE_TIMEOUT = 300000; + private static final int GROUP_INACTIVE_TIMEOUT = 180000; @Test public void testTerminationBehavior() { @@ -52,62 +51,62 @@ public class GroupTerminationBehaviorTest extends StratosTestServerManager { String autoscalingPolicyId = "autoscaling-policy-group-termination-behavior-test"; TopologyHandler topologyHandler = TopologyHandler.getInstance(); - boolean addedScalingPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json", RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); assertTrue(addedScalingPolicy); - boolean addedC1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1-group-termination-behavior-test.json", + boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1-group-termination-behavior-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC1); - boolean addedC2 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2-group-termination-behavior-test.json", + boolean addedC2 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2-group-termination-behavior-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC2); - boolean addedC3 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3-group-termination-behavior-test.json", + boolean addedC3 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3-group-termination-behavior-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC3); - boolean addedC4 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c4-group-termination-behavior-test.json", + boolean addedC4 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c4-group-termination-behavior-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertTrue(addedC4); - boolean addedG1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + boolean addedG1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + "/" + "cartridge-groups-group-termination-behavior-test.json", RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME); assertTrue(addedG1); - CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClientTenant1. + CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient. getEntity(RestConstants.CARTRIDGE_GROUPS, "g-sc-G4-group-termination-behavior-test", CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); assertEquals(beanG1.getName(), "g-sc-G4-group-termination-behavior-test"); - boolean addedN1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + "network-partition-group-termination-behavior-test-1.json", RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); assertTrue(addedN1); - boolean addedDep = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + "deployment-policy-group-termination-behavior-test.json", RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); assertTrue(addedDep); - boolean added = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + + boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + "group-termination-behavior-test.json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME); assertTrue(added); - ApplicationBean bean = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, + ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, "group-termination-behavior-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); assertEquals(bean.getApplicationId(), "group-termination-behavior-test"); - boolean addAppPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + "application-policy-group-termination-behavior-test.json", RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME); assertTrue(addAppPolicy); - ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant1.getEntity( + ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity( RestConstants.APPLICATION_POLICIES, "application-policy-group-termination-behavior-test", ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME); @@ -115,82 +114,86 @@ public class GroupTerminationBehaviorTest extends StratosTestServerManager { //deploy the application String resourcePath = RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" + RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-group-termination-behavior-test"; - boolean deployed = restClientTenant1.deployEntity(resourcePath, + boolean deployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME); assertTrue(deployed); - //Application active handling - topologyHandler.assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active,tenant1Id); - - Application depApplication= topologyHandler.getApplication(bean.getApplicationId(), tenant1Id); - String groupId = topologyHandler.generateId(depApplication.getUniqueIdentifier(), - "g-G1-1x0-group-termination-behavior-test", depApplication.getUniqueIdentifier() + "-1"); + String groupId = topologyHandler.generateId(bean.getApplicationId(), + "g-G1-1x0-group-termination-behavior-test", bean.getApplicationId() + "-1"); String clusterIdC3 = topologyHandler. getClusterIdFromAlias(bean.getApplicationId(), - "c3-1x0-group-termination-behavior-test",tenant1Id); + "c3-1x0-group-termination-behavior-test"); String clusterIdC4 = topologyHandler. getClusterIdFromAlias(bean.getApplicationId(), - "c4-1x0-group-termination-behavior-test",tenant1Id); + "c4-1x0-group-termination-behavior-test"); String clusterIdC2 = topologyHandler. getClusterIdFromAlias(bean.getApplicationId(), - "c2-1x0-group-termination-behavior-test",tenant1Id); + "c2-1x0-group-termination-behavior-test"); assertCreationOfNodes(groupId, clusterIdC2); + assertCreationOfNodes(clusterIdC3, clusterIdC4); + //Application active handling + topologyHandler.assertApplicationStatus(bean.getApplicationId(), + ApplicationStatus.Active); //Group active handling - topologyHandler.assertGroupActivation(bean.getApplicationId(),tenant1Id); + topologyHandler.assertGroupActivation(bean.getApplicationId()); //Cluster active handling - topologyHandler.assertClusterActivation(bean.getApplicationId(),tenant1Id); + topologyHandler.assertClusterActivation(bean.getApplicationId()); //Terminate one member in the cluster TopologyHandler.getInstance().terminateMemberFromCluster( "c3-group-termination-behavior-test", bean.getApplicationId(), - mockIaasApiClient,tenant1Id); + mockIaasApiClient); List<String> clusterIds = new ArrayList<String>(); clusterIds.add(clusterIdC3); clusterIds.add(clusterIdC4); clusterIds.add(clusterIdC2); + assertGroupInactive(groupId, clusterIdC3); - //Application active handling - topologyHandler.assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active,tenant1Id); + assertTerminatingOfNodes(groupId, clusterIds); + + assertTerminationOfNodes(groupId, clusterIds); assertCreationOfNodes(groupId, clusterIdC2); assertCreationOfNodes(clusterIdC3, clusterIdC4); + //Application active handling + topologyHandler.assertApplicationStatus(bean.getApplicationId(), + ApplicationStatus.Active); + //Group active handling - topologyHandler.assertGroupActivation(bean.getApplicationId(),tenant1Id); + topologyHandler.assertGroupActivation(bean.getApplicationId()); //Cluster active handling - topologyHandler.assertClusterActivation(bean.getApplicationId(),tenant1Id); + topologyHandler.assertClusterActivation(bean.getApplicationId()); - boolean removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "g-sc-G4-group-termination-behavior-test", RestConstants.CARTRIDGE_GROUPS_NAME); assertFalse(removedGroup); - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); assertFalse(removedAuto); - boolean removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME); //Trying to remove the used network partition assertFalse(removedNet); - boolean removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-group-termination-behavior-test", RestConstants.DEPLOYMENT_POLICIES_NAME); assertFalse(removedDep); @@ -198,70 +201,70 @@ public class GroupTerminationBehaviorTest extends StratosTestServerManager { String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" + RestConstants.APPLICATIONS_UNDEPLOY; - boolean unDeployed = restClientTenant1.undeployEntity(resourcePathUndeploy, + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME); assertTrue(unDeployed); - boolean undeploy = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test",tenant1Id); + boolean undeploy = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test"); if (!undeploy) { //Need to forcefully undeploy the application log.info("Force undeployment is going to start for the [application] " + "group-termination-behavior-test"); - restClientTenant1.undeployEntity(RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" + + restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); - boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test",tenant1Id); + boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test"); assertTrue(String.format("Forceful undeployment failed for the application %s", "group-termination-behavior-test"), forceUndeployed); } - boolean removed = restClientTenant1.removeEntity(RestConstants.APPLICATIONS, "group-termination-behavior-test", + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "group-termination-behavior-test", RestConstants.APPLICATIONS_NAME); assertTrue(removed); - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, "group-termination-behavior-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); assertNull(beanRemoved); - removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "g-sc-G4-group-termination-behavior-test", RestConstants.CARTRIDGE_GROUPS_NAME); assertTrue(removedGroup); - boolean removedC1 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c1-group-termination-behavior-test", + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1-group-termination-behavior-test", RestConstants.CARTRIDGES_NAME); assertTrue(removedC1); - boolean removedC2 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c2-group-termination-behavior-test", + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2-group-termination-behavior-test", RestConstants.CARTRIDGES_NAME); assertTrue(removedC2); - boolean removedC3 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c3-group-termination-behavior-test", + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3-group-termination-behavior-test", RestConstants.CARTRIDGES_NAME); assertTrue(removedC3); - boolean removedC4 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c4-group-termination-behavior-test", + boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4-group-termination-behavior-test", RestConstants.CARTRIDGES_NAME); assertTrue(removedC4); - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); assertTrue(removedAuto); - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-group-termination-behavior-test", RestConstants.DEPLOYMENT_POLICIES_NAME); assertTrue(removedDep); - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME); assertFalse(removedNet); - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, "application-policy-group-termination-behavior-test", RestConstants.APPLICATION_POLICIES_NAME); assertTrue(removeAppPolicy); - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME); assertTrue(removedNet); http://git-wip-us.apache.org/repos/asf/stratos/blob/4b864473/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 index 427db7d..1e8324e 100644 --- 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 @@ -52,43 +52,43 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage public void testDeployApplication() { try { log.info("-------------------------------Started Partition One after another test case-------------------------------"); - + TopologyHandler topologyHandler = TopologyHandler.getInstance(); String autoscalingPolicyId = "autoscaling-policy-3"; - boolean addedScalingPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json", RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); assertEquals(addedScalingPolicy, true); - boolean addedC1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c7.json", + boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c7.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertEquals(addedC1, true); - boolean addedN1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + "network-partition-11.json", RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); assertEquals(addedN1, true); - boolean addedDep = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + "deployment-policy-5.json", RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); assertEquals(addedDep, true); - boolean added = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + + boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + "single-cluster-scaling-test.json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME); assertEquals(added, true); - ApplicationBean bean = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, + 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 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + "application-policy-4.json", RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME); assertEquals(addAppPolicy, true); - ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant1.getEntity( + ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity( RestConstants.APPLICATION_POLICIES, "application-policy-4", ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME); @@ -96,16 +96,16 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage //deploy the application String resourcePath = RestConstants.APPLICATIONS + "/" + "single-cluster-scaling-test" + RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-4"; - boolean deployed = restClientTenant1.deployEntity(resourcePath, + boolean deployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME); assertEquals(deployed, true); //Application active handling - TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active, tenant1Id); + topologyHandler.assertApplicationStatus(bean.getApplicationId(), + ApplicationStatus.Active); //Cluster active handling - TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenant1Id); + topologyHandler.assertClusterActivation(bean.getApplicationId()); //Verifying whether members got created using round robin algorithm assertClusterWithRoundRobinAlgorithm(bean.getApplicationId()); @@ -113,17 +113,17 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage //Removing one member from cluster and check for auto healing - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); assertEquals(removedAuto, false); - boolean removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + 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 = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-5", RestConstants.DEPLOYMENT_POLICIES_NAME); assertEquals(removedDep, false); @@ -131,55 +131,55 @@ public class PartitionOneAfterAnotherClusterTest extends StratosTestServerManage String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "single-cluster-scaling-test" + RestConstants.APPLICATIONS_UNDEPLOY; - boolean unDeployed = restClientTenant1.undeployEntity(resourcePathUndeploy, + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME); assertEquals(unDeployed, true); - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test", tenant1Id); + boolean undeploy = topologyHandler.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"); - restClientTenant1.undeployEntity(RestConstants.APPLICATIONS + "/" + "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", tenant1Id); + boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test"); assertEquals(String.format("Forceful undeployment failed for the application %s", "single-cluster-scaling-test"), forceUndeployed, true); } - boolean removed = restClientTenant1.removeEntity(RestConstants.APPLICATIONS, "single-cluster-scaling-test", + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "single-cluster-scaling-test", RestConstants.APPLICATIONS_NAME); assertEquals(removed, true); - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, "single-cluster-scaling-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); assertEquals(beanRemoved, null); - boolean removedC1 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c7", + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c7", RestConstants.CARTRIDGES_NAME); assertEquals(removedC1, true); - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); assertEquals(removedAuto, true); - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-5", RestConstants.DEPLOYMENT_POLICIES_NAME); assertEquals(removedDep, true); - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-11", RestConstants.NETWORK_PARTITIONS_NAME); assertEquals(removedNet, false); - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, "application-policy-4", RestConstants.APPLICATION_POLICIES_NAME); assertEquals(removeAppPolicy, true); - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-11", RestConstants.NETWORK_PARTITIONS_NAME); assertEquals(removedNet, true);
