From d507915073036f72fe39cc43aac483578a354f5f Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 11 Oct 2019 21:09:54 -0400 Subject: [PATCH] Force flush in translog retention policy test (#47879) If we roll translog but do not index, then a flush without force is a noop. In this case, the number of retained translog files will be higher than the value specified by the retention policy. Closes #4741 --- .../test/java/org/elasticsearch/index/shard/IndexShardIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java index 37e94624b1043..77d88f4c30794 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java @@ -993,7 +993,7 @@ public void testNoOpEngineFactoryTakesPrecedence() { } } - public void testLimitNumberOfRetainingTranslogFiles() throws Exception { + public void testLimitNumberOfRetainedTranslogFiles() throws Exception { String indexName = "test"; int translogRetentionTotalFiles = randomIntBetween(0, 50); Settings.Builder settings = Settings.builder() @@ -1026,7 +1026,7 @@ public void testLimitNumberOfRetainingTranslogFiles() throws Exception { shard.rollTranslogGeneration(); } } - client().admin().indices().prepareFlush(indexName).get(); + client().admin().indices().prepareFlush(indexName).setForce(true).setWaitIfOngoing(true).get(); checkTranslog.run(); }