diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java index 099ba54598d..39b3c7780c0 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java @@ -83,6 +83,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request); final Set shardIdsToFetch = new HashSet<>(); + logger.trace("cluster state used to determine shards [{}]", state.prettyPrint()); // collect relevant shard ids of the requested indices for fetching store infos for (String index : concreteIndices) { IndexRoutingTable indexShardRoutingTables = routingTables.index(index); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesShardStoreRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesShardStoreRequestTests.java index fee2f329d1a..15f2d045505 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesShardStoreRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/segments/IndicesShardStoreRequestTests.java @@ -37,10 +37,10 @@ import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ElasticsearchIntegrationTest; +import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.store.MockFSDirectoryService; import org.junit.Test; -import java.io.IOException; import java.util.*; import java.util.concurrent.ExecutionException; @@ -58,6 +58,7 @@ public class IndicesShardStoreRequestTests extends ElasticsearchIntegrationTest } @Test + @TestLogging("action.admin.indices.shards:TRACE") public void testBasic() throws Exception { String index = "test"; internalCluster().ensureAtLeastNumDataNodes(2); @@ -91,10 +92,12 @@ public class IndicesShardStoreRequestTests extends ElasticsearchIntegrationTest disableAllocation(index); logger.info("--> stop random node"); internalCluster().stopRandomNode(new IndexNodePredicate(index)); + ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + List unassignedShards = clusterState.routingTable().index(index).shardsWithState(ShardRoutingState.UNASSIGNED); response = client().admin().indices().shardStores(Requests.indicesShardStoresRequest(index)).get(); assertThat(response.getStoreStatuses().containsKey(index), equalTo(true)); ImmutableOpenIntMap> shardStoresStatuses = response.getStoreStatuses().get(index); - assertThat(shardStoresStatuses.size(), greaterThan(0)); + assertThat(shardStoresStatuses.size(), equalTo(unassignedShards.size())); for (IntObjectCursor> storesStatus : shardStoresStatuses) { assertThat("must report for one store", storesStatus.value.size(), equalTo(1)); assertThat("reported store should be primary", storesStatus.value.get(0).getAllocation(), equalTo(IndicesShardStoresResponse.StoreStatus.Allocation.PRIMARY));