Skip to content

Commit

Permalink
test IncludeShardsStatsFlag via getShardStats(Index index) instead ge…
Browse files Browse the repository at this point in the history
…tStatsByShard()
  • Loading branch information
NEUpanning committed Oct 13, 2023
1 parent 9d20eda commit 3ddf821
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ public DenseVectorStats getDenseVectorStats() {
return stats.getDenseVectorStats();
}

// for testing
Map<Index, List<IndexShardStats>> getStatsByShard() {
return statsByShard;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
stats.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.object.HasToString.hasToString;

public class NodeIndicesStatsTests extends ESTestCase {
Expand All @@ -36,11 +37,14 @@ public void testInvalidLevel() {
}

public void testIncludeShardsStatsFlag() {
final Index index = new Index("test", "_na_");
final Map<Index, List<IndexShardStats>> statsByShards = new HashMap<>();
final List<IndexShardStats> emptyList = List.of();
statsByShards.put(index, emptyList);
NodeIndicesStats stats = new NodeIndicesStats(null, Collections.emptyMap(), statsByShards, true);
assertThat(stats.getStatsByShard(), sameInstance(statsByShards));
assertThat(stats.getShardStats(index), sameInstance(emptyList));
stats = new NodeIndicesStats(null, Collections.emptyMap(), statsByShards, false);
assertThat(stats.getStatsByShard(), sameInstance(Map.of()));
assertThat(stats.getShardStats(index), nullValue());
}

}

0 comments on commit 3ddf821

Please sign in to comment.