You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/08/07 08:27:53 UTC
[1/5] stratos git commit: Re-organizing the package structure
Repository: stratos
Updated Branches:
refs/heads/master 955c37a6c -> 3eb7d7c25
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
new file mode 100644
index 0000000..9d13ca4
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
+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 Deployment policy CRUD operations
+ */
+public class DeploymentPolicyTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(DeploymentPolicyTest.class);
+ private static final String TEST_PATH = "/deployment-policy-test";
+
+
+ @Test
+ public void testDeploymentPolicy() {
+ try {
+ String deploymentPolicyId = "deployment-policy-2";
+ log.info("Started deployment policy test case**************************************");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-5" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-6" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ deploymentPolicyId + ".json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ DeploymentPolicyBean bean = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(bean.getId(), "deployment-policy-2");
+ assertEquals(bean.getNetworkPartitions().size(), 2);
+ assertEquals(bean.getNetworkPartitions().get(0).getId(), "network-partition-5");
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitions().size(), 1);
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 20);
+
+ assertEquals(bean.getNetworkPartitions().get(1).getId(), "network-partition-6");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().size(), 2);
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
+ "network-partition-6-partition-1");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 10);
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+ "network-partition-6-partition-2");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 9);
+
+ //update network partition
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-5-v1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(updated, true);
+
+ //update deployment policy with new partition and max values
+ boolean updatedDep = restClient.updateEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH +
+ "/" + deploymentPolicyId + "-v1.json", RestConstants.DEPLOYMENT_POLICIES,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(updatedDep, true);
+
+ DeploymentPolicyBean updatedBean = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(updatedBean.getId(), "deployment-policy-2");
+ assertEquals(updatedBean.getNetworkPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getId(), "network-partition-5");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 25);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getId(), "partition-2");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getPartitionMax(), 20);
+
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getId(), "network-partition-6");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
+ "network-partition-6-partition-1");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 15);
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+ "network-partition-6-partition-2");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ DeploymentPolicyBean beanRemovedDep = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(beanRemovedDep, null);
+
+ boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN1, true);
+
+ NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-5",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN1, null);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-6", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-6",
+ 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/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
new file mode 100644
index 0000000..5df2313
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.partition.NetworkPartitionBean;
+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 NetworkPartitionTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(NetworkPartitionTest.class);
+ private static final String TEST_PATH = "/network-partition-test";
+
+
+ @Test
+ public void testNetworkPartition() {
+ try {
+ String networkPartitionId = "network-partition-3";
+ log.info("Started network partition test case**************************************");
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ networkPartitionId + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(added, true);
+ NetworkPartitionBean bean = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(bean.getId(), "network-partition-3");
+ assertEquals(bean.getPartitions().size(), 1);
+ assertEquals(bean.getPartitions().get(0).getId(), "partition-1");
+ assertEquals(bean.getPartitions().get(0).getProperty().get(0).getName(), "region");
+ assertEquals(bean.getPartitions().get(0).getProperty().get(0).getValue(), "default");
+
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ networkPartitionId + "-v1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(updated, true);
+ NetworkPartitionBean updatedBean = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(updatedBean.getId(), "network-partition-3");
+ assertEquals(updatedBean.getPartitions().size(), 2);
+ assertEquals(updatedBean.getPartitions().get(1).getId(), "partition-2");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getName(), "region");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getValue(), "default1");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getName(), "zone");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getValue(), "z1");
+
+ boolean removed = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removed, true);
+
+ NetworkPartitionBean beanRemoved = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ log.info("Ended network partition test case**************************************");
+ } catch (Exception e) {
+ log.error("An error occurred while handling network partitions", e);
+ assertTrue("An error occurred while handling network partitions", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/testng.xml b/products/stratos/modules/integration/src/test/resources/testng.xml
index 849a282..356b5ec 100644
--- a/products/stratos/modules/integration/src/test/resources/testng.xml
+++ b/products/stratos/modules/integration/src/test/resources/testng.xml
@@ -24,42 +24,42 @@
<test name="CartridgeTest">
<classes>
- <class name="org.apache.stratos.integration.tests.CartridgeTest" />
+ <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
</classes>
</test>
<test name="CartridgeGroupTest">
<classes>
- <class name="org.apache.stratos.integration.tests.CartridgeGroupTest" />
+ <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
</classes>
</test>
<test name="NetworkPartitionTest">
<classes>
- <class name="org.apache.stratos.integration.tests.NetworkPartitionTest" />
+ <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
</classes>
</test>
<test name="ApplicationPolicyTest">
<classes>
- <class name="org.apache.stratos.integration.tests.ApplicationPolicyTest" />
+ <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
</classes>
</test>
<test name="DeploymentPolicyTest">
<classes>
- <class name="org.apache.stratos.integration.tests.DeploymentPolicyTest" />
+ <class name="org.apache.stratos.integration.tests.policies.DeploymentPolicyTest" />
</classes>
</test>
<test name="AutoscalingPolicyTest">
<classes>
- <class name="org.apache.stratos.integration.tests.AutoscalingPolicyTest" />
+ <class name="org.apache.stratos.integration.tests.policies.AutoscalingPolicyTest" />
</classes>
</test>
<test name="SampleApplicationsTest">
<classes>
- <class name="org.apache.stratos.integration.tests.SampleApplicationsTest" />
+ <class name="org.apache.stratos.integration.tests.application.SampleApplicationsTest" />
</classes>
</test>
<test name="ApplicationBurstingTest">
<classes>
- <class name="org.apache.stratos.integration.tests.ApplicationBurstingTest" />
+ <class name="org.apache.stratos.integration.tests.application.ApplicationBurstingTest" />
</classes>
</test>
[5/5] stratos git commit: removing listener
Posted by re...@apache.org.
removing listener
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3eb7d7c2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3eb7d7c2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3eb7d7c2
Branch: refs/heads/master
Commit: 3eb7d7c25cef217c80dfce97de61646359f9711e
Parents: c7a5ffd
Author: reka <rt...@gmail.com>
Authored: Fri Aug 7 11:57:35 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Aug 7 11:57:35 2015 +0530
----------------------------------------------------------------------
.../org/apache/stratos/integration/tests/TopologyHandler.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/3eb7d7c2/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
index 846302b..ec63f84 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
@@ -390,8 +390,4 @@ public class TopologyHandler {
String path = getClass().getResource("/").getPath();
return StringUtils.removeEnd(path, File.separator);
}
-
- private void addEventListeners() {
- topologyEventReceiver.addEventListener(MemberInitializedEventListener );
- }
}
[3/5] stratos git commit: Re-organizing the package structure
Posted by re...@apache.org.
Re-organizing the package structure
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/66487b24
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/66487b24
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/66487b24
Branch: refs/heads/master
Commit: 66487b24f9eeb5ba71709bd55bbf6f0504c78b33
Parents: 955c37a
Author: reka <rt...@gmail.com>
Authored: Fri Aug 7 11:37:15 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Aug 7 11:37:15 2015 +0530
----------------------------------------------------------------------
.../tests/ApplicationBurstingTest.java | 223 ----------
.../tests/ApplicationPolicyTest.java | 131 ------
.../tests/AutoscalingPolicyTest.java | 89 ----
.../integration/tests/CartridgeGroupTest.java | 127 ------
.../integration/tests/CartridgeTest.java | 128 ------
.../integration/tests/DeploymentPolicyTest.java | 155 -------
.../integration/tests/NetworkPartitionTest.java | 90 ----
.../tests/SampleApplicationsTest.java | 424 ------------------
.../tests/StratosTestServerManager.java | 3 +-
.../integration/tests/TopologyHandler.java | 5 +-
.../application/ApplicationBurstingTest.java | 226 ++++++++++
.../application/SampleApplicationsTest.java | 427 +++++++++++++++++++
.../application/SingleClusterScalingTest.java | 233 ++++++++++
.../tests/group/CartridgeGroupTest.java | 129 ++++++
.../integration/tests/group/CartridgeTest.java | 130 ++++++
.../tests/policies/ApplicationPolicyTest.java | 133 ++++++
.../tests/policies/AutoscalingPolicyTest.java | 91 ++++
.../tests/policies/DeploymentPolicyTest.java | 157 +++++++
.../tests/policies/NetworkPartitionTest.java | 92 ++++
.../integration/src/test/resources/testng.xml | 16 +-
20 files changed, 1631 insertions(+), 1378 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationBurstingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationBurstingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationBurstingTest.java
deleted file mode 100644
index 518c7cb..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationBurstingTest.java
+++ /dev/null
@@ -1,223 +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;
-
-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.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 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);
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
deleted file mode 100644
index 635931e..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
+++ /dev/null
@@ -1,131 +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;
-
-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.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/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
deleted file mode 100644
index c4b52f6..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
+++ /dev/null
@@ -1,89 +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;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
-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);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
deleted file mode 100644
index 873fa5a..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
+++ /dev/null
@@ -1,127 +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;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
-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/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
deleted file mode 100644
index f3456a4..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
+++ /dev/null
@@ -1,128 +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;
-
-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.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/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
deleted file mode 100644
index b384e46..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
+++ /dev/null
@@ -1,155 +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;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
-import org.testng.annotations.Test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-
-/**
- * Test to handle Deployment policy CRUD operations
- */
-public class DeploymentPolicyTest extends StratosTestServerManager {
- private static final Log log = LogFactory.getLog(DeploymentPolicyTest.class);
- private static final String TEST_PATH = "/deployment-policy-test";
-
-
- @Test
- public void testDeploymentPolicy() {
- try {
- String deploymentPolicyId = "deployment-policy-2";
- log.info("Started deployment policy test case**************************************");
-
- boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-5" + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(addedN1, true);
-
- boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-6" + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(addedN2, true);
-
- boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
- deploymentPolicyId + ".json",
- RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(addedDep, true);
-
- DeploymentPolicyBean bean = (DeploymentPolicyBean) restClient.
- getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
- DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(bean.getId(), "deployment-policy-2");
- assertEquals(bean.getNetworkPartitions().size(), 2);
- assertEquals(bean.getNetworkPartitions().get(0).getId(), "network-partition-5");
- assertEquals(bean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
- assertEquals(bean.getNetworkPartitions().get(0).getPartitions().size(), 1);
- assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
- assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 20);
-
- assertEquals(bean.getNetworkPartitions().get(1).getId(), "network-partition-6");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().size(), 2);
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
- "network-partition-6-partition-1");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 10);
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
- "network-partition-6-partition-2");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 9);
-
- //update network partition
- boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-5-v1.json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(updated, true);
-
- //update deployment policy with new partition and max values
- boolean updatedDep = restClient.updateEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH +
- "/" + deploymentPolicyId + "-v1.json", RestConstants.DEPLOYMENT_POLICIES,
- RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(updatedDep, true);
-
- DeploymentPolicyBean updatedBean = (DeploymentPolicyBean) restClient.
- getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
- DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(updatedBean.getId(), "deployment-policy-2");
- assertEquals(updatedBean.getNetworkPartitions().size(), 2);
- assertEquals(updatedBean.getNetworkPartitions().get(0).getId(), "network-partition-5");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().size(), 2);
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 25);
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getId(), "partition-2");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getPartitionMax(), 20);
-
- assertEquals(updatedBean.getNetworkPartitions().get(1).getId(), "network-partition-6");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().size(), 2);
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
- "network-partition-6-partition-1");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 15);
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
- "network-partition-6-partition-2");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
-
- boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
- //Trying to remove the used network partition
- assertEquals(removedNet, false);
-
- boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(removedDep, true);
-
- DeploymentPolicyBean beanRemovedDep = (DeploymentPolicyBean) restClient.
- getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
- DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(beanRemovedDep, null);
-
- boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(removedN1, true);
-
- NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-5",
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(beanRemovedN1, null);
-
- boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-6", RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(removedN2, true);
-
- NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-6",
- 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/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
deleted file mode 100644
index 741d8be..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
+++ /dev/null
@@ -1,90 +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;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-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 NetworkPartitionTest extends StratosTestServerManager {
- private static final Log log = LogFactory.getLog(NetworkPartitionTest.class);
- private static final String TEST_PATH = "/network-partition-test";
-
-
- @Test
- public void testNetworkPartition() {
- try {
- String networkPartitionId = "network-partition-3";
- log.info("Started network partition test case**************************************");
-
- boolean added = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- networkPartitionId + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-
- assertEquals(added, true);
- NetworkPartitionBean bean = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
-
- assertEquals(bean.getId(), "network-partition-3");
- assertEquals(bean.getPartitions().size(), 1);
- assertEquals(bean.getPartitions().get(0).getId(), "partition-1");
- assertEquals(bean.getPartitions().get(0).getProperty().get(0).getName(), "region");
- assertEquals(bean.getPartitions().get(0).getProperty().get(0).getValue(), "default");
-
- boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- networkPartitionId + "-v1.json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
-
- assertEquals(updated, true);
- NetworkPartitionBean updatedBean = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(updatedBean.getId(), "network-partition-3");
- assertEquals(updatedBean.getPartitions().size(), 2);
- assertEquals(updatedBean.getPartitions().get(1).getId(), "partition-2");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getName(), "region");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getValue(), "default1");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getName(), "zone");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getValue(), "z1");
-
- boolean removed = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(removed, true);
-
- NetworkPartitionBean beanRemoved = (NetworkPartitionBean) restClient.
- getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
- NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(beanRemoved, null);
-
- log.info("Ended network partition test case**************************************");
- } catch (Exception e) {
- log.error("An error occurred while handling network partitions", e);
- assertTrue("An error occurred while handling network partitions", false);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
deleted file mode 100644
index b2960e2..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ /dev/null
@@ -1,424 +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;
-
-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.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/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
index 5453bbd..57fe040 100755
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
@@ -26,9 +26,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.stratos.common.test.TestLogAppender;
+import org.apache.stratos.integration.tests.application.SampleApplicationsTest;
import org.apache.stratos.integration.tests.rest.RestClient;
-import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.wso2.carbon.integration.framework.TestServerManager;
http://git-wip-us.apache.org/repos/asf/stratos/blob/66487b24/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
index 7162cdf..846302b 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.domain.topology.MemberStatus;
import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.listener.topology.MemberInitializedEventListener;
import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
@@ -390,5 +391,7 @@ public class TopologyHandler {
return StringUtils.removeEnd(path, File.separator);
}
-
+ private void addEventListeners() {
+ topologyEventReceiver.addEventListener(MemberInitializedEventListener );
+ }
}
[2/5] stratos git commit: Re-organizing the package structure
Posted by re...@apache.org.
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);
+ }
+ }
+}
[4/5] stratos git commit: renaming the testng.xml
Posted by re...@apache.org.
renaming the testng.xml
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c7a5ffd5
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c7a5ffd5
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c7a5ffd5
Branch: refs/heads/master
Commit: c7a5ffd5df10810aab5c3685b9386d2f14360999
Parents: 66487b2
Author: reka <rt...@gmail.com>
Authored: Fri Aug 7 11:39:43 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Fri Aug 7 11:39:43 2015 +0530
----------------------------------------------------------------------
products/stratos/modules/integration/pom.xml | 2 +-
.../src/test/resources/strats-testng.xml | 66 ++++++++++++++++++++
.../integration/src/test/resources/testng.xml | 66 --------------------
3 files changed, 67 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c7a5ffd5/products/stratos/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/pom.xml b/products/stratos/modules/integration/pom.xml
index ca92a8b..1e0d1f5 100755
--- a/products/stratos/modules/integration/pom.xml
+++ b/products/stratos/modules/integration/pom.xml
@@ -118,7 +118,7 @@
<emma.home>${basedir}/target/emma</emma.home>
</systemProperties>
<suiteXmlFiles>
- <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
+ <suiteXmlFile>src/test/resources/strats-testng.xml</suiteXmlFile>
</suiteXmlFiles>
<workingDirectory>${basedir}/target</workingDirectory>
</configuration>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c7a5ffd5/products/stratos/modules/integration/src/test/resources/strats-testng.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/strats-testng.xml b/products/stratos/modules/integration/src/test/resources/strats-testng.xml
new file mode 100644
index 0000000..356b5ec
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/strats-testng.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="StratosIntegrationSuite">
+
+ <test name="CartridgeTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
+ </classes>
+ </test>
+ <test name="CartridgeGroupTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
+ </classes>
+ </test>
+ <test name="NetworkPartitionTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
+ </classes>
+ </test>
+ <test name="ApplicationPolicyTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
+ </classes>
+ </test>
+ <test name="DeploymentPolicyTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.DeploymentPolicyTest" />
+ </classes>
+ </test>
+ <test name="AutoscalingPolicyTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.AutoscalingPolicyTest" />
+ </classes>
+ </test>
+ <test name="SampleApplicationsTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.application.SampleApplicationsTest" />
+ </classes>
+ </test>
+ <test name="ApplicationBurstingTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.application.ApplicationBurstingTest" />
+ </classes>
+ </test>
+
+</suite>
http://git-wip-us.apache.org/repos/asf/stratos/blob/c7a5ffd5/products/stratos/modules/integration/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/testng.xml b/products/stratos/modules/integration/src/test/resources/testng.xml
deleted file mode 100644
index 356b5ec..0000000
--- a/products/stratos/modules/integration/src/test/resources/testng.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-
-<suite name="StratosIntegrationSuite">
-
- <test name="CartridgeTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
- </classes>
- </test>
- <test name="CartridgeGroupTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
- </classes>
- </test>
- <test name="NetworkPartitionTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
- </classes>
- </test>
- <test name="ApplicationPolicyTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
- </classes>
- </test>
- <test name="DeploymentPolicyTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.policies.DeploymentPolicyTest" />
- </classes>
- </test>
- <test name="AutoscalingPolicyTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.policies.AutoscalingPolicyTest" />
- </classes>
- </test>
- <test name="SampleApplicationsTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.application.SampleApplicationsTest" />
- </classes>
- </test>
- <test name="ApplicationBurstingTest">
- <classes>
- <class name="org.apache.stratos.integration.tests.application.ApplicationBurstingTest" />
- </classes>
- </test>
-
-</suite>