Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
NEUpanning committed Oct 9, 2023
1 parent 100f568 commit 8543023
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ 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 @@ -8,12 +8,18 @@

package org.elasticsearch.indices;

import org.elasticsearch.action.admin.indices.stats.IndexShardStats;
import org.elasticsearch.index.Index;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xcontent.ToXContent;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

public class NodeIndicesStatsTests extends ESTestCase {
Expand All @@ -29,4 +35,12 @@ public void testInvalidLevel() {
);
}

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

}

0 comments on commit 8543023

Please sign in to comment.