From e423b7341aefb4176571e284858d25619ced4416 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Wed, 17 Jul 2019 10:30:30 +0200 Subject: [PATCH] Log non-acknowledged close index response in ReplicaToPrimaryPromotionIT Relates #44479 --- .../recovery/ReplicaToPrimaryPromotionIT.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java b/server/src/test/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java index 126c4df7928..f2ebf5a2108 100644 --- a/server/src/test/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java +++ b/server/src/test/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java @@ -18,6 +18,7 @@ */ package org.elasticsearch.indices.recovery; +import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -31,6 +32,7 @@ import java.util.Locale; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @ESIntegTestCase.ClusterScope(numDataNodes = 2) @@ -46,10 +48,12 @@ public class ReplicaToPrimaryPromotionIT extends ESIntegTestCase { createIndex(indexName); final int numOfDocs = scaledRandomIntBetween(0, 200); - try (BackgroundIndexer indexer = new BackgroundIndexer(indexName, "_doc", client(), numOfDocs)) { - waitForDocs(numOfDocs, indexer); + if (numOfDocs > 0) { + try (BackgroundIndexer indexer = new BackgroundIndexer(indexName, "_doc", client(), numOfDocs)) { + waitForDocs(numOfDocs, indexer); + } + refresh(indexName); } - refresh(indexName); assertHitCount(client().prepareSearch(indexName).setSize(0).get(), numOfDocs); ensureGreen(indexName); @@ -57,7 +61,8 @@ public class ReplicaToPrimaryPromotionIT extends ESIntegTestCase { // sometimes test with a closed index final IndexMetaData.State indexState = randomFrom(IndexMetaData.State.OPEN, IndexMetaData.State.CLOSE); if (indexState == IndexMetaData.State.CLOSE) { - assertAcked(client().admin().indices().prepareClose(indexName)); + CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose(indexName).get(); + assertThat("close index not acked - " + closeIndexResponse, closeIndexResponse.isAcknowledged(), equalTo(true)); ensureGreen(indexName); }