http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/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 deleted file mode 100644 index f210b12..0000000 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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; - -/** - * This will handle the application bursting test cases - */ -public class ApplicationBurstingTest extends StratosTestServerManager { - private static final Log log = LogFactory.getLog(SampleApplicationsTest.class); - private static final String RESOURCES_PATH = "/application-bursting-test"; - - - @Test - public void testApplicationBusting() { - try { - log.info("----------------------------Started application Bursting test case----------------------------"); - - String autoscalingPolicyId = "autoscaling-policy-application-bursting-test"; - - boolean addedScalingPolicy = - restClientTenant1.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 + "/" + "esb-application-bursting-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC1, true); - - boolean addedC2 = restClientTenant1.addEntity( - RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC2, true); - - boolean addedC3 = restClientTenant1.addEntity( - RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC3, true); - - boolean addedG1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + - "/" + "esb-php-group-application-bursting-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 addedN1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + - "network-partition-application-bursting-test-1.json", - RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(addedN1, true); - - 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", - RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(addedDep, true); - - boolean added = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + - "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS, - RestConstants.APPLICATIONS_NAME); - assertEquals(added, true); - - ApplicationBean bean = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(bean.getApplicationId(), "application-bursting-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, - RestConstants.APPLICATION_POLICIES_NAME); - - //deploy the application - String resourcePath = RestConstants.APPLICATIONS + "/" + "application-bursting-test" + - RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-application-bursting-test"; - boolean deployed = restClientTenant1.deployEntity(resourcePath, - RestConstants.APPLICATIONS_NAME); - assertEquals(deployed, true); - - //Application active handling - TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active, tenant1Id); - - //Group active handling - TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId(), tenant1Id); - - //Cluster active handling - TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenant1Id); - - boolean removedGroup = restClientTenant1 - .removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, false); - - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, false); - - boolean removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", - RestConstants.NETWORK_PARTITIONS_NAME); - //Trying to remove the used network partition - assertEquals(removedNet, false); - - boolean removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, false); - - //Un-deploying the application - String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "application-bursting-test" + - RestConstants.APPLICATIONS_UNDEPLOY; - - boolean unDeployed = restClientTenant1.undeployEntity(resourcePathUndeploy, - RestConstants.APPLICATIONS_NAME); - assertEquals(unDeployed, true); - - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", - tenant1Id); - if (!undeploy) { - //Need to forcefully undeploy the application - log.info("Force undeployment is going to start for the [application] " + "application-bursting-test"); - - restClientTenant1.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-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 removed = restClientTenant1.removeEntity(RestConstants.APPLICATIONS, "application-bursting-test", - RestConstants.APPLICATIONS_NAME); - assertEquals(removed, true); - - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(beanRemoved, null); - - removedGroup = restClientTenant1 - .removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, true); - - boolean removedC1 = - restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC1, true); - - boolean removedC2 = - restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC2, true); - - boolean removedC3 = - restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC3, true); - - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, true); - - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, true); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, false); - - boolean removedN2 = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, false); - - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-application-bursting-test", RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(removeAppPolicy, true); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, true); - - removedN2 = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, 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); - } - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/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 deleted file mode 100644 index 9ba62f6..0000000 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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.integration.tests.rest.RestClient; -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 RESOURCES_PATH = "/application-update-test"; - - @Test - public void testDeployApplication() { - try { - - String autoscalingPolicyId = "autoscaling-policy-application-update-test"; - String applicationId="g-sc-G123-1-application-update-test"; - - testApplicationRuntimeForTenant(restClientTenant1,tenant1Id,autoscalingPolicyId) ; - - TopologyHandler.getInstance().assertApplicationForNonAvailability(applicationId,tenant2Id); - - //Updating application - boolean updated = restClientTenant1.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.getInstance().assertClusterMinMemberCount(applicationId, 1, tenant1Id); - - ApplicationBean updatedBean = (ApplicationBean) restClientTenant1.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", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, false); - - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, false); - - boolean removedNet = restClientTenant1.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, - "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); - - 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); - } - } - - 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); - } - - private void testApplicationUndeplymentForTenant(RestClient restClientTenant,int tenantId,String autoscalingPolicyId){ - - String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1-application-update-test" + - RestConstants.APPLICATIONS_UNDEPLOY; - - 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"); - - restClientTenant.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", tenantId); - assertEquals(String.format("Forceful undeployment failed for the application %s", - "g-sc-G123-1-application-update-test"), forceUndeployed, true); - - } - - boolean removed = restClientTenant.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1-application-update-test", - RestConstants.APPLICATIONS_NAME); - assertEquals(removed, true); - - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant.getEntity(RestConstants.APPLICATIONS, - "g-sc-G123-1-application-update-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(beanRemoved, null); - - boolean removedGroup = restClientTenant.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1-application-update-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, true); - - boolean removedC1 = restClientTenant.removeEntity(RestConstants.CARTRIDGES, "c1-application-update-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC1, true); - - boolean removedC2 = restClientTenant.removeEntity(RestConstants.CARTRIDGES, "c2-application-update-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC2, true); - - boolean removedC3 = restClientTenant.removeEntity(RestConstants.CARTRIDGES, "c3-application-update-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC3, true); - - boolean removedAuto = restClientTenant.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, true); - - boolean removedDep = restClientTenant.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-update-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, true); - - boolean removedNet = restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-update-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, false); - - boolean removedN2 = restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-update-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, false); - - boolean removeAppPolicy = restClientTenant.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-application-update-test", RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(removeAppPolicy, true); - - 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/c0664270/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 deleted file mode 100644 index 07af23d..0000000 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupStartupOrderTest.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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; - - - - -/** - * 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"; - - @Test - public void testApplicationBusting() { - try { - log.info("-------------------------------Started application Bursting test case-------------------------------"); - - String autoscalingPolicyId = "autoscaling-policy-application-bursting-test"; - - boolean addedScalingPolicy = restClientTenant1.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 + "/" + "esb-application-bursting-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC1, true); - - boolean addedC2 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC2, true); - - boolean addedC3 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC3, true); - - - boolean addedC5 = restClientTenant1.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", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertTrue(addedC6); - - boolean addedC7 = restClientTenant1.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", - 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 + - "/" + "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 + - "/" + "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", - RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(addedN1, true); - - - 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", - RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(addedDep, true); - - boolean added = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + - "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS, - RestConstants.APPLICATIONS_NAME); - assertEquals(added, true); - - ApplicationBean bean = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(bean.getApplicationId(), "application-bursting-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, - RestConstants.APPLICATION_POLICIES_NAME); - - //deploy the application - String resourcePath = RestConstants.APPLICATIONS + "/" + "application-bursting-test" + - RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-application-bursting-test"; - boolean deployed = restClientTenant1.deployEntity(resourcePath, - RestConstants.APPLICATIONS_NAME); - assertEquals(deployed, true); - - //Application active handling - TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active, tenant1Id); - - TopologyHandler.getInstance().assertApplicationForNonAvailability(bean.getApplicationId(),tenant2Id); - - //Group active handling - TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId(), tenant1Id); - - //Cluster active handling - TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenant1Id); - - boolean removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, false); - - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, false); - - boolean removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", - RestConstants.NETWORK_PARTITIONS_NAME); - //Trying to remove the used network partition - assertEquals(removedNet, false); - - boolean removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, false); - - //Un-deploying the application - String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "application-bursting-test" + - RestConstants.APPLICATIONS_UNDEPLOY; - - boolean unDeployed = restClientTenant1.undeployEntity(resourcePathUndeploy, - RestConstants.APPLICATIONS_NAME); - assertEquals(unDeployed, true); - - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", tenant1Id); - if (!undeploy) { - //Need to forcefully undeploy the application - log.info("Force undeployment is going to start for the [application] " + "application-bursting-test"); - - restClientTenant1.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-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 removed = restClientTenant1.removeEntity(RestConstants.APPLICATIONS, "application-bursting-test", - RestConstants.APPLICATIONS_NAME); - assertEquals(removed, true); - - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(beanRemoved, null); - - removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertEquals(removedGroup, true); - - boolean removedC1 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC1, true); - - boolean removedC2 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC2, true); - - boolean removedC3 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC3, true); - - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, true); - - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-application-bursting-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, true); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, false); - - boolean removedN2 = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, false); - - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-application-bursting-test", RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(removeAppPolicy, true); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, true); - - removedN2 = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedN2, 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); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/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 deleted file mode 100644 index 475ddd4..0000000 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTest.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * 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.Application; -import org.apache.stratos.messaging.domain.application.ApplicationStatus; -import org.testng.annotations.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static junit.framework.Assert.*; - -/** - * Handling the termination behavior of the group - */ -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; - - @Test - public void testTerminationBehavior() { - try { - log.info("-------------------------------Started application termination behavior test case-------------------------------"); - - String autoscalingPolicyId = "autoscaling-policy-group-termination-behavior-test"; - TopologyHandler topologyHandler = TopologyHandler.getInstance(); - - boolean addedScalingPolicy = restClientTenant1.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", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertTrue(addedC1); - - boolean addedC2 = restClientTenant1.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", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertTrue(addedC3); - - boolean addedC4 = restClientTenant1.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 + - "/" + "cartridge-groups-group-termination-behavior-test.json", RestConstants.CARTRIDGE_GROUPS, - RestConstants.CARTRIDGE_GROUPS_NAME); - assertTrue(addedG1); - - CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClientTenant1. - 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 + "/" + - "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 + "/" + - "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 + "/" + - "group-termination-behavior-test.json", RestConstants.APPLICATIONS, - RestConstants.APPLICATIONS_NAME); - assertTrue(added); - - ApplicationBean bean = (ApplicationBean) restClientTenant1.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 + "/" + - "application-policy-group-termination-behavior-test.json", RestConstants.APPLICATION_POLICIES, - RestConstants.APPLICATION_POLICIES_NAME); - assertTrue(addAppPolicy); - - ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant1.getEntity( - RestConstants.APPLICATION_POLICIES, - "application-policy-group-termination-behavior-test", ApplicationPolicyBean.class, - RestConstants.APPLICATION_POLICIES_NAME); - - //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, - 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 clusterIdC3 = topologyHandler. - getClusterIdFromAlias(bean.getApplicationId(), - "c3-1x0-group-termination-behavior-test",tenant1Id); - - String clusterIdC4 = topologyHandler. - getClusterIdFromAlias(bean.getApplicationId(), - "c4-1x0-group-termination-behavior-test",tenant1Id); - - String clusterIdC2 = topologyHandler. - getClusterIdFromAlias(bean.getApplicationId(), - "c2-1x0-group-termination-behavior-test",tenant1Id); - - assertCreationOfNodes(groupId, clusterIdC2); - assertCreationOfNodes(clusterIdC3, clusterIdC4); - - - //Group active handling - topologyHandler.assertGroupActivation(bean.getApplicationId(),tenant1Id); - - //Cluster active handling - topologyHandler.assertClusterActivation(bean.getApplicationId(),tenant1Id); - - //Terminate one member in the cluster - TopologyHandler.getInstance().terminateMemberFromCluster( - "c3-group-termination-behavior-test", - bean.getApplicationId(), - mockIaasApiClient,tenant1Id); - - List<String> clusterIds = new ArrayList<String>(); - clusterIds.add(clusterIdC3); - clusterIds.add(clusterIdC4); - clusterIds.add(clusterIdC2); - - - //Application active handling - topologyHandler.assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active,tenant1Id); - - assertCreationOfNodes(groupId, clusterIdC2); - - assertCreationOfNodes(clusterIdC3, clusterIdC4); - - //Group active handling - topologyHandler.assertGroupActivation(bean.getApplicationId(),tenant1Id); - - //Cluster active handling - topologyHandler.assertClusterActivation(bean.getApplicationId(),tenant1Id); - - boolean removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, - "g-sc-G4-group-termination-behavior-test", - RestConstants.CARTRIDGE_GROUPS_NAME); - assertFalse(removedGroup); - - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertFalse(removedAuto); - - boolean removedNet = restClientTenant1.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, - "deployment-policy-group-termination-behavior-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertFalse(removedDep); - - //Un-deploying the application - String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "group-termination-behavior-test" + - RestConstants.APPLICATIONS_UNDEPLOY; - - boolean unDeployed = restClientTenant1.undeployEntity(resourcePathUndeploy, - RestConstants.APPLICATIONS_NAME); - assertTrue(unDeployed); - - boolean undeploy = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test",tenant1Id); - 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" + - RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); - - boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("group-termination-behavior-test",tenant1Id); - 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", - RestConstants.APPLICATIONS_NAME); - assertTrue(removed); - - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "group-termination-behavior-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertNull(beanRemoved); - - removedGroup = restClientTenant1.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", - RestConstants.CARTRIDGES_NAME); - assertTrue(removedC1); - - boolean removedC2 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c2-group-termination-behavior-test", - RestConstants.CARTRIDGES_NAME); - assertTrue(removedC2); - - boolean removedC3 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c3-group-termination-behavior-test", - RestConstants.CARTRIDGES_NAME); - assertTrue(removedC3); - - boolean removedC4 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c4-group-termination-behavior-test", - RestConstants.CARTRIDGES_NAME); - assertTrue(removedC4); - - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertTrue(removedAuto); - - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-group-termination-behavior-test", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertTrue(removedDep); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertFalse(removedNet); - - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-group-termination-behavior-test", RestConstants.APPLICATION_POLICIES_NAME); - assertTrue(removeAppPolicy); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-group-termination-behavior-test-1", RestConstants.NETWORK_PARTITIONS_NAME); - assertTrue(removedNet); - - log.info("-------------------------------Ended application termination behavior test case-------------------------------"); - - } catch (Exception e) { - log.error("An error occurred while handling application termination behavior", e); - assertTrue("An error occurred while handling application termination behavior", false); - } - } - - private void assertGroupInactive(String groupId, String clusterId) { - long startTime = System.currentTimeMillis(); - Map<String, Long> inActiveMap = TopologyHandler.getInstance().getInActiveMembers(); - - while (!inActiveMap.containsKey(clusterId)) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - inActiveMap = TopologyHandler.getInstance().getInActiveMembers(); - if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) { - break; - } - } - assertTrue(inActiveMap.containsKey(clusterId)); - - while (!inActiveMap.containsKey(groupId)) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - inActiveMap = TopologyHandler.getInstance().getInActiveMembers(); - if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) { - break; - } - } - assertTrue(inActiveMap.containsKey(groupId)); - - } - - private void assertTerminatingOfNodes(String groupId, List<String> clusterIds) { - Map<String, Long> terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers(); - for (String clusterId : clusterIds) { - long startTime = System.currentTimeMillis(); - while (!terminatingMembers.containsKey(clusterId)) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers(); - if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) { - break; - } - } - assertTrue(terminatingMembers.containsKey(groupId)); - } - long startTime = System.currentTimeMillis(); - while (!terminatingMembers.containsKey(groupId)) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers(); - if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) { - break; - } - } - assertTrue(terminatingMembers.containsKey(groupId)); - - } - - private void assertTerminationOfNodes(String groupId, List<String> clusterIds) { - long startTime = System.currentTimeMillis(); - Map<String, Long> terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers(); - - for (String clusterId : clusterIds) { - while (!terminatedMembers.containsKey(clusterId)) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers(); - if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) { - break; - } - } - assertTrue(terminatedMembers.containsKey(clusterId)); - } - - while (!terminatedMembers.containsKey(groupId)) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers(); - if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) { - break; - } - } - - assertTrue(terminatedMembers.containsKey(groupId)); - } - - 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_INACTIVE_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_INACTIVE_TIMEOUT) { - break; - } - } - - assertTrue(createdMembers.containsKey(secondNodeId)); - - assertTrue(createdMembers.get(secondNodeId) > activeMembers.get(firstNodeId)); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/c0664270/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 deleted file mode 100644 index 427db7d..0000000 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTest.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * 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 RESOURCES_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 = restClientTenant1.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", - RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); - assertEquals(addedC1, true); - - boolean addedN1 = restClientTenant1.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 + "/" + - "deployment-policy-5.json", - RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(addedDep, true); - - boolean added = restClientTenant1.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, - "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 + "/" + - "application-policy-4.json", RestConstants.APPLICATION_POLICIES, - RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(addAppPolicy, true); - - ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant1.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 = restClientTenant1.deployEntity(resourcePath, - RestConstants.APPLICATIONS_NAME); - assertEquals(deployed, true); - - //Application active handling - TopologyHandler.getInstance().assertApplicationStatus(bean.getApplicationId(), - ApplicationStatus.Active, tenant1Id); - - //Cluster active handling - TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenant1Id); - - //Verifying whether members got created using round robin algorithm - assertClusterWithRoundRobinAlgorithm(bean.getApplicationId()); - - //Removing one member from cluster and check for auto healing - - - boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, false); - - boolean removedNet = restClientTenant1.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, - "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 = restClientTenant1.undeployEntity(resourcePathUndeploy, - RestConstants.APPLICATIONS_NAME); - assertEquals(unDeployed, true); - - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test", tenant1Id); - 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" + - RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); - - boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("single-cluster-scaling-test", tenant1Id); - 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", - RestConstants.APPLICATIONS_NAME); - assertEquals(removed, true); - - ApplicationBean beanRemoved = (ApplicationBean) restClientTenant1.getEntity(RestConstants.APPLICATIONS, - "single-cluster-scaling-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); - assertEquals(beanRemoved, null); - - boolean removedC1 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "c7", - RestConstants.CARTRIDGES_NAME); - assertEquals(removedC1, true); - - - removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, - autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); - assertEquals(removedAuto, true); - - removedDep = restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES, - "deployment-policy-5", RestConstants.DEPLOYMENT_POLICIES_NAME); - assertEquals(removedDep, true); - - removedNet = restClientTenant1.removeEntity(RestConstants.NETWORK_PARTITIONS, - "network-partition-11", RestConstants.NETWORK_PARTITIONS_NAME); - assertEquals(removedNet, false); - - - boolean removeAppPolicy = restClientTenant1.removeEntity(RestConstants.APPLICATION_POLICIES, - "application-policy-4", RestConstants.APPLICATION_POLICIES_NAME); - assertEquals(removeAppPolicy, true); - - removedNet = restClientTenant1.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)); - } - } - } - - } - - - } - - } - - - } -}
