Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/800#discussion_r134724140
--- Diff:
policy/src/test/java/org/apache/brooklyn/policy/autoscaling/AutoScalerPolicyPoolSizeTest.java
---
@@ -0,0 +1,110 @@
+/*
+ * 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.brooklyn.policy.autoscaling;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.policy.PolicySpec;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.trait.Resizable;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+public class AutoScalerPolicyPoolSizeTest extends
BrooklynAppUnitTestSupport {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(AutoScalerPolicyPoolSizeTest.class);
+
+ private static final int CLUSTER_INIITIAL_SIZE = 3;
+ private static final int CLUSTER_MIN_SIZE = 2;
+ private static final int CLUSTER_MAX_SIZE = 4;
+
+ AutoScalerPolicy policy;
+ TestSizeRecordingCluster cluster;
+ List<Integer> resizes = MutableList.of();
+
+ @BeforeMethod(alwaysRun = true)
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ LOG.info("resetting " + getClass().getSimpleName());
+ cluster =
app.createAndManageChild(EntitySpec.create(TestSizeRecordingCluster.class)
+ .configure(TestCluster.INITIAL_SIZE, CLUSTER_INIITIAL_SIZE)
+ .configure(TestCluster.MEMBER_SPEC,
EntitySpec.create(BasicStartable.class))
+ );
+ PolicySpec<AutoScalerPolicy> policySpec =
PolicySpec.create(AutoScalerPolicy.class)
+ .configure(AutoScalerPolicy.RESIZE_OPERATOR, new
ResizeOperator() {
--- End diff --
Why supply a `RESIZE_OPERATOR` (I'm guessing it's because that's what
`AutoScalerPolicyTest` does)?
Better to just rely on the default `RESIZE_OPERATOR`, which does exactly
this - then we are testing a more realistic way of using the `AutoScalerPolicy`
. You never use the `resizes` field anyway, and we can live without the
logging.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---