Skip to content

Commit

Permalink
[Segment Replication] Fix testAllConstraints test by using similar ca…
Browse files Browse the repository at this point in the history
…lculations as used in code (opensearch-project#6817)

Signed-off-by: Suraj Singh <[email protected]>
Signed-off-by: Valentin Mitrofanov <[email protected]>
  • Loading branch information
dreamer-89 authored and mitrofmep committed Apr 5, 2023
1 parent 408d6ed commit 3cae35e
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ public void testAllConstraints() {
when(node.numShards(indexName)).thenReturn(shardCount);
when(node.getNodeId()).thenReturn("test-node");

long expectedWeight = (shardCount >= avgPerIndexShardsPerNode) ? CONSTRAINT_WEIGHT : 0;
expectedWeight += perIndexPrimaryShardCount > avgPerIndexPrimaryShardsPerNode ? CONSTRAINT_WEIGHT : 0;
expectedWeight += primaryShardsPerNode >= avgPrimaryShardsPerNode ? CONSTRAINT_WEIGHT : 0;
long expectedWeight = (shardCount >= (int) Math.ceil(avgPerIndexShardsPerNode)) ? CONSTRAINT_WEIGHT : 0;
expectedWeight += perIndexPrimaryShardCount > (int) Math.ceil(avgPerIndexPrimaryShardsPerNode) ? CONSTRAINT_WEIGHT : 0;
expectedWeight += primaryShardsPerNode >= (int) Math.ceil(avgPrimaryShardsPerNode) ? CONSTRAINT_WEIGHT : 0;
assertEquals(expectedWeight, constraints.weight(balancer, node, indexName));
}

Expand Down

0 comments on commit 3cae35e

Please sign in to comment.