Skip to content

Commit cfa72d1

Browse files
committed
Revert "Add test to verify force primary allocation on closed indices (#42458)"
Replicate closed indices requires 7.2.0 or later. This reverts commit 20ad899.
1 parent 20ad899 commit cfa72d1

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
import org.elasticsearch.action.DocWriteResponse;
2424
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder;
2525
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse;
26-
import org.elasticsearch.action.admin.indices.stats.ShardStats;
2726
import org.elasticsearch.action.bulk.BulkResponse;
2827
import org.elasticsearch.action.index.IndexResponse;
2928
import org.elasticsearch.action.support.ActiveShardCount;
30-
import org.elasticsearch.action.support.IndicesOptions;
3129
import org.elasticsearch.cluster.ClusterState;
3230
import org.elasticsearch.cluster.ClusterStateListener;
3331
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -67,7 +65,6 @@
6765
import java.util.concurrent.ExecutionException;
6866
import java.util.concurrent.TimeUnit;
6967
import java.util.stream.Collectors;
70-
import java.util.stream.Stream;
7168

7269
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
7370
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
@@ -231,9 +228,7 @@ public void testForceStaleReplicaToBePromotedToPrimary() throws Exception {
231228
Set<String> historyUUIDs = Arrays.stream(client().admin().indices().prepareStats("test").clear().get().getShards())
232229
.map(shard -> shard.getCommitStats().getUserData().get(Engine.HISTORY_UUID_KEY)).collect(Collectors.toSet());
233230
createStaleReplicaScenario(master);
234-
if (randomBoolean()) {
235-
assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(0));
236-
}
231+
237232
boolean useStaleReplica = randomBoolean(); // if true, use stale replica, otherwise a completely empty copy
238233
logger.info("--> explicitly promote old primary shard");
239234
final String idxName = "test";
@@ -283,18 +278,15 @@ public void testForceStaleReplicaToBePromotedToPrimary() throws Exception {
283278
assertBusy(() -> assertTrue(client().admin().cluster().prepareState().get()
284279
.getState().routingTable().index(idxName).allPrimaryShardsActive()));
285280
}
286-
ShardStats[] shardStats = client().admin().indices().prepareStats("test")
287-
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED).get().getShards();
288-
for (ShardStats shardStat : shardStats) {
289-
assertThat(shardStat.getCommitStats().getNumDocs(), equalTo(useStaleReplica ? 1 : 0));
290-
}
281+
assertHitCount(client().prepareSearch(idxName).setSize(0).setQuery(matchAllQuery()).get(), useStaleReplica ? 1L : 0L);
282+
291283
// allocation id of old primary was cleaned from the in-sync set
292284
final ClusterState state = client().admin().cluster().prepareState().get().getState();
293285

294286
assertEquals(Collections.singleton(state.routingTable().index(idxName).shard(0).primary.allocationId().getId()),
295287
state.metaData().index(idxName).inSyncAllocationIds(0));
296288

297-
Set<String> newHistoryUUIds = Stream.of(shardStats)
289+
Set<String> newHistoryUUIds = Arrays.stream(client().admin().indices().prepareStats("test").clear().get().getShards())
298290
.map(shard -> shard.getCommitStats().getUserData().get(Engine.HISTORY_UUID_KEY)).collect(Collectors.toSet());
299291
assertThat(newHistoryUUIds, everyItem(not(isIn(historyUUIDs))));
300292
assertThat(newHistoryUUIds, hasSize(1));

0 commit comments

Comments
 (0)