Revert "Update the mock health statistics" This reverts commit 78300f46511abd218b77d8647b8800ed68afbd74.
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/407cd115 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/407cd115 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/407cd115 Branch: refs/heads/master Commit: 407cd115f9505d139b191d596981daac34e43622 Parents: 7b0b155 Author: gayangunarathne <[email protected]> Authored: Mon Nov 2 16:52:42 2015 +0530 Committer: gayangunarathne <[email protected]> Committed: Mon Nov 2 16:52:42 2015 +0530 ---------------------------------------------------------------------- .../iaas/statistics/MockHealthStatistics.java | 3 +- .../application/SingleClusterScalingTest.java | 114 ------------------- 2 files changed, 1 insertion(+), 116 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/407cd115/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/statistics/MockHealthStatistics.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/statistics/MockHealthStatistics.java b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/statistics/MockHealthStatistics.java index d8563c5..0acfd96 100644 --- a/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/statistics/MockHealthStatistics.java +++ b/components/org.apache.stratos.mock.iaas/src/main/java/org/apache/stratos/mock/iaas/statistics/MockHealthStatistics.java @@ -80,8 +80,7 @@ public class MockHealthStatistics { * @return */ public int getStatistics(String cartridgeType, MockScalingFactor scalingFactor) throws NoStatisticsFoundException { - String[] cartridgeDetails=cartridgeType.split("~"); - Map<String, Integer> factorValueMap = statisticsMap.get(cartridgeDetails[0]); + Map<String, Integer> factorValueMap = statisticsMap.get(cartridgeType); if (factorValueMap != null) { if (factorValueMap.containsKey(scalingFactor.toString())) { return factorValueMap.get(scalingFactor.toString()); http://git-wip-us.apache.org/repos/asf/stratos/blob/407cd115/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 index 46412db..5f40baf 100644 --- 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 @@ -48,8 +48,6 @@ public class SingleClusterScalingTest extends StratosTestServerManager { private static final Log log = LogFactory.getLog(SampleApplicationsTest.class); private static final String RESOURCES_PATH = "/single-cluster-scaling-test"; private static final int CLUSTER_SCALE_UP_TIMEOUT = 180000; - private static final int CLUSTER_SCALE_DOWN_TIMEOUT = 360000; - private int activeInstancesAfterScaleup = 0; @Test @@ -232,7 +230,6 @@ public class SingleClusterScalingTest extends StratosTestServerManager { } clusterScaleup = activeInstances >= clusterDataHolder.getMinInstances(); if(clusterScaleup) { - activeInstancesAfterScaleup = activeInstances; break; } } @@ -245,115 +242,4 @@ public class SingleClusterScalingTest extends StratosTestServerManager { assertEquals(String.format("Cluster did not get scaled up: [cluster-id] %s", clusterId), clusterScaleup, true); } - - /** - * Assert application activation - * - * @param applicationName - */ - private void assertClusterWithScaleDown(String applicationName,int tenantId) { - Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,tenantId); - assertNotNull(String.format("Application is not found: [application-id] %s", - applicationName), application); - boolean clusterScaleDown = false; - String clusterId = null; - long startTime = System.currentTimeMillis(); - while (!clusterScaleDown) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) { - String serviceName = clusterDataHolder.getServiceUuid(); - clusterId = clusterDataHolder.getClusterId(); - Service service = TopologyManager.getTopology().getService(serviceName); - assertNotNull(String.format("Service is not found: [application-id] %s [service] %s", - applicationName, serviceName), service); - - Cluster cluster = service.getCluster(clusterId); - assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s", - applicationName, serviceName, clusterId), cluster); - for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) { - int activeInstances = 0; - for (Member member : cluster.getMembers()) { - if (member.getClusterInstanceId().equals(instance.getInstanceId())) { - if (member.getStatus().equals(MemberStatus.Active)) { - activeInstances++; - } - } - } - - if(activeInstances > activeInstancesAfterScaleup) { - activeInstancesAfterScaleup = activeInstances; - } - - clusterScaleDown = activeInstancesAfterScaleup - 1 == activeInstances; - if(clusterScaleDown) { - break; - } - - } - - application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,tenantId); - if ((System.currentTimeMillis() - startTime) > CLUSTER_SCALE_DOWN_TIMEOUT) { - break; - } - } - } - assertEquals(String.format("Cluster did not get scaled up: [cluster-id] %s", clusterId), - clusterScaleDown, true); - } - - /** - * Assert application activation - * - * @param applicationName - */ - private void assertClusterScaleDownToMinimumCount(String applicationName) { - Application application = ApplicationManager.getApplications().getApplication(applicationName); - assertNotNull(String.format("Application is not found: [application-id] %s", - applicationName), application); - boolean clusterScaleDown = false; - String clusterId = null; - long startTime = System.currentTimeMillis(); - while (!clusterScaleDown) { - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) { - } - Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) { - String serviceName = clusterDataHolder.getServiceType(); - clusterId = clusterDataHolder.getClusterId(); - Service service = TopologyManager.getTopology().getService(serviceName); - assertNotNull(String.format("Service is not found: [application-id] %s [service] %s", - applicationName, serviceName), service); - - Cluster cluster = service.getCluster(clusterId); - assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s", - applicationName, serviceName, clusterId), cluster); - for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) { - int activeInstances = 0; - for (Member member : cluster.getMembers()) { - if (member.getClusterInstanceId().equals(instance.getInstanceId())) { - if (member.getStatus().equals(MemberStatus.Active)) { - activeInstances++; - } - } - } - clusterScaleDown = activeInstances == clusterDataHolder.getMinInstances(); - if(clusterScaleDown) { - break; - } - } - application = ApplicationManager.getApplications().getApplication(applicationName); - if ((System.currentTimeMillis() - startTime) > CLUSTER_SCALE_DOWN_TIMEOUT) { - break; - } - } - } - assertEquals(String.format("Cluster did not get scaled up: [cluster-id] %s", clusterId), - clusterScaleDown, true); - } }
