You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/11/29 20:25:49 UTC
[18/28] stratos git commit: Cleaning up test cases. Remove duplicate
assertions. Fix formatting.
http://git-wip-us.apache.org/repos/asf/stratos/blob/35eb6c22/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTestCase.java
index 7ef911f..d7b400a 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/GroupTerminationBehaviorTestCase.java
@@ -22,11 +22,9 @@ 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.common.RestConstants;
import org.apache.stratos.integration.common.TopologyHandler;
import org.apache.stratos.integration.tests.StratosIntegrationTest;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.Member;
import org.testng.annotations.Test;
@@ -36,14 +34,15 @@ import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
-import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
/**
* Handling the termination behavior of the group
*/
+@Test(groups = { "application", "failed" })
public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
private static final Log log = LogFactory.getLog(GroupTerminationBehaviorTestCase.class);
+ private TopologyHandler topologyHandler = TopologyHandler.getInstance();
private static final String RESOURCES_PATH = "/group-termination-behavior-test";
private static final String autoscalingPolicyId = "autoscaling-policy-group-termination-behavior-test";
private static final String cartridgeId1 = "c1-group-termination-behavior-test";
@@ -55,40 +54,38 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
private static final String deploymentPolicyId = "deployment-policy-group-termination-behavior-test";
private static final int GROUP_INACTIVE_TIMEOUT = 180000;
- @Test(timeOut = APPLICATION_TEST_TIMEOUT, groups = {"stratos.application.deployment", "failed"})
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT)
public void testTerminationBehavior() throws Exception {
+ log.info("Running GroupTerminationBehaviorTestCase.testTerminationBehavior test method...");
+ long startTime = System.currentTimeMillis();
- TopologyHandler topologyHandler = TopologyHandler.getInstance();
-
- boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
- + "/" + autoscalingPolicyId + ".json",
+ boolean addedScalingPolicy = restClient.addEntity(
+ RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json",
RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
assertTrue(addedScalingPolicy);
- boolean addedC1 = restClient.addEntity(
- RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId1 + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ boolean addedC1 = restClient
+ .addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId1 + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
assertTrue(addedC1);
- boolean addedC2 = restClient.addEntity(
- RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId2 + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ boolean addedC2 = restClient
+ .addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId2 + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
assertTrue(addedC2);
- boolean addedC3 = restClient.addEntity(
- RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId3 + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ boolean addedC3 = restClient
+ .addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId3 + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
assertTrue(addedC3);
- boolean addedC4 = restClient.addEntity(
- RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId4 + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ boolean addedC4 = restClient
+ .addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId4 + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
assertTrue(addedC4);
boolean addedG1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
- "/" + cartridgeGroupId + ".json",
- RestConstants.CARTRIDGE_GROUPS,
- RestConstants.CARTRIDGE_GROUPS_NAME);
+ "/" + cartridgeGroupId + ".json", RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME);
assertTrue(addedG1);
CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
@@ -97,61 +94,54 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
assertEquals(beanG1.getName(), "g-sc-G4-group-termination-behavior-test");
boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- networkPartitionId1 + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ networkPartitionId1 + ".json", RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
assertTrue(addedN1);
boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
- deploymentPolicyId + ".json",
- RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ deploymentPolicyId + ".json", RestConstants.DEPLOYMENT_POLICIES,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
assertTrue(addedDep);
final String applicationId = "group-termination-behavior-test";
boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
- applicationId + ".json", RestConstants.APPLICATIONS,
- RestConstants.APPLICATIONS_NAME);
+ applicationId + ".json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
assertTrue(added);
- ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
- applicationId, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ ApplicationBean bean = (ApplicationBean) restClient
+ .getEntity(RestConstants.APPLICATIONS, applicationId, ApplicationBean.class,
+ RestConstants.APPLICATIONS_NAME);
assertEquals(bean.getApplicationId(), "group-termination-behavior-test");
final String applicationPolicyId = "application-policy-group-termination-behavior-test";
boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
- applicationPolicyId + ".json",
- RestConstants.APPLICATION_POLICIES,
+ applicationPolicyId + ".json", RestConstants.APPLICATION_POLICIES,
RestConstants.APPLICATION_POLICIES_NAME);
assertTrue(addAppPolicy);
//deploy the application
String resourcePath = RestConstants.APPLICATIONS + "/" + applicationId +
RestConstants.APPLICATIONS_DEPLOY + "/" + applicationPolicyId;
- boolean deployed = restClient.deployEntity(resourcePath,
- RestConstants.APPLICATIONS_NAME);
+ boolean deployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
assertTrue(deployed);
- String groupId = topologyHandler.generateId(bean.getApplicationId(),
- "g-G1-1x0-group-termination-behavior-test", bean.getApplicationId() + "-1");
+ String groupId = topologyHandler.generateId(bean.getApplicationId(), "g-G1-1x0-group-termination-behavior-test",
+ bean.getApplicationId() + "-1");
String clusterIdC3 = topologyHandler.
- getClusterIdFromAlias(bean.getApplicationId(),
- "c3-1x0-group-termination-behavior-test");
+ getClusterIdFromAlias(bean.getApplicationId(), "c3-1x0-group-termination-behavior-test");
String clusterIdC4 = topologyHandler.
- getClusterIdFromAlias(bean.getApplicationId(),
- "c4-1x0-group-termination-behavior-test");
+ getClusterIdFromAlias(bean.getApplicationId(), "c4-1x0-group-termination-behavior-test");
String clusterIdC2 = topologyHandler.
- getClusterIdFromAlias(bean.getApplicationId(),
- "c2-1x0-group-termination-behavior-test");
+ getClusterIdFromAlias(bean.getApplicationId(), "c2-1x0-group-termination-behavior-test");
assertCreationOfNodes(groupId, clusterIdC2);
assertCreationOfNodes(clusterIdC3, clusterIdC4);
//Application active handling
- topologyHandler.assertApplicationStatus(bean.getApplicationId(),
- ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
//Group active handling
topologyHandler.assertGroupActivation(bean.getApplicationId());
@@ -159,8 +149,8 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
//Cluster active handling
topologyHandler.assertClusterActivation(bean.getApplicationId());
- Map<String, Member> memberMap = TopologyHandler.getInstance().getMembersForCluster
- ("c3-group-termination-behavior-test", bean.getApplicationId());
+ Map<String, Member> memberMap = TopologyHandler.getInstance()
+ .getMembersForCluster("c3-group-termination-behavior-test", bean.getApplicationId());
//Terminate members in the cluster
for (Map.Entry<String, Member> entry : memberMap.entrySet()) {
@@ -185,8 +175,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
assertCreationOfNodes(clusterIdC3, clusterIdC4);
//Application active handling
- topologyHandler.assertApplicationStatus(bean.getApplicationId(),
- ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
//Group active handling
topologyHandler.assertGroupActivation(bean.getApplicationId());
@@ -194,31 +183,11 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
//Cluster active handling
topologyHandler.assertClusterActivation(bean.getApplicationId());
- boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
- "g-sc-G4-group-termination-behavior-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
- assertFalse(removedGroup);
-
- boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
- autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
- assertFalse(removedAuto);
-
- boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- networkPartitionId1,
- RestConstants.NETWORK_PARTITIONS_NAME);
- //Trying to remove the used network partition
- assertFalse(removedNet);
-
- boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertFalse(removedDep);
-
//Un-deploying the application
String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + applicationId +
RestConstants.APPLICATIONS_UNDEPLOY;
- boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
- RestConstants.APPLICATIONS_NAME);
+ boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME);
assertTrue(unDeployed);
boolean undeploy = topologyHandler.assertApplicationUndeploy(applicationId);
@@ -230,55 +199,59 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
boolean forceUndeployed = topologyHandler.assertApplicationUndeploy(applicationId);
- assertTrue(String.format("Forceful undeployment failed for the application %s",
- applicationId), forceUndeployed);
+ assertTrue(String.format("Forceful undeployment failed for the application %s", applicationId),
+ forceUndeployed);
}
- boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, applicationId,
- RestConstants.APPLICATIONS_NAME);
+ boolean removed = restClient
+ .removeEntity(RestConstants.APPLICATIONS, applicationId, RestConstants.APPLICATIONS_NAME);
assertTrue(removed);
- ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
- applicationId, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ ApplicationBean beanRemoved = (ApplicationBean) restClient
+ .getEntity(RestConstants.APPLICATIONS, applicationId, ApplicationBean.class,
+ RestConstants.APPLICATIONS_NAME);
assertNull(beanRemoved);
- removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS,
- "g-sc-G4-group-termination-behavior-test",
- RestConstants.CARTRIDGE_GROUPS_NAME);
+ boolean removedGroup = restClient
+ .removeEntity(RestConstants.CARTRIDGE_GROUPS, "g-sc-G4-group-termination-behavior-test",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
assertTrue(removedGroup);
- boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeId1,
- RestConstants.CARTRIDGES_NAME);
+ boolean removedC1 = restClient
+ .removeEntity(RestConstants.CARTRIDGES, cartridgeId1, RestConstants.CARTRIDGES_NAME);
assertTrue(removedC1);
- boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeId2,
- RestConstants.CARTRIDGES_NAME);
+ boolean removedC2 = restClient
+ .removeEntity(RestConstants.CARTRIDGES, cartridgeId2, RestConstants.CARTRIDGES_NAME);
assertTrue(removedC2);
- boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeId3,
- RestConstants.CARTRIDGES_NAME);
+ boolean removedC3 = restClient
+ .removeEntity(RestConstants.CARTRIDGES, cartridgeId3, RestConstants.CARTRIDGES_NAME);
assertTrue(removedC3);
- boolean removedC4 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeId4,
- RestConstants.CARTRIDGES_NAME);
+ boolean removedC4 = restClient
+ .removeEntity(RestConstants.CARTRIDGES, cartridgeId4, RestConstants.CARTRIDGES_NAME);
assertTrue(removedC4);
- removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
- autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId,
+ RestConstants.AUTOSCALING_POLICIES_NAME);
assertTrue(removedAuto);
- removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
assertTrue(removedDep);
- removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- networkPartitionId1, RestConstants.NETWORK_PARTITIONS_NAME);
- assertFalse(removedNet);
-
- boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
- applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
+ boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
+ RestConstants.APPLICATION_POLICIES_NAME);
assertTrue(removeAppPolicy);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId1,
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ assertTrue(removedNet);
+
+ long duration = System.currentTimeMillis() - startTime;
+ log.info(String.format("GroupTerminationBehaviorTestCase completed in [duration] %s ms", duration));
}
private void assertGroupInactive(String groupId, String clusterId) {
@@ -288,8 +261,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!inActiveMap.containsKey(clusterId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
inActiveMap = TopologyHandler.getInstance().getInActiveMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -301,8 +273,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!inActiveMap.containsKey(groupId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
inActiveMap = TopologyHandler.getInstance().getInActiveMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -320,8 +291,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!terminatingMembers.containsKey(clusterId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -334,8 +304,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!terminatingMembers.containsKey(groupId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
terminatingMembers = TopologyHandler.getInstance().getTerminatingMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -354,8 +323,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!terminatedMembers.containsKey(clusterId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -368,8 +336,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!terminatedMembers.containsKey(groupId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignore) {
+ } catch (InterruptedException ignore) {
}
terminatedMembers = TopologyHandler.getInstance().getTerminatedMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -389,8 +356,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!activeMembers.containsKey(firstNodeId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignored) {
+ } catch (InterruptedException ignored) {
}
activeMembers = TopologyHandler.getInstance().getActivateddMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -402,8 +368,7 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
while (!createdMembers.containsKey(secondNodeId)) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException ignored) {
+ } catch (InterruptedException ignored) {
}
createdMembers = TopologyHandler.getInstance().getCreatedMembers();
if ((System.currentTimeMillis() - startTime) > GROUP_INACTIVE_TIMEOUT) {
@@ -412,5 +377,8 @@ public class GroupTerminationBehaviorTestCase extends StratosIntegrationTest {
}
assertTrue(createdMembers.containsKey(secondNodeId));
assertTrue(createdMembers.get(secondNodeId) > activeMembers.get(firstNodeId));
+
+ long duration = System.currentTimeMillis() - startTime;
+ log.info(String.format("GroupTerminationBehaviorTestCase completed in [duration] %s ms", duration));
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/35eb6c22/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/MetadataServiceTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/MetadataServiceTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/MetadataServiceTestCase.java
index f33ecad..5ba3634 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/MetadataServiceTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/MetadataServiceTestCase.java
@@ -28,14 +28,11 @@ import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
import org.apache.stratos.integration.common.RestConstants;
import org.apache.stratos.integration.common.TopologyHandler;
import org.apache.stratos.integration.tests.StratosIntegrationTest;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.metadata.client.beans.PropertyBean;
import org.apache.stratos.mock.iaas.domain.MockInstanceMetadata;
import org.testng.Assert;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
+import org.testng.annotations.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -52,7 +49,7 @@ import static org.testng.AssertJUnit.assertTrue;
* Deploy a sample application on mock IaaS and load test metadata service with high load of concurrent read/write
* operations from multiple clients
*/
-@Test(groups = { "stratos.application.deployment", "metadata" })
+@Test(groups = { "application", "metadata" })
public class MetadataServiceTestCase extends StratosIntegrationTest {
private static final Log log = LogFactory.getLog(MetadataServiceTestCase.class);
private static final String RESOURCES_PATH = "/metadata-service-test";
@@ -77,10 +74,10 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
public static final String APPLICATION_POLICY_ID = "application-policy-metadata-service-test";
public static final String DEPLOYMENT_POLICY_ID = "deployment-policy-metadata-service-test";
- @BeforeTest(timeOut = APPLICATION_TEST_TIMEOUT)
+ @BeforeClass(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT)
public void deployApplications() throws Exception {
+ log.info("Running MetadataServiceTestCase.deployApplications method...");
startTime = System.currentTimeMillis();
- log.info("Adding autoscaling policy [autoscale policy id] " + AUTOSCALE_POLICY_ID);
boolean addedScalingPolicy = restClient.addEntity(
RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + AUTOSCALE_POLICY_ID + ".json",
RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -154,13 +151,13 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
assertTrue(deployed);
log.info("Waiting for application-1 status to become ACTIVE...");
- topologyHandler.assertApplicationStatus(bean1.getApplicationId(), ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean1.getApplicationId());
log.info("Waiting for cluster status of application-1 to become ACTIVE...");
topologyHandler.assertClusterActivation(bean1.getApplicationId());
log.info("Waiting for application-2 status to become ACTIVE...");
- topologyHandler.assertApplicationStatus(bean2.getApplicationId(), ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean2.getApplicationId());
log.info("Waiting for cluster status of application-2 to become ACTIVE...");
topologyHandler.assertClusterActivation(bean2.getApplicationId());
@@ -200,10 +197,11 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
return payloadProperties;
}
- @Test(timeOut = APPLICATION_TEST_TIMEOUT,
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT,
description = "Application startup, activation and metadata service basic test",
priority = 1)
public void testBasicOperations() throws Exception {
+ log.info("Running MetadataServiceTestCase.testBasicOperations test method...");
String key = "mykey";
String val1 = "myval1";
String val2 = "myval2";
@@ -266,10 +264,11 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
log.info("Metadata service basic test completed successfully");
}
- @Test(timeOut = APPLICATION_TEST_TIMEOUT,
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT,
description = "Application startup, activation and metadata service concurrency test",
priority = 2)
public void metadataConcurrencyTest() throws Exception {
+ log.info("Running MetadataServiceTestCase.metadataConcurrencyTest test method...");
log.info("Starting multiple clients to add properties");
ExecutorService taskExecutor = Executors.newFixedThreadPool(5);
List<Callable<Void>> tasks = new ArrayList<>();
@@ -289,10 +288,11 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
log.info("Metadata service concurrency test completed successfully");
}
- @Test(timeOut = APPLICATION_TEST_TIMEOUT,
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT,
description = "Application startup, activation and metadata service security test",
priority = 3)
public void metadataSecurityTest() throws Exception {
+ log.info("Running MetadataServiceTestCase.metadataSecurityTest test method...");
String key = "mykey";
String val1 = "myval1";
@@ -321,10 +321,11 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
log.info("Metadata service security test completed successfully");
}
- @Test(timeOut = APPLICATION_TEST_TIMEOUT,
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT,
description = "Application startup, activation and metadata service concurrency test",
priority = 10)
public void cleanupAfterUndeployingAppTest() throws Exception {
+ log.info("Running MetadataServiceTestCase.cleanupAfterUndeployingAppTest test method...");
// undeploy the app and check whether metadata entries are cleared
log.info("Un-deploying the application [application id] " + APPLICATION_1_ID);
String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + APPLICATION_1_ID +
@@ -367,8 +368,9 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
};
}
- @AfterTest(timeOut = APPLICATION_TEST_TIMEOUT)
+ @AfterClass(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT)
public void cleanup() throws Exception {
+ log.info("Running MetadataServiceTestCase.cleanup method...");
// remove app-1
log.info("Removing the application [application id] " + APPLICATION_1_ID);
boolean removedApp = restClient
@@ -436,6 +438,6 @@ public class MetadataServiceTestCase extends StratosIntegrationTest {
RestConstants.NETWORK_PARTITIONS_NAME);
assertTrue(removedNet);
long duration = System.currentTimeMillis() - startTime;
- log.info("Metadata test completed in " + duration + " ms");
+ log.info(String.format("MetadataServiceTestCase completed in [duration] %s ms", duration));
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/35eb6c22/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTestCase.java
index 301cd53..6cbcef1 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionOneAfterAnotherClusterTestCase.java
@@ -26,7 +26,6 @@ import org.apache.stratos.integration.common.RestConstants;
import org.apache.stratos.integration.common.TopologyHandler;
import org.apache.stratos.integration.tests.StratosIntegrationTest;
import org.apache.stratos.messaging.domain.application.Application;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
import org.apache.stratos.messaging.domain.application.ClusterDataHolder;
import org.apache.stratos.messaging.domain.instance.ClusterInstance;
import org.apache.stratos.messaging.domain.topology.Cluster;
@@ -34,6 +33,7 @@ import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.domain.topology.Service;
import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.*;
@@ -45,63 +45,62 @@ import static org.testng.AssertJUnit.assertTrue;
/**
* This will handle the scale-up and scale-down of a particular cluster bursting test cases
*/
+@Test(groups = { "application", "failed" })
public class PartitionOneAfterAnotherClusterTestCase extends StratosIntegrationTest {
private static final Log log = LogFactory.getLog(PartitionOneAfterAnotherClusterTestCase.class);
private static final String RESOURCES_PATH = "/partition-round-robin-cluster-test";
+ private TopologyHandler topologyHandler = TopologyHandler.getInstance();
- @Test(timeOut = APPLICATION_TEST_TIMEOUT, groups = {"stratos.application.deployment", "failed"})
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT)
public void testDeployApplication() throws Exception {
- TopologyHandler topologyHandler = TopologyHandler.getInstance();
- String autoscalingPolicyId = "autoscaling-policy-3";
+ log.info("Running PartitionOneAfterAnotherClusterTestCase.testDeployApplication test method...");
+ long startTime = System.currentTimeMillis();
- boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
- + "/" + autoscalingPolicyId + ".json",
+ String autoscalingPolicyId = "autoscaling-policy-3";
+ boolean addedScalingPolicy = restClient.addEntity(
+ RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json",
RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
- assertEquals(addedScalingPolicy, true);
+ Assert.assertTrue(addedScalingPolicy, "Could not add autoscaling policy");
- boolean addedC1 = restClient.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c7.json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
- assertEquals(addedC1, true);
+ boolean addedC1 = restClient
+ .addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c7.json", RestConstants.CARTRIDGES,
+ RestConstants.CARTRIDGES_NAME);
+ Assert.assertTrue(addedC1, "Could not add cartridge");
boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- "network-partition-11.json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(addedN1, true);
+ "network-partition-11.json", RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ Assert.assertTrue(addedN1, "Could not add network partition");
boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
- "deployment-policy-5.json",
- RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(addedDep, true);
+ "deployment-policy-5.json", RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ Assert.assertTrue(addedDep, "Could not add deployment policy");
boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
- "single-cluster-scaling-test.json", RestConstants.APPLICATIONS,
- RestConstants.APPLICATIONS_NAME);
- assertEquals(added, true);
+ "single-cluster-scaling-test.json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
+ Assert.assertTrue(added, "Could not add application");
- ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
- "single-cluster-scaling-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ ApplicationBean bean = (ApplicationBean) restClient
+ .getEntity(RestConstants.APPLICATIONS, "single-cluster-scaling-test", ApplicationBean.class,
+ RestConstants.APPLICATIONS_NAME);
assertEquals(bean.getApplicationId(), "single-cluster-scaling-test");
boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
"application-policy-4.json", RestConstants.APPLICATION_POLICIES,
RestConstants.APPLICATION_POLICIES_NAME);
- assertEquals(addAppPolicy, true);
+ Assert.assertTrue(addAppPolicy, "Could not add application policy");
- ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
- RestConstants.APPLICATION_POLICIES,
- "application-policy-4", ApplicationPolicyBean.class,
- RestConstants.APPLICATION_POLICIES_NAME);
+ ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient
+ .getEntity(RestConstants.APPLICATION_POLICIES, "application-policy-4", ApplicationPolicyBean.class,
+ RestConstants.APPLICATION_POLICIES_NAME);
//deploy the application
String resourcePath = RestConstants.APPLICATIONS + "/" + "single-cluster-scaling-test" +
RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-4";
- boolean deployed = restClient.deployEntity(resourcePath,
- RestConstants.APPLICATIONS_NAME);
- assertEquals(deployed, true);
+ boolean deployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
+ Assert.assertTrue(deployed, "Could not deploy app");
//Application active handling
- topologyHandler.assertApplicationStatus(bean.getApplicationId(),
- ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
//Cluster active handling
topologyHandler.assertClusterActivation(bean.getApplicationId());
@@ -111,28 +110,25 @@ public class PartitionOneAfterAnotherClusterTestCase extends StratosIntegrationT
//Removing one member from cluster and check for auto healing
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId,
+ RestConstants.AUTOSCALING_POLICIES_NAME);
+ Assert.assertTrue(removedAuto, "Could not remove autoscaling policy");
- boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
- autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
- assertEquals(removedAuto, false);
-
- boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-11",
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-11",
RestConstants.NETWORK_PARTITIONS_NAME);
//Trying to remove the used network partition
- assertEquals(removedNet, false);
+ Assert.assertTrue(removedNet, "Could not remove network partition");
- boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- "deployment-policy-5", RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(removedDep, false);
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-5",
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
+ Assert.assertTrue(removedDep, "Could not remove deployment policy");
//Un-deploying the application
String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "single-cluster-scaling-test" +
RestConstants.APPLICATIONS_UNDEPLOY;
- boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
- RestConstants.APPLICATIONS_NAME);
- assertEquals(unDeployed, true);
+ boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME);
+ Assert.assertTrue(unDeployed, "Could not undeploy app");
boolean undeploy = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test");
if (!undeploy) {
@@ -143,44 +139,45 @@ public class PartitionOneAfterAnotherClusterTestCase extends StratosIntegrationT
RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("single-cluster-scaling-test");
- assertTrue(String.format("Forceful undeployment failed for the application %s",
- "single-cluster-scaling-test"), forceUndeployed);
+ assertTrue(
+ String.format("Forceful undeployment failed for the application %s", "single-cluster-scaling-test"),
+ forceUndeployed);
}
boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "single-cluster-scaling-test",
RestConstants.APPLICATIONS_NAME);
- assertEquals(removed, true);
+ Assert.assertTrue(removed, "Could not remomve application");
- ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
- "single-cluster-scaling-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ ApplicationBean beanRemoved = (ApplicationBean) restClient
+ .getEntity(RestConstants.APPLICATIONS, "single-cluster-scaling-test", ApplicationBean.class,
+ RestConstants.APPLICATIONS_NAME);
assertEquals(beanRemoved, null);
- boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c7",
- RestConstants.CARTRIDGES_NAME);
- assertEquals(removedC1, true);
-
-
- removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
- autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
- assertEquals(removedAuto, true);
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c7", RestConstants.CARTRIDGES_NAME);
+ Assert.assertTrue(removedC1, "Could not remove cartridge");
- removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- "deployment-policy-5", RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertEquals(removedDep, true);
+ removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId,
+ RestConstants.AUTOSCALING_POLICIES_NAME);
+ Assert.assertTrue(removedAuto, "Could not remove autoscaling policy");
- removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-11", RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(removedNet, false);
+ removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-5",
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
+ Assert.assertTrue(removedDep, "Could not remomve deployment policy");
+ removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-11",
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ Assert.assertTrue(removedNet, "Could not remove network partition");
- boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
- "application-policy-4", RestConstants.APPLICATION_POLICIES_NAME);
- assertEquals(removeAppPolicy, true);
+ boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, "application-policy-4",
+ RestConstants.APPLICATION_POLICIES_NAME);
+ Assert.assertTrue(removeAppPolicy, "Could not remove application policy");
- removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- "network-partition-11", RestConstants.NETWORK_PARTITIONS_NAME);
- assertEquals(removedNet, true);
+ removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-11",
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ Assert.assertTrue(removedNet, "Could not remove network partition");
+ long duration = System.currentTimeMillis() - startTime;
+ log.info(String.format("PartitionOneAfterAnotherClusterTestCase completed in [duration] %s ms", duration));
}
/**
@@ -190,16 +187,15 @@ public class PartitionOneAfterAnotherClusterTestCase extends StratosIntegrationT
*/
private void assertClusterWithRoundRobinAlgorithm(String applicationName) {
Application application = ApplicationManager.getApplications().getApplication(applicationName);
- assertNotNull(String.format("Application is not found: [application-id] %s",
- applicationName), application);
+ assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
String serviceName = clusterDataHolder.getServiceType();
String clusterId = clusterDataHolder.getClusterId();
Service service = TopologyManager.getTopology().getService(serviceName);
- assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
- applicationName, serviceName), service);
+ assertNotNull(String.format("Service is not found: [application-id] %s [service] %s", applicationName,
+ serviceName), service);
Cluster cluster = service.getCluster(clusterId);
assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
@@ -262,8 +258,8 @@ public class PartitionOneAfterAnotherClusterTestCase extends StratosIntegrationT
} else {
p1Index++;
previousPartition = p1;
- assertEquals(allInitTime.get(i), p1InitTime.get(p1Index), "Partition-1 doesn't not contain " +
- "correct values in current iteration");
+ assertEquals(allInitTime.get(i), p1InitTime.get(p1Index),
+ "Partition-1 doesn't not contain " + "correct values in current iteration");
if (p2Index >= 0) {
assertEquals(allInitTime.get(i - 1), p2InitTime.get(p2Index),
"Partition-2 doesn't not contain correct values in the previous iteration");
@@ -277,4 +273,4 @@ public class PartitionOneAfterAnotherClusterTestCase extends StratosIntegrationT
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/35eb6c22/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTestCase.java
index b8d119c..4fa50b9 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/PartitionRoundRobinClusterTestCase.java
@@ -25,7 +25,6 @@ import org.apache.stratos.integration.common.RestConstants;
import org.apache.stratos.integration.common.TopologyHandler;
import org.apache.stratos.integration.tests.StratosIntegrationTest;
import org.apache.stratos.messaging.domain.application.Application;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
import org.apache.stratos.messaging.domain.application.ClusterDataHolder;
import org.apache.stratos.messaging.domain.instance.ClusterInstance;
import org.apache.stratos.messaging.domain.topology.Cluster;
@@ -39,7 +38,6 @@ import org.testng.annotations.Test;
import java.util.*;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
@@ -47,6 +45,7 @@ import static org.testng.AssertJUnit.assertTrue;
/**
* This will handle the scale-up and scale-down of a particular cluster bursting test cases
*/
+@Test(groups = { "application", "round-robin" })
public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
private static final Log log = LogFactory.getLog(PartitionRoundRobinClusterTestCase.class);
private static final String RESOURCES_PATH = "/partition-round-robin-cluster-test";
@@ -56,40 +55,39 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
private static final String deploymentPolicyId = "deployment-policy-partition-round-robin-test";
private static final String applicationId = "partition-round-robin-test";
private static final String applicationPolicyId = "application-policy-partition-round-robin-test";
+ private TopologyHandler topologyHandler = TopologyHandler.getInstance();
- @Test(timeOut = APPLICATION_TEST_TIMEOUT, groups = {"stratos.application.deployment"})
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT)
public void testDeployApplication() throws Exception {
+ log.info("Running PartitionRoundRobinClusterTestCase.testDeployApplication test method...");
+ long startTime = System.currentTimeMillis();
-
- TopologyHandler topologyHandler = TopologyHandler.getInstance();
-
- boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
- + "/" + autoscalingPolicyId + ".json",
+ boolean addedScalingPolicy = restClient.addEntity(
+ RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json",
RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
Assert.assertTrue(addedScalingPolicy);
- boolean addedC1 = restClient.addEntity(
- RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId + ".json",
- RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ boolean addedC1 = restClient
+ .addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
Assert.assertTrue(addedC1);
boolean addedN1 = restClient.addEntity(RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
- networkPartitionId + ".json",
- RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ networkPartitionId + ".json", RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
Assert.assertTrue(addedN1);
boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
- deploymentPolicyId + ".json",
- RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ deploymentPolicyId + ".json", RestConstants.DEPLOYMENT_POLICIES,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
Assert.assertTrue(addedDep);
boolean added = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
- applicationId + ".json", RestConstants.APPLICATIONS,
- RestConstants.APPLICATIONS_NAME);
+ applicationId + ".json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
Assert.assertTrue(added);
- ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
- applicationId, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ ApplicationBean bean = (ApplicationBean) restClient
+ .getEntity(RestConstants.APPLICATIONS, applicationId, ApplicationBean.class,
+ RestConstants.APPLICATIONS_NAME);
assertEquals(bean.getApplicationId(), applicationId);
boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
@@ -100,14 +98,11 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
//deploy the application
String resourcePath = RestConstants.APPLICATIONS + "/" + applicationId +
RestConstants.APPLICATIONS_DEPLOY + "/" + applicationPolicyId;
- boolean deployed = restClient.deployEntity(resourcePath,
- RestConstants.APPLICATIONS_NAME);
+ boolean deployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
Assert.assertTrue(deployed);
-
//Application active handling
- topologyHandler.assertApplicationStatus(bean.getApplicationId(),
- ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
//Cluster active handling
topologyHandler.assertClusterActivation(bean.getApplicationId());
@@ -115,86 +110,57 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
//Verifying whether members got created using round robin algorithm
assertClusterWithRoundRobinAlgorithm(bean.getApplicationId());
- //Application in-active handling
- log.info("Waiting for the faulty member detection from " +
- "CEP as the statistics are stopped...");
- topologyHandler.assertApplicationStatus(bean.getApplicationId(),
- ApplicationStatus.Inactive);
-
- //Application active handling after application becomes active again
- topologyHandler.assertApplicationStatus(bean.getApplicationId(),
- ApplicationStatus.Active);
-
- //Cluster active handling
- topologyHandler.assertClusterActivation(bean.getApplicationId());
-
- boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
- autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
- assertFalse(removedAuto);
-
- boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- networkPartitionId,
- RestConstants.NETWORK_PARTITIONS_NAME);
- //Trying to remove the used network partition
- assertFalse(removedNet);
-
- boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
- assertFalse(removedDep);
-
//Un-deploying the application
String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + applicationId +
RestConstants.APPLICATIONS_UNDEPLOY;
- boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
- RestConstants.APPLICATIONS_NAME);
+ boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME);
Assert.assertTrue(unDeployed);
boolean undeploy = topologyHandler.assertApplicationUndeploy(applicationId);
if (!undeploy) {
//Need to forcefully undeploy the application
- log.info(String.format("Force undeployment is going to start for the [application] %s", applicationId));
+ log.info(String.format("Force undeployment is going to start for [application-id] %s", applicationId));
restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + applicationId +
RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
boolean forceUndeployed = topologyHandler.assertApplicationUndeploy(applicationId);
- assertTrue(String.format("Forceful undeployment failed for the application %s",
- applicationId), forceUndeployed);
+ assertTrue(String.format("Forceful undeployment failed for the application %s", applicationId),
+ forceUndeployed);
}
- boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, applicationId,
- RestConstants.APPLICATIONS_NAME);
+ boolean removed = restClient
+ .removeEntity(RestConstants.APPLICATIONS, applicationId, RestConstants.APPLICATIONS_NAME);
Assert.assertTrue(removed);
- ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
- applicationId, ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ ApplicationBean beanRemoved = (ApplicationBean) restClient
+ .getEntity(RestConstants.APPLICATIONS, applicationId, ApplicationBean.class,
+ RestConstants.APPLICATIONS_NAME);
assertNull(beanRemoved);
- boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeId,
- RestConstants.CARTRIDGES_NAME);
+ boolean removedC1 = restClient
+ .removeEntity(RestConstants.CARTRIDGES, cartridgeId, RestConstants.CARTRIDGES_NAME);
Assert.assertTrue(removedC1);
- removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
- autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId,
+ RestConstants.AUTOSCALING_POLICIES_NAME);
Assert.assertTrue(removedAuto);
- removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
- deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
Assert.assertTrue(removedDep);
- removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
- assertFalse(removedNet);
-
- boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
- applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
+ boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
+ RestConstants.APPLICATION_POLICIES_NAME);
Assert.assertTrue(removeAppPolicy);
- removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
- networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ RestConstants.NETWORK_PARTITIONS_NAME);
Assert.assertTrue(removedNet);
+ long duration = System.currentTimeMillis() - startTime;
+ log.info(String.format("PartitionRoundRobinClusterTestCase completed in [duration] %s ms", duration));
}
/**
@@ -204,16 +170,15 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
*/
private void assertClusterWithRoundRobinAlgorithm(String applicationName) {
Application application = ApplicationManager.getApplications().getApplication(applicationName);
- assertNotNull(String.format("Application is not found: [application-id] %s",
- applicationName), application);
+ assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
String serviceName = clusterDataHolder.getServiceType();
String clusterId = clusterDataHolder.getClusterId();
Service service = TopologyManager.getTopology().getService(serviceName);
- assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
- applicationName, serviceName), service);
+ assertNotNull(String.format("Service is not found: [application-id] %s [service] %s", applicationName,
+ serviceName), service);
Cluster cluster = service.getCluster(clusterId);
assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
@@ -243,7 +208,7 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
List<Long> p2InitTime = partitionIdToMembersMap.get(p2);
Collections.sort(p2InitTime);
- List<Long> allInitTime = new ArrayList<Long>();
+ List<Long> allInitTime = new ArrayList<>();
allInitTime.addAll(p1InitTime);
allInitTime.addAll(p2InitTime);
Collections.sort(allInitTime);
@@ -253,10 +218,10 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
String previousPartition = null;
for (int i = 0; i < allInitTime.size(); i++) {
if (previousPartition == null) {
- if (p1InitTime.get(0) == allInitTime.get(i)) {
+ if (Objects.equals(p1InitTime.get(0), allInitTime.get(i))) {
previousPartition = p1;
p1Index++;
- } else if (p2InitTime.get(0) == allInitTime.get(i)) {
+ } else if (Objects.equals(p2InitTime.get(0), allInitTime.get(i))) {
previousPartition = p2;
p2Index++;
@@ -292,4 +257,4 @@ public class PartitionRoundRobinClusterTestCase extends StratosIntegrationTest {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/35eb6c22/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationStartupTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationStartupTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationStartupTestCase.java
index e0c9a23..306a5e0 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationStartupTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationStartupTestCase.java
@@ -28,7 +28,6 @@ import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
import org.apache.stratos.integration.common.RestConstants;
import org.apache.stratos.integration.common.TopologyHandler;
import org.apache.stratos.integration.tests.StratosIntegrationTest;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.metadata.client.beans.PropertyBean;
import org.apache.stratos.mock.iaas.domain.MockInstanceMetadata;
@@ -45,9 +44,11 @@ import static org.testng.AssertJUnit.assertTrue;
* Deploy a sample application on mock IaaS and assert whether application instance, cluster instance, member instances
* are getting activated. Kill the mock instance and check whether
*/
+@Test(groups = { "application", "smoke" })
public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
private static final Log log = LogFactory.getLog(SampleApplicationStartupTestCase.class);
private static final String RESOURCES_PATH = "/sample-application-startup-test";
+ private TopologyHandler topologyHandler = TopologyHandler.getInstance();
private static final String PAYLOAD_PARAMETER_SEPARATOR = ",";
private static final String PAYLOAD_PARAMETER_NAME_VALUE_SEPARATOR = "=";
private static final String PAYLOAD_PARAMETER_TOKEN_KEY = "TOKEN";
@@ -55,13 +56,13 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
private GsonBuilder gsonBuilder = new GsonBuilder();
private Gson gson = gsonBuilder.create();
- @Test(timeOut = APPLICATION_TEST_TIMEOUT,
- description = "Application startup, activation and faulty member " + "detection",
- groups = { "stratos.application.startup", "smoke" })
+ @Test(timeOut = DEFAULT_APPLICATION_TEST_TIMEOUT,
+ description = "Application startup, activation and faulty member detection")
public void testApplication() throws Exception {
- String autoscalingPolicyId = "autoscaling-policy-sample-application-startup-test";
- TopologyHandler topologyHandler = TopologyHandler.getInstance();
+ log.info("Running SampleApplicationStartupTestCase.testApplication test method...");
+ long startTime = System.currentTimeMillis();
+ String autoscalingPolicyId = "autoscaling-policy-sample-application-startup-test";
log.info("Adding autoscaling policy [autoscale policy id] " + autoscalingPolicyId);
boolean addedScalingPolicy = restClient.addEntity(
RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyId + ".json",
@@ -89,7 +90,7 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
log.info("Adding application [application id] sample-application-startup-test");
boolean addedApp = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
"sample-application-startup-test.json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
- assertEquals(addedApp, true);
+ Assert.assertTrue(addedApp);
ApplicationBean bean = (ApplicationBean) restClient
.getEntity(RestConstants.APPLICATIONS, "sample-application-startup-test", ApplicationBean.class,
@@ -109,18 +110,18 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
assertEquals(policyBean.getId(), "application-policy-sample-application-startup-test");
// Used policies/cartridges should not removed...asserting validations when removing policies
- log.info("Trying to remove the used autoscaling policy...");
+ log.info("Trying to remove used autoscaling policy...");
boolean removedUsedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId,
RestConstants.AUTOSCALING_POLICIES_NAME);
assertFalse(removedUsedAuto);
- log.info("Trying to remove the used network partition...");
+ log.info("Trying to remove used network partition...");
boolean removedUsedNet = restClient
.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-sample-application-startup-test",
RestConstants.NETWORK_PARTITIONS_NAME);
assertFalse(removedUsedNet);
- log.info("Trying to remove the used deployment policy...");
+ log.info("Trying to remove used deployment policy...");
boolean removedUsedDep = restClient
.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-sample-application-startup-test",
RestConstants.DEPLOYMENT_POLICIES_NAME);
@@ -145,7 +146,8 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
assertFalse(removed);
log.info("Waiting for application status to become ACTIVE...");
- topologyHandler.assertApplicationStatus(bean.getApplicationId(), ApplicationStatus.Active);
+ //topologyHandler.assertApplicationStatus(bean.getApplicationId(), ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
log.info("Waiting for cluster status to become ACTIVE...");
topologyHandler.assertClusterActivation(bean.getApplicationId());
@@ -187,9 +189,7 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
Assert.assertTrue(propertyBean != null && propertyBean.getValues().size() > 0, "Empty property list");
List<String> addedValues = new ArrayList<>(Arrays.asList(val1, val2));
boolean hasPropertiesAdded = propertyBean.getValues().containsAll(addedValues);
-
Assert.assertTrue(hasPropertiesAdded, "Metadata properties retrieved are not correct");
- log.info("Metadata test completed successfully");
log.info("Terminating members in [cluster id] c1-sample-application-startup-test in mock IaaS directly to "
+ "simulate faulty members...");
@@ -202,11 +202,12 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
}
// application status should be marked as inactive since some members are faulty
log.info("Waiting for application status to become INACTIVE");
- topologyHandler.assertApplicationStatus(bean.getApplicationId(), ApplicationStatus.Inactive);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
// application should recover itself and become active after spinning more instances
log.info("Waiting for application status to become ACTIVE...");
- topologyHandler.assertApplicationStatus(bean.getApplicationId(), ApplicationStatus.Active);
+ //topologyHandler.assertApplicationStatus(bean.getApplicationId(), ApplicationStatus.Active);
+ TopologyHandler.getInstance().assertApplicationActiveStatus(bean.getApplicationId());
log.info("Waiting for cluster status to become ACTIVE...");
topologyHandler.assertClusterActivation(bean.getApplicationId());
@@ -231,7 +232,7 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
"sample-application-startup-test"), forceUndeployed);
}
- log.info("Removing the application [application id] sample-application-startup-test");
+ log.info("Removing application [application id] sample-application-startup-test");
boolean removedApp = restClient.removeEntity(RestConstants.APPLICATIONS, "sample-application-startup-test",
RestConstants.APPLICATIONS_NAME);
assertTrue(removedApp);
@@ -241,35 +242,36 @@ public class SampleApplicationStartupTestCase extends StratosIntegrationTest {
RestConstants.APPLICATIONS_NAME);
assertNull(beanRemoved);
- log.info("Removing the application policy [application policy id] "
+ log.info("Removing application policy [application policy id] "
+ "application-policy-sample-application-startup-test");
boolean removeAppPolicy = restClient
.removeEntity(RestConstants.APPLICATION_POLICIES, "application-policy-sample-application-startup-test",
RestConstants.APPLICATION_POLICIES_NAME);
assertTrue(removeAppPolicy);
- log.info("Removing the cartridge [cartridge type] c1-sample-application-startup-test");
+ log.info("Removing cartridge [cartridge type] c1-sample-application-startup-test");
boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1-sample-application-startup-test",
RestConstants.CARTRIDGES_NAME);
assertTrue(removedC1);
- log.info("Removing the autoscaling policy [autoscaling policy id] " + autoscalingPolicyId);
+ log.info("Removing autoscaling policy [autoscaling policy id] " + autoscalingPolicyId);
boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyId,
RestConstants.AUTOSCALING_POLICIES_NAME);
assertTrue(removedAuto);
- log.info("Removing the deployment policy [deployment policy id] "
+ log.info("Removing deployment policy [deployment policy id] "
+ "deployment-policy-sample-application-startup-test");
boolean removedDep = restClient
.removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-sample-application-startup-test",
RestConstants.DEPLOYMENT_POLICIES_NAME);
assertTrue(removedDep);
- log.info("Removing the network partition [network partition id] "
- + "network-partition-sample-application-startup-test");
+ log.info("Removing network partition [network partition id] network-partition-sample-application-startup-test");
boolean removedNet = restClient
.removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-sample-application-startup-test",
RestConstants.NETWORK_PARTITIONS_NAME);
assertTrue(removedNet);
+ long duration = System.currentTimeMillis() - startTime;
+ log.info(String.format("SampleApplicationStartupTestCase completed in [duration] %s ms", duration));
}
}