Skip to content

Commit 4527995

Browse files
committed
Randomly include write loads when testing unassigned assignment
1 parent f96a6ea commit 4527995

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/WriteLoadConstraintDeciderTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void testWriteLoadDeciderCanAllocate() {
119119
"Unassigned shard should always be accepted",
120120
writeLoadDecider.canAllocate(
121121
testHarness.unassignedShardRouting,
122-
testHarness.exceedingThresholdRoutingNode,
122+
randomFrom(testHarness.exceedingThresholdRoutingNode, testHarness.belowThresholdRoutingNode),
123123
testHarness.routingAllocation
124124
),
125125
Decision.Type.YES,
@@ -239,6 +239,9 @@ private TestHarness createClusterStateAndRoutingAllocation(String indexName) {
239239
shardIdToWriteLoadEstimate.put(testShardId1, 0.5);
240240
shardIdToWriteLoadEstimate.put(testShardId2, 0.5);
241241
shardIdToWriteLoadEstimate.put(testShardId3NoWriteLoad, 0d);
242+
if (randomBoolean()) {
243+
shardIdToWriteLoadEstimate.put(testShardId4Unassigned, randomDoubleBetween(0.0, 2.0, true));
244+
}
242245

243246
ClusterInfo clusterInfo = ClusterInfo.builder()
244247
.nodeUsageStatsForThreadPools(nodeIdToNodeUsageStatsForThreadPools)
@@ -298,8 +301,7 @@ private TestHarness createClusterStateAndRoutingAllocation(String indexName) {
298301
);
299302
RoutingNode nearThresholdRoutingNode = RoutingNodesHelper.routingNode(
300303
nearThresholdDiscoveryNode3.getId(),
301-
nearThresholdDiscoveryNode3,
302-
new ShardRouting[] {}
304+
nearThresholdDiscoveryNode3
303305
);
304306

305307
return new TestHarness(

0 commit comments

Comments
 (0)