http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/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 new file mode 100644 index 0000000..e62c4a5 --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java @@ -0,0 +1,226 @@ +/* + * 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.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 TEST_PATH = "/application-bursting-test"; + + + @Test + public void testApplicationBusting() { + try { + log.info("Started application Bursting test case**************************************"); + + String autoscalingPolicyId = "autoscaling-policy-2"; + + boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + + "/" + autoscalingPolicyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(addedScalingPolicy, true); + + boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC1, true); + + boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC2, true); + + boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC3, true); + + boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + "/" + "esb-php-group.json", RestConstants.CARTRIDGE_GROUPS, + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(addedG1, true); + + CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(beanG1.getName(), "esb-php-group"); + + boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-9.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN1, true); + + boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-10.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN2, true); + + boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + "deployment-policy-4.json", + RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(addedDep, true); + + boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" + + "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS, + RestConstants.APPLICATIONS_NAME); + assertEquals(added, true); + + ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(bean.getApplicationId(), "cartridge-group-app"); + + boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + "application-policy-3.json", RestConstants.APPLICATION_POLICIES, + RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(addAppPolicy, true); + + ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity( + RestConstants.APPLICATION_POLICIES, + "application-policy-3", ApplicationPolicyBean.class, + RestConstants.APPLICATION_POLICIES_NAME); + + //deploy the application + String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" + + RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3"; + boolean deployed = restClient.deployEntity(resourcePath, + RestConstants.APPLICATIONS_NAME); + assertEquals(deployed, true); + + //Application active handling + TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId()); + + //Group active handling + TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId()); + + //Cluster active handling + TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId()); + + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, false); + + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, false); + + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-9", + RestConstants.NETWORK_PARTITIONS_NAME); + //Trying to remove the used network partition + assertEquals(removedNet, false); + + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, false); + + //Un-deploying the application + String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" + + RestConstants.APPLICATIONS_UNDEPLOY; + + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, + RestConstants.APPLICATIONS_NAME); + assertEquals(unDeployed, true); + + boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app"); + if (!undeploy) { + //Need to forcefully undeploy the application + log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app"); + + restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" + + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); + + boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app"); + assertEquals(String.format("Forceful undeployment failed for the application %s", + "cartridge-group-app"), forceUndeployed, true); + + } + + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app", + RestConstants.APPLICATIONS_NAME); + assertEquals(removed, true); + + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(beanRemoved, null); + + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, true); + + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC1, true); + + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC2, true); + + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC3, true); + + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, true); + + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, false); + + boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, false); + + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, + "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(removeAppPolicy, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, true); + + removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-10", 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/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java new file mode 100644 index 0000000..2dad064 --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java @@ -0,0 +1,427 @@ +/* + * 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.testng.annotations.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * Sample application tests with application add, . + */ +public class SampleApplicationsTest extends StratosTestServerManager { + private static final Log log = LogFactory.getLog(SampleApplicationsTest.class); + private static final String TEST_PATH = "/sample-applications-test"; + + @Test + public void testApplication() { + log.info("Started application test case**************************************"); + String autoscalingPolicyId = "autoscaling-policy-1"; + + try { + boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + + "/" + autoscalingPolicyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(addedScalingPolicy, true); + + boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC1, true); + + boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC2, true); + + boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC3, true); + + boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + "/" + "cartrdige-nested.json", RestConstants.CARTRIDGE_GROUPS, + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(addedG1, true); + + CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "G1", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(beanG1.getName(), "G1"); + + boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-1.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN1, true); + + boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-2.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN2, true); + + boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + "deployment-policy-1.json", + RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(addedDep, true); + + boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" + + "g-sc-G123-1.json", RestConstants.APPLICATIONS, + RestConstants.APPLICATIONS_NAME); + assertEquals(added, true); + + ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(bean.getApplicationId(), "g-sc-G123-1"); + + assertEquals(bean.getComponents().getGroups().get(0).getName(), "G1"); + assertEquals(bean.getComponents().getGroups().get(0).getAlias(), "group1"); + assertEquals(bean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1); + assertEquals(bean.getComponents().getGroups().get(0).getGroupMinInstances(), 1); + + assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1"); + assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1); + assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2); + + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2"); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2"); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1); + + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2"); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2); + + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3"); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3"); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 2); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1); + + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3"); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1); + assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2); + + boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/g-sc-G123-1-v1.json", + RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME); + assertEquals(updated, true); + + ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + + assertEquals(bean.getApplicationId(), "g-sc-G123-1"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getName(), "G1"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getAlias(), "group1"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMinInstances(), 1); + + assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2); + assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3); + + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1); + + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 4); + + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 3); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 2); + + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3"); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2); + assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3); + + + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, false); + + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, false); + + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-1", + RestConstants.NETWORK_PARTITIONS_NAME); + //Trying to remove the used network partition + assertEquals(removedNet, false); + + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, false); + + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1", + RestConstants.APPLICATIONS_NAME); + assertEquals(removed, true); + + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(beanRemoved, null); + + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, true); + + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC1, true); + + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC2, true); + + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC3, true); + + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, true); + + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, true); + + boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, true); + + log.info("Ended application test case**************************************"); + + } catch (Exception e) { + log.error("An error occurred while handling application test case", e); + assertTrue("An error occurred while handling application test case", false); + } + } + + @Test(dependsOnMethods = {"testApplication"}) + public void testDeployApplication() { + try { + log.info("Started application deploy/undeploy test case**************************************"); + + String autoscalingPolicyId = "autoscaling-policy-1"; + + boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + + "/" + autoscalingPolicyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(addedScalingPolicy, true); + + boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC1, true); + + boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC2, true); + + boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC3, true); + + boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + "/" + "cartrdige-nested.json", RestConstants.CARTRIDGE_GROUPS, + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(addedG1, true); + + CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "G1", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(beanG1.getName(), "G1"); + + boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-1.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN1, true); + + boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-2.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN2, true); + + boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + "deployment-policy-1.json", + RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(addedDep, true); + + boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" + + "g-sc-G123-1.json", RestConstants.APPLICATIONS, + RestConstants.APPLICATIONS_NAME); + assertEquals(added, true); + + ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(bean.getApplicationId(), "g-sc-G123-1"); + + boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + "application-policy-1.json", RestConstants.APPLICATION_POLICIES, + RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(addAppPolicy, true); + + ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity( + RestConstants.APPLICATION_POLICIES, + "application-policy-1", ApplicationPolicyBean.class, + RestConstants.APPLICATION_POLICIES_NAME); + + //deploy the application + String resourcePath = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" + + RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-1"; + boolean deployed = restClient.deployEntity(resourcePath, + RestConstants.APPLICATIONS_NAME); + assertEquals(deployed, true); + + //Application active handling + TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId()); + + //Group active handling + TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId()); + + //Cluster active handling + TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId()); + + //Updating application + boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" + + "g-sc-G123-1-v1.json", RestConstants.APPLICATIONS, + RestConstants.APPLICATIONS_NAME); + assertEquals(updated, true); + + TopologyHandler.getInstance().assertGroupInstanceCount(bean.getApplicationId(), "group3", 2); + + TopologyHandler.getInstance().assertClusterMinMemberCount(bean.getApplicationId(), 2); + + ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(updatedBean.getApplicationId(), "g-sc-G123-1"); + + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, false); + + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, false); + + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-1", + RestConstants.NETWORK_PARTITIONS_NAME); + //Trying to remove the used network partition + assertEquals(removedNet, false); + + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, false); + + //Un-deploying the application + String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" + + RestConstants.APPLICATIONS_UNDEPLOY; + + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, + RestConstants.APPLICATIONS_NAME); + assertEquals(unDeployed, true); + + boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1"); + if (!undeploy) { + //Need to forcefully undeploy the application + log.info("Force undeployment is going to start for the [application] " + "g-sc-G123-1"); + + restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" + + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); + + boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1"); + assertEquals(String.format("Forceful undeployment failed for the application %s", + "g-sc-G123-1"), forceUndeployed, true); + + } + + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1", + RestConstants.APPLICATIONS_NAME); + assertEquals(removed, true); + + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(beanRemoved, null); + + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, true); + + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC1, true); + + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC2, true); + + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC3, true); + + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, true); + + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, false); + + boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, false); + + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, + "application-policy-1", RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(removeAppPolicy, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, true); + + removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, true); + + log.info("Ended application deploy/undeploy test case**************************************"); + + } catch (Exception e) { + log.error("An error occurred while handling application deployment/undeployment", e); + assertTrue("An error occurred while handling application deployment/undeployment", false); + } + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java new file mode 100644 index 0000000..2fd4100 --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java @@ -0,0 +1,233 @@ +/* + * 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.testng.annotations.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * This will handle the scale-up and scale-down of a particular cluster bursting test cases + */ +public class SingleClusterScalingTest extends StratosTestServerManager { + private static final Log log = LogFactory.getLog(SampleApplicationsTest.class); + private static final String TEST_PATH = "/application-bursting-test"; + + + @Test + public void testDeployApplication() { + try { + log.info("Started application Bursting test case**************************************"); + + String autoscalingPolicyId = "autoscaling-policy-2"; + + boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + + "/" + autoscalingPolicyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(addedScalingPolicy, true); + + boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC1, true); + + boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC2, true); + + boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(addedC3, true); + + boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + "/" + "esb-php-group.json", RestConstants.CARTRIDGE_GROUPS, + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(addedG1, true); + + CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(beanG1.getName(), "esb-php-group"); + + boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-9.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN1, true); + + boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-10.json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN2, true); + + boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + "deployment-policy-4.json", + RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(addedDep, true); + + boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" + + "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS, + RestConstants.APPLICATIONS_NAME); + assertEquals(added, true); + + ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(bean.getApplicationId(), "cartridge-group-app"); + + boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + "application-policy-3.json", RestConstants.APPLICATION_POLICIES, + RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(addAppPolicy, true); + + ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity( + RestConstants.APPLICATION_POLICIES, + "application-policy-3", ApplicationPolicyBean.class, + RestConstants.APPLICATION_POLICIES_NAME); + + //deploy the application + String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" + + RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3"; + boolean deployed = restClient.deployEntity(resourcePath, + RestConstants.APPLICATIONS_NAME); + assertEquals(deployed, true); + + //Application active handling + TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId()); + + //Group active handling + TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId()); + + //Cluster active handling + TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId()); + + boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, false); + + boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, false); + + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-9", + RestConstants.NETWORK_PARTITIONS_NAME); + //Trying to remove the used network partition + assertEquals(removedNet, false); + + boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, false); + + //Un-deploying the application + String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" + + RestConstants.APPLICATIONS_UNDEPLOY; + + boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, + RestConstants.APPLICATIONS_NAME); + assertEquals(unDeployed, true); + + boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app"); + if (!undeploy) { + //Need to forcefully undeploy the application + log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app"); + + restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" + + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); + + boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app"); + assertEquals(String.format("Forceful undeployment failed for the application %s", + "cartridge-group-app"), forceUndeployed, true); + + } + + boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app", + RestConstants.APPLICATIONS_NAME); + assertEquals(removed, true); + + ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS, + "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); + assertEquals(beanRemoved, null); + + removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(removedGroup, true); + + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC1, true); + + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC2, true); + + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat", + RestConstants.CARTRIDGES_NAME); + assertEquals(removedC3, true); + + removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(removedAuto, true); + + removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, + "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME); + assertEquals(removedDep, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, false); + + boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, false); + + boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, + "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(removeAppPolicy, true); + + removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedNet, true); + + removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-10", 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); + } + } + + @Test(dependsOnMethods = {"testApplication"}) + public void testClusterScalingUp() { + + } + + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java new file mode 100644 index 0000000..4cd3235 --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java @@ -0,0 +1,129 @@ +/* + * 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.group; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean; +import org.apache.stratos.integration.tests.RestConstants; +import org.apache.stratos.integration.tests.StratosTestServerManager; +import org.testng.annotations.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * Test to handle Cartridge group CRUD operations + */ +public class CartridgeGroupTest extends StratosTestServerManager { + private static final Log log = LogFactory.getLog(CartridgeGroupTest.class); + private static final String TEST_PATH = "/cartridge-group-test"; + + @Test + public void testCartridgeGroup() { + try { + log.info("Started Cartridge group test case**************************************"); + + boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c4.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c4"), addedC1, true); + + boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c5.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c5"), addedC2, true); + + boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c6.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c6"), addedC3, true); + + boolean added = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + "/" + "g4-g5-g6.json", RestConstants.CARTRIDGE_GROUPS, + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge Group did not added: [cartridge-group-name] %s", + "g4-g5-g6"), added, true); + CartridgeGroupBean bean = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "G4", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge Group name did not match: [cartridge-group-name] %s", + "g4-g5-g6.json"), bean.getName(), "G4"); + + boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH + + "/" + "g4-g5-g6-v1.json", + RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge Group did not updated: [cartridge-group-name] %s", + "g4-g5-g6"), updated, true); + CartridgeGroupBean updatedBean = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "G4", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Updated Cartridge Group didn't match: [cartridge-group-name] %s", + "g4-g5-g6"), updatedBean.getName(), "G4"); + + boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge can be removed while it is used in " + + "cartridge group: [cartridge-name] %s", "c4"), removedC1, false); + + boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge can be removed while it is used in " + + "cartridge group: [cartridge-name] %s", + "c5"), removedC2, false); + + boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge can be removed while it is used in " + + "cartridge group: [cartridge-name] %s", + "c6"), removedC3, false); + + boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge Group did not removed: [cartridge-group-name] %s", + "g4-g5-g6"), removed, true); + + CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient. + getEntity(RestConstants.CARTRIDGE_GROUPS, "G4", + CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge Group did not removed completely: " + + "[cartridge-group-name] %s", + "g4-g5-g6"), beanRemoved, null); + + removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s", + "c4"), removedC1, true); + + removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s", + "c5"), removedC2, true); + + removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6", + RestConstants.CARTRIDGE_GROUPS_NAME); + assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s", + "c6"), removedC3, true); + + log.info("Ended Cartridge group test case**************************************"); + + } catch (Exception e) { + log.error("An error occurred while handling Cartridge group test case", e); + assertTrue("An error occurred while handling Cartridge group test case", false); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java new file mode 100644 index 0000000..e861e12 --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java @@ -0,0 +1,130 @@ +/* + * 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.group; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.beans.PropertyBean; +import org.apache.stratos.common.beans.cartridge.CartridgeBean; +import org.apache.stratos.integration.tests.RestConstants; +import org.apache.stratos.integration.tests.StratosTestServerManager; +import org.testng.annotations.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * Test to handle Cartridge CRUD operations + */ +public class CartridgeTest extends StratosTestServerManager { + private static final Log log = LogFactory.getLog(CartridgeTest.class); + private static final String TEST_PATH = "/cartridge-test"; + + + @Test + public void testCartridge() { + log.info("Started Cartridge test case**************************************"); + + try { + String cartridgeType = "c0"; + boolean added = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + + cartridgeType + ".json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(added, true); + CartridgeBean bean = (CartridgeBean) restClient. + getEntity(RestConstants.CARTRIDGES, cartridgeType, + CartridgeBean.class, RestConstants.CARTRIDGES_NAME); + assertEquals(bean.getCategory(), "Application"); + assertEquals(bean.getHost(), "qmog.cisco.com"); + for (PropertyBean property : bean.getProperty()) { + if (property.getName().equals("payload_parameter.CEP_IP")) { + assertEquals(property.getValue(), "octl.qmog.cisco.com"); + } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) { + assertEquals(property.getValue(), "admin"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) { + assertEquals(property.getValue(), "octl.qmog.cisco.com"); + } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) { + assertEquals(property.getValue(), "1"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) { + assertEquals(property.getValue(), "admin"); + } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) { + assertEquals(property.getValue(), "test"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) { + assertEquals(property.getValue(), "7711"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) { + assertEquals(property.getValue(), "7611"); + } else if (property.getName().equals("payload_parameter.CEP_PORT")) { + assertEquals(property.getValue(), "7611"); + } else if (property.getName().equals("payload_parameter.MB_PORT")) { + assertEquals(property.getValue(), "61616"); + } + } + + + boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + + cartridgeType + "-v1.json", + RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); + assertEquals(updated, true); + CartridgeBean updatedBean = (CartridgeBean) restClient. + getEntity(RestConstants.CARTRIDGES, cartridgeType, + CartridgeBean.class, RestConstants.CARTRIDGES_NAME); + assertEquals(updatedBean.getType(), "c0"); + assertEquals(updatedBean.getCategory(), "Data"); + assertEquals(updatedBean.getHost(), "qmog.cisco.com12"); + for (PropertyBean property : updatedBean.getProperty()) { + if (property.getName().equals("payload_parameter.CEP_IP")) { + assertEquals(property.getValue(), "octl.qmog.cisco.com123"); + } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) { + assertEquals(property.getValue(), "admin123"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) { + assertEquals(property.getValue(), "octl.qmog.cisco.com123"); + } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) { + assertEquals(property.getValue(), "3"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) { + assertEquals(property.getValue(), "admin123"); + } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) { + assertEquals(property.getValue(), "test123"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) { + assertEquals(property.getValue(), "7712"); + } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) { + assertEquals(property.getValue(), "7612"); + } else if (property.getName().equals("payload_parameter.CEP_PORT")) { + assertEquals(property.getValue(), "7612"); + } else if (property.getName().equals("payload_parameter.MB_PORT")) { + assertEquals(property.getValue(), "61617"); + } + } + + boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType, + RestConstants.CARTRIDGES_NAME); + assertEquals(removed, true); + + CartridgeBean beanRemoved = (CartridgeBean) restClient. + getEntity(RestConstants.CARTRIDGES, cartridgeType, + CartridgeBean.class, RestConstants.CARTRIDGES_NAME); + assertEquals(beanRemoved, null); + + log.info("Ended Cartridge test case**************************************"); + } catch (Exception e) { + log.error("An error occurred while handling RESTConstants.CARTRIDGES_PATH", e); + assertTrue("An error occurred while handling RESTConstants.CARTRIDGES_PATH", false); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java new file mode 100644 index 0000000..4ed2a2e --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java @@ -0,0 +1,133 @@ +/* + * 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.policies; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.beans.PropertyBean; +import org.apache.stratos.common.beans.partition.NetworkPartitionBean; +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.testng.annotations.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * Test to handle Network partition CRUD operations + */ +public class ApplicationPolicyTest extends StratosTestServerManager { + private static final Log log = LogFactory.getLog(ApplicationPolicyTest.class); + private static final String TEST_PATH = "/application-policy-test"; + + + @Test + public void testApplicationPolicy() { + try { + String applicationPolicyId = "application-policy-2"; + log.info("Started Application policy test case**************************************"); + + boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-7" + ".json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN1, true); + + boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + + "network-partition-8" + ".json", + RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(addedN2, true); + + boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + applicationPolicyId + ".json", + RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(addedDep, true); + + ApplicationPolicyBean bean = (ApplicationPolicyBean) restClient. + getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId, + ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(bean.getId(), applicationPolicyId); + assertEquals(String.format("The expected algorithm %s is not found in %s", + "one-after-another", applicationPolicyId), bean.getAlgorithm(), "one-after-another"); + assertEquals(String.format("The expected id %s is not found", + applicationPolicyId), bean.getId(), applicationPolicyId); + assertEquals(String.format("The expected networkpartitions size %s is not found in %s", + 2, applicationPolicyId), bean.getNetworkPartitions().length, 2); + assertEquals(String.format("The first network partition is not %s in %s", + "network-partition-7", applicationPolicyId), bean.getNetworkPartitions()[0], + "network-partition-7"); + assertEquals(String.format("The Second network partition is not %s in %s", + "network-partition-8", applicationPolicyId), bean.getNetworkPartitions()[1], + "network-partition-8"); + boolean algoFound = false; + for (PropertyBean propertyBean : bean.getProperties()) { + if (propertyBean.getName().equals("networkPartitionGroups")) { + assertEquals(String.format("The networkPartitionGroups algorithm %s is not found in %s", + "network-partition-7,network-partition-8", applicationPolicyId), + propertyBean.getValue(), "network-partition-7,network-partition-8"); + algoFound = true; + + } + } + if (!algoFound) { + assertTrue(String.format("The networkPartitionGroups property is not found in %s", + applicationPolicyId), false); + } + + boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-7", RestConstants.NETWORK_PARTITIONS_NAME); + //Trying to remove the used network partition + assertEquals(removedNet, false); + + boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, + applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(removedDep, true); + + ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient. + getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId, + ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME); + assertEquals(beanRemovedDep, null); + + boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-7", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN1, true); + + NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient. + getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-7", + NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(beanRemovedN1, null); + + boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, + "network-partition-8", RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(removedN2, true); + + NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient. + getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-8", + NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME); + assertEquals(beanRemovedN2, null); + + log.info("Ended deployment policy test case**************************************"); + + } catch (Exception e) { + log.error("An error occurred while handling deployment policy", e); + assertTrue("An error occurred while handling deployment policy", false); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java new file mode 100644 index 0000000..96b8a57 --- /dev/null +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java @@ -0,0 +1,91 @@ +/* + * 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.policies; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean; +import org.apache.stratos.integration.tests.RestConstants; +import org.apache.stratos.integration.tests.StratosTestServerManager; +import org.testng.annotations.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * Test to handle autoscaling policy CRUD operations + */ +public class AutoscalingPolicyTest extends StratosTestServerManager { + private static final Log log = LogFactory.getLog(AutoscalingPolicyTest.class); + private static final String TEST_PATH = "/autoscaling-policy-test"; + + + @Test + public void testAutoscalingPolicy() { + log.info("Started autoscaling policy test case**************************************"); + String policyId = "autoscaling-policy-c0"; + try { + boolean added = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + + assertEquals(String.format("Autoscaling policy did not added: [autoscaling-policy-id] %s", policyId), added, true); + AutoscalePolicyBean bean = (AutoscalePolicyBean) restClient. + getEntity(RestConstants.AUTOSCALING_POLICIES, policyId, + AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME); + + assertEquals(String.format("[autoscaling-policy-id] %s is not correct", bean.getId()), + bean.getId(), policyId); + assertEquals(String.format("[autoscaling-policy-id] %s RIF is not correct", policyId), + bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 35.0, 0.0); + assertEquals(String.format("[autoscaling-policy-id] %s Memory is not correct", policyId), + bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0); + assertEquals(String.format("[autoscaling-policy-id] %s Load is not correct", policyId), + bean.getLoadThresholds().getLoadAverage().getThreshold(), 25.0, 0.0); + + boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + "-v1.json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + + assertEquals(String.format("[autoscaling-policy-id] %s update failed", policyId), updated, true); + AutoscalePolicyBean updatedBean = (AutoscalePolicyBean) restClient.getEntity( + RestConstants.AUTOSCALING_POLICIES, policyId, + AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(String.format("[autoscaling-policy-id] %s RIF is not correct", policyId), + updatedBean.getLoadThresholds().getRequestsInFlight().getThreshold(), 30.0, 0.0); + assertEquals(String.format("[autoscaling-policy-id] %s Load is not correct", policyId), + updatedBean.getLoadThresholds().getMemoryConsumption().getThreshold(), 40.0, 0.0); + assertEquals(String.format("[autoscaling-policy-id] %s Memory is not correct", policyId), + updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0); + + boolean removed = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, + policyId, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(String.format("[autoscaling-policy-id] %s couldn't be removed", policyId), + removed, true); + + AutoscalePolicyBean beanRemoved = (AutoscalePolicyBean) restClient.getEntity( + RestConstants.AUTOSCALING_POLICIES, policyId, + AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME); + assertEquals(String.format("[autoscaling-policy-id] %s didn't get removed successfully", + policyId), beanRemoved, null); + log.info("Ended autoscaling policy test case**************************************"); + } catch (Exception e) { + log.error("An error occurred while handling [autoscaling policy] " + policyId, e); + assertTrue("An error occurred while handling [autoscaling policy] " + policyId, false); + } + } +}
