Skip to content

Commit

Permalink
Minor fix for the constraints related tests. (apache#545)
Browse files Browse the repository at this point in the history
Minor fix for the constraints related tests.
  • Loading branch information
jiajunwang authored and huizhilu committed Aug 16, 2020
1 parent 70194d8 commit cb1668f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* under the License.
*/

import java.util.function.Function;

import org.apache.commons.math3.analysis.function.Sigmoid;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public void testGetNormalizedScore() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void testGetAssignmentScore() {

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
Expand All @@ -61,7 +61,7 @@ public void testGetAssignmentScoreMaxScore() {

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testGetAssignmentScoreWhenReplicaNotTopState() {
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);
}
Expand All @@ -64,7 +64,7 @@ public void testGetAssignmentScoreWhenReplicaIsTopStateHeavyLoad() {
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);
}

Expand All @@ -76,7 +76,7 @@ public void testGetAssignmentScoreWhenReplicaIsTopStateLightLoad() {
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);
}
}

0 comments on commit cb1668f

Please sign in to comment.