Skip to content

Commit c5ceb92

Browse files
committed
Test that shard write load is extracted
1 parent 45020c5 commit c5ceb92

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

server/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.elasticsearch.cluster.routing.ShardRoutingHelper;
1919
import org.elasticsearch.cluster.routing.UnassignedInfo;
2020
import org.elasticsearch.index.Index;
21+
import org.elasticsearch.index.shard.IndexingStats;
2122
import org.elasticsearch.index.shard.ShardId;
2223
import org.elasticsearch.index.shard.ShardPath;
2324
import org.elasticsearch.index.store.StoreStats;
@@ -107,6 +108,7 @@ public void testFillShardLevelInfo() {
107108
Path test0Path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve("0");
108109
CommonStats commonStats0 = new CommonStats();
109110
commonStats0.store = new StoreStats(100, 101, 0L);
111+
commonStats0.indexing = randomIndexingStats();
110112
ShardRouting test_1 = ShardRouting.newUnassigned(
111113
new ShardId(index, 1),
112114
false,
@@ -119,8 +121,10 @@ public void testFillShardLevelInfo() {
119121
Path test1Path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve("1");
120122
CommonStats commonStats1 = new CommonStats();
121123
commonStats1.store = new StoreStats(1000, 1001, 0L);
124+
commonStats1.indexing = randomIndexingStats();
122125
CommonStats commonStats2 = new CommonStats();
123126
commonStats2.store = new StoreStats(1000, 999, 0L);
127+
commonStats2.indexing = randomIndexingStats();
124128
ShardStats[] stats = new ShardStats[] {
125129
new ShardStats(test_0, new ShardPath(false, test0Path, test0Path, test_0.shardId()), commonStats0, null, null, null, false, 0),
126130
new ShardStats(test_1, new ShardPath(false, test1Path, test1Path, test_1.shardId()), commonStats1, null, null, null, false, 0),
@@ -166,6 +170,41 @@ public void testFillShardLevelInfo() {
166170
hasEntry(ClusterInfo.NodeAndShard.from(test_1), test1Path.getParent().getParent().getParent().toAbsolutePath().toString())
167171
)
168172
);
173+
174+
assertThat(
175+
shardWriteLoads,
176+
equalTo(
177+
Map.of(
178+
test_0.shardId(),
179+
commonStats0.indexing.getTotal().getPeakWriteLoad(),
180+
test_1.shardId(),
181+
Math.max(commonStats1.indexing.getTotal().getPeakWriteLoad(), commonStats2.indexing.getTotal().getPeakWriteLoad())
182+
)
183+
)
184+
);
185+
}
186+
187+
private IndexingStats randomIndexingStats() {
188+
return new IndexingStats(
189+
new IndexingStats.Stats(
190+
randomNonNegativeLong(),
191+
randomNonNegativeLong(),
192+
randomNonNegativeLong(),
193+
randomNonNegativeLong(),
194+
randomNonNegativeLong(),
195+
randomNonNegativeLong(),
196+
randomMillisUpToYear9999(),
197+
randomNonNegativeLong(),
198+
randomNonNegativeLong(),
199+
randomBoolean(),
200+
randomNonNegativeLong(),
201+
randomNonNegativeLong(),
202+
randomNonNegativeLong(),
203+
randomNonNegativeLong(),
204+
randomDoubleBetween(0d, 10d, true),
205+
randomDoubleBetween(0d, 10d, true)
206+
)
207+
);
169208
}
170209

171210
public void testLeastAndMostAvailableDiskSpace() {

0 commit comments

Comments
 (0)