Skip to content

Commit beb2611

Browse files
committed
More randomness
1 parent e589db4 commit beb2611

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

server/src/test/java/org/elasticsearch/cluster/routing/WriteLoadPerShardSimulatorTests.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,8 @@ public class WriteLoadPerShardSimulatorTests extends ESTestCase {
3838
* We should not adjust the values if there's no movement
3939
*/
4040
public void testNoShardMovement() {
41-
final var originalNode0WriteLoadStats = new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
42-
randomIntBetween(4, 32),
43-
randomFloatBetween(0f, 1f, true),
44-
randomLongBetween(0L, 7_000L)
45-
);
46-
final var originalNode1WriteLoadStats = new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
47-
randomIntBetween(4, 32),
48-
randomFloatBetween(0f, 1f, true),
49-
randomLongBetween(0L, 7_000L)
50-
);
41+
final var originalNode0WriteLoadStats = randomUsageStats();
42+
final var originalNode1WriteLoadStats = randomUsageStats();
5143
final var allocation = createRoutingAllocation(originalNode0WriteLoadStats, originalNode1WriteLoadStats);
5244

5345
final var writeLoadPerShardSimulator = new WriteLoadPerShardSimulator(allocation);
@@ -64,18 +56,9 @@ public void testNoShardMovement() {
6456
}
6557

6658
public void testMovementOfAShardWillReduceThreadPoolUtilisation() {
67-
final var originalNode0WriteLoadStats = new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
68-
randomIntBetween(4, 16),
69-
randomFloatBetween(0.2f, 1.0f, true),
70-
0
71-
);
72-
final var originalNode1WriteLoadStats = new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
73-
randomIntBetween(4, 16),
74-
randomFloatBetween(0.1f, 0.5f, true),
75-
0
76-
);
59+
final var originalNode0WriteLoadStats = randomUsageStats();
60+
final var originalNode1WriteLoadStats = randomUsageStats();
7761
final var allocation = createRoutingAllocation(originalNode0WriteLoadStats, originalNode1WriteLoadStats);
78-
7962
final var writeLoadPerShardSimulator = new WriteLoadPerShardSimulator(allocation);
8063

8164
// Relocate a random shard from node_0 to node_1
@@ -161,7 +144,11 @@ private float getAverageWritePoolUtilization(WriteLoadPerShardSimulator writeLoa
161144
}
162145

163146
private NodeUsageStatsForThreadPools.ThreadPoolUsageStats randomUsageStats() {
164-
return new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(randomIntBetween(4, 16), randomFloatBetween(0.0f, 1.0f, false), 0);
147+
return new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
148+
randomIntBetween(4, 16),
149+
randomFloatBetween(0.1f, 1.0f, true),
150+
randomLongBetween(0, 60_000)
151+
);
165152
}
166153

167154
private RoutingAllocation createRoutingAllocation(

0 commit comments

Comments
 (0)