Skip to content

Commit 37dccf4

Browse files
author
Jiajun Wang
committed
Minir fix for the constraints related tests.
1 parent b0e05b8 commit 37dccf4

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/UsageSoftConstraint.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* under the License.
2020
*/
2121

22-
import java.util.function.Function;
23-
2422
import org.apache.commons.math3.analysis.function.Sigmoid;
2523

2624
/**

helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestMaxCapacityUsageInstanceConstraint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public void testGetNormalizedScore() {
4848
when(_testNode.getProjectedHighestUtilization(anyMap())).thenReturn(0.8f);
4949
when(_clusterContext.getEstimatedMaxUtilization()).thenReturn(1f);
5050
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
51-
Assert.assertTrue(score > 0.99);
51+
// Convert to float so as to compare with equal.
52+
Assert.assertEquals((float) score,0.8f);
5253
double normalizedScore =
5354
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
5455
Assert.assertTrue(normalizedScore > 0.99);

helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourcePartitionAntiAffinityConstraint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public void testGetAssignmentScore() {
4949

5050
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
5151
double normalizedScore = _constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
52-
Assert.assertTrue(score > 0.99);
53-
Assert.assertTrue(score > 0.99);
52+
Assert.assertEquals(score, 0.3);
53+
Assert.assertTrue(normalizedScore > 0.99);
5454
}
5555

5656
@Test
@@ -61,7 +61,7 @@ public void testGetAssignmentScoreMaxScore() {
6161

6262
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
6363
double normalizedScore = _constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
64-
Assert.assertEquals(score, 1.0);
64+
Assert.assertEquals(score, 0.0);
6565
Assert.assertEquals(normalizedScore, 1.0);
6666
}
6767
}

helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/constraints/TestResourceTopStateAntiAffinityConstraint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testGetAssignmentScoreWhenReplicaNotTopState() {
5151
double normalizedScore =
5252
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
5353
Assert.assertEquals(score, 0.0);
54-
Assert.assertEquals(normalizedScore, 0.0);
54+
Assert.assertEquals(normalizedScore, 1.0);
5555
verifyZeroInteractions(_testNode);
5656
verifyZeroInteractions(_clusterContext);
5757
}
@@ -64,7 +64,7 @@ public void testGetAssignmentScoreWhenReplicaIsTopStateHeavyLoad() {
6464
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
6565
double normalizedScore =
6666
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
67-
Assert.assertEquals(score, 0.5);
67+
Assert.assertEquals(score, 1.0);
6868
Assert.assertEquals(normalizedScore, 0.5);
6969
}
7070

@@ -76,7 +76,7 @@ public void testGetAssignmentScoreWhenReplicaIsTopStateLightLoad() {
7676
double score = _constraint.getAssignmentScore(_testNode, _testReplica, _clusterContext);
7777
double normalizedScore =
7878
_constraint.getAssignmentNormalizedScore(_testNode, _testReplica, _clusterContext);
79-
Assert.assertEquals(score, 1.0);
79+
Assert.assertEquals(score, 0.0);
8080
Assert.assertEquals(normalizedScore, 1.0);
8181
}
8282
}

0 commit comments

Comments
 (0)