From ee3786092ad35645b1b57eff0b344ac960df35fd Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 1 Oct 2018 20:13:16 +0200 Subject: [PATCH] [CCR] Only use primary shards and get expected count from leader index (#34186) Closes #34173 --- .../test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java index e19087e767b53..14ab1b90aa639 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java @@ -355,7 +355,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) assertSameDocCount("index1", "index2"); assertTotalNumberOfOptimizedIndexing(resolveIndex("index2"), numberOfShards, - client().prepareSearch("index2").get().getHits().totalHits); + client().prepareSearch("index1").get().getHits().totalHits); unfollowIndex("index2"); assertMaxSeqNoOfUpdatesIsTransferred(resolveIndex("index1"), resolveIndex("index2"), numberOfShards); } @@ -915,7 +915,7 @@ private void assertTotalNumberOfOptimizedIndexing(Index followerIndex, int numbe for (String node : internalCluster().nodesInclude(followerIndex.getName())) { IndicesService indicesService = internalCluster().getInstance(IndicesService.class, node); IndexShard shard = indicesService.getShardOrNull(new ShardId(followerIndex, shardId)); - if (shard != null) { + if (shard != null && shard.routingEntry().primary()) { try { FollowingEngine engine = ((FollowingEngine) IndexShardTestCase.getEngine(shard)); numOfOptimizedOps[shardId] = engine.getNumberOfOptimizedIndexing();