diff --git a/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java b/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java index d584b8643ce..e72a393c147 100644 --- a/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java +++ b/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java @@ -34,7 +34,6 @@ import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; import org.elasticsearch.test.InternalTestCluster.RestartCallback; -import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.store.MockDirectoryHelper; import org.elasticsearch.test.store.MockFSDirectoryService; import org.junit.Test; @@ -363,10 +362,13 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes client().admin().indices().prepareFlush().execute().actionGet(); } } - client().admin().indices().prepareFlush().execute().actionGet(); - + if (randomBoolean()) { + client().admin().indices().prepareFlush().execute().actionGet(); + } logger.info("Running Cluster Health"); ensureGreen(); + client().admin().indices().prepareOptimize("test").setWaitForMerge(true).setMaxNumSegments(100).get(); // just wait for merges + client().admin().indices().prepareFlush().setWaitIfOngoing(true).setForce(true).execute().actionGet(); logger.info("--> shutting down the nodes");