You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ji...@apache.org on 2019/10/26 05:16:33 UTC
[helix] branch wagedRebalancer updated: Minor fix for the
constraints related tests. (#545)
This is an automated email from the ASF dual-hosted git repository.
jiajunwang pushed a commit to branch wagedRebalancer
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/wagedRebalancer by this push:
new c227b38 Minor fix for the constraints related tests. (#545)
c227b38 is described below
commit c227b38e36ed4a61998b492fbc88855038b78648
Author: Jiajun Wang <18...@users.noreply.github.com>
AuthorDate: Fri Oct 25 22:16:25 2019 -0700
Minor fix for the constraints related tests. (#545)
Minor fix for the constraints related tests.
---
.../rebalancer/waged/constraints/UsageSoftConstraint.java | 2 --
.../waged/constraints/TestMaxCapacityUsageInstanceConstraint.java | 3 ++-
.../constraints/TestResourcePartitionAntiAffinityConstraint.java | 6 +++---
.../constraints/TestResourceTopStateAntiAffinityConstraint.java | 6 +++---
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/UsageSoftConstraint.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/UsageSoftConstraint.java
index 9fe0632..271ee74 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/UsageSoftConstraint.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/UsageSoftConstraint.java
@@ -19,8 +19,6 @@ package org.apache.helix.controller.rebalancer.waged.constraints;
* under the License.
*/
-import java.util.function.Function;
-
import org.apache.commons.math3.analysis.function.Sigmoid;
/**
diff --git a/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestMaxCapacityUsageInstanceConstraint.java b/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestMaxCapacityUsageInstanceConstraint.java
index 1bc0793..5d52cb7 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestMaxCapacityUsageInstanceConstraint.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestMaxCapacityUsageInstanceConstraint.java
@@ -48,7 +48,8 @@ public class TestMaxCapacityUsageInstanceConstraint {
when(_testNode.getProjectedHighestUtilization(anyMap())).thenReturn(0.8f);
when(_clusterContext.getEstimatedMaxUtilization()).thenReturn(1f);
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
- Assert.assertTrue(score > 0.99);
+ // Convert to float so as to compare with equal.
+ Assert.assertEquals((float) score,0.8f);
double normalizedScore =
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
Assert.assertTrue(normalizedScore > 0.99);
diff --git a/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourcePartitionAntiAffinityConstraint.java b/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourcePartitionAntiAffinityConstraint.java
index e3381d1..30bd630 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourcePartitionAntiAffinityConstraint.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourcePartitionAntiAffinityConstraint.java
@@ -49,8 +49,8 @@ public class TestResourcePartitionAntiAffinityConstraint {
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
double normalizedScore = _constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
- Assert.assertTrue(score > 0.99);
- Assert.assertTrue(score > 0.99);
+ Assert.assertEquals(score, 0.3);
+ Assert.assertTrue(normalizedScore > 0.99);
}
@Test
@@ -61,7 +61,7 @@ public class TestResourcePartitionAntiAffinityConstraint {
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
double normalizedScore = _constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
- Assert.assertEquals(score, 1.0);
+ Assert.assertEquals(score, 0.0);
Assert.assertEquals(normalizedScore, 1.0);
}
}
diff --git a/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourceTopStateAntiAffinityConstraint.java b/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourceTopStateAntiAffinityConstraint.java
index ca2421f..2a26030 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourceTopStateAntiAffinityConstraint.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourceTopStateAntiAffinityConstraint.java
@@ -51,7 +51,7 @@ public class TestResourceTopStateAntiAffinityConstraint {
double normalizedScore =
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
Assert.assertEquals(score, 0.0);
- Assert.assertEquals(normalizedScore, 0.0);
+ Assert.assertEquals(normalizedScore, 1.0);
verifyZeroInteractions(_testNode);
verifyZeroInteractions(_clusterContext);
}
@@ -64,7 +64,7 @@ public class TestResourceTopStateAntiAffinityConstraint {
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
double normalizedScore =
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
- Assert.assertEquals(score, 0.5);
+ Assert.assertEquals(score, 1.0);
Assert.assertEquals(normalizedScore, 0.5);
}
@@ -76,7 +76,7 @@ public class TestResourceTopStateAntiAffinityConstraint {
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
double normalizedScore =
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
- Assert.assertEquals(score, 1.0);
+ Assert.assertEquals(score, 0.0);
Assert.assertEquals(normalizedScore, 1.0);
}
}