Repository: brooklyn-server Updated Branches: refs/heads/master d5f9ae48b -> 8c69a7d99
fix non-det failure in scaling down test ensuring that policy doesn't start before size reaches 6, and fix execution context bug found in autoscaler changing pool size Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2cc9dafb Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2cc9dafb Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2cc9dafb Branch: refs/heads/master Commit: 2cc9dafb5151dbf6ebbda2d209a78f77236e6962 Parents: c9f7b0d Author: Alex Heneveld <[email protected]> Authored: Sat Sep 16 03:23:00 2017 +0100 Committer: Alex Heneveld <[email protected]> Committed: Sat Sep 16 03:25:36 2017 +0100 ---------------------------------------------------------------------- .../policy/autoscaling/AutoScalerPolicy.java | 4 ++-- .../autoscaling/AutoScalerPolicyPoolSizeTest.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2cc9dafb/policy/src/main/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicy.java ---------------------------------------------------------------------- diff --git a/policy/src/main/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicy.java b/policy/src/main/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicy.java index baa3871..0b33760 100644 --- a/policy/src/main/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicy.java +++ b/policy/src/main/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicy.java @@ -768,8 +768,8 @@ public class AutoScalerPolicy extends AbstractPolicy { int desiredSize = Math.min(max, Math.max(min, currentSize)); if (currentSize != desiredSize) { - if (LOG.isInfoEnabled()) LOG.info("{} resizing pool {} immediateley from {} to {} (due to new pool size limits)", new Object[] {this, poolEntity, currentSize, desiredSize}); - getResizeOperator().resize(poolEntity, desiredSize); + if (LOG.isInfoEnabled()) LOG.info("{} resizing pool {} triggering resize computation due to new pool size limits, current {} exceeds bound of {}", new Object[] {this, poolEntity, currentSize, desiredSize}); + resizeNow("Size "+currentSize+" not in new bounds"); } } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2cc9dafb/policy/src/test/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicyPoolSizeTest.java ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicyPoolSizeTest.java b/policy/src/test/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicyPoolSizeTest.java index b03c194..16325d2 100644 --- a/policy/src/test/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicyPoolSizeTest.java +++ b/policy/src/test/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicyPoolSizeTest.java @@ -30,6 +30,8 @@ import org.apache.brooklyn.core.test.entity.TestCluster; import org.apache.brooklyn.core.test.entity.TestSizeRecordingCluster; import org.apache.brooklyn.entity.stock.BasicStartable; import org.apache.brooklyn.util.collections.MutableList; +import org.apache.brooklyn.util.time.Duration; +import org.apache.brooklyn.util.time.Time; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -64,7 +66,7 @@ public class AutoScalerPolicyPoolSizeTest extends BrooklynAppUnitTestSupport { .configure(AutoScalerPolicy.RESIZE_OPERATOR, new ResizeOperator() { @Override public Integer resize(Entity entity, Integer desiredSize) { - LOG.info("resizing to " + desiredSize); + LOG.info("test policy resizing to " + desiredSize); resizes.add(desiredSize); return ((Resizable) entity).resize(desiredSize); } @@ -101,10 +103,18 @@ public class AutoScalerPolicyPoolSizeTest extends BrooklynAppUnitTestSupport { @Test public void testResizeDown() throws Exception { EntityAsserts.assertAttributeEqualsEventually(cluster, TestCluster.GROUP_SIZE, CLUSTER_INIITIAL_SIZE); + // temporarily increase, otherwise the policy can sometimes kick in to resize down before size 6 is reached + policy.config().set(AutoScalerPolicy.MAX_POOL_SIZE, CLUSTER_MAX_SIZE + 2); cluster.resize(CLUSTER_MAX_SIZE + 2); + EntityAsserts.assertAttributeEqualsEventually(cluster, TestSizeRecordingCluster.SIZE_HISTORY_RECORD_COUNT, 2); + Assert.assertEquals((int)cluster.getSizeHistory().get(0), CLUSTER_INIITIAL_SIZE, "history: "+cluster.getSizeHistory()); + Assert.assertEquals((int)cluster.getSizeHistory().get(1), CLUSTER_MAX_SIZE + 2, "history: "+cluster.getSizeHistory()); + + policy.config().set(AutoScalerPolicy.MIN_POOL_SIZE, CLUSTER_MAX_SIZE); + policy.config().set(AutoScalerPolicy.MAX_POOL_SIZE, CLUSTER_MAX_SIZE); EntityAsserts.assertAttributeEqualsEventually(cluster, TestSizeRecordingCluster.SIZE_HISTORY_RECORD_COUNT, 3); - Assert.assertEquals((int)cluster.getSizeHistory().get(0), CLUSTER_INIITIAL_SIZE); - Assert.assertEquals((int)cluster.getSizeHistory().get(1), CLUSTER_MAX_SIZE + 2); - Assert.assertEquals((int)cluster.getSizeHistory().get(2), CLUSTER_MAX_SIZE); + Assert.assertEquals((int)cluster.getSizeHistory().get(0), CLUSTER_INIITIAL_SIZE, "history: "+cluster.getSizeHistory()); + Assert.assertEquals((int)cluster.getSizeHistory().get(1), CLUSTER_MAX_SIZE + 2, "history: "+cluster.getSizeHistory()); + Assert.assertEquals((int)cluster.getSizeHistory().get(2), CLUSTER_MAX_SIZE, "history: "+cluster.getSizeHistory()); } }
