From f2b5044580053bf4d63f1545197488596e60b678 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Wed, 28 Dec 2022 20:05:22 -0800 Subject: [PATCH] Flush index to clear translog before stats validation (#5655) Signed-off-by: Daniel Widdis Signed-off-by: Daniel Widdis --- .../java/org/opensearch/search/PitMultiNodeTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/org/opensearch/search/PitMultiNodeTests.java b/server/src/test/java/org/opensearch/search/PitMultiNodeTests.java index b11a80b9d8726..6a29417eae8ae 100644 --- a/server/src/test/java/org/opensearch/search/PitMultiNodeTests.java +++ b/server/src/test/java/org/opensearch/search/PitMultiNodeTests.java @@ -28,6 +28,7 @@ import org.opensearch.action.search.GetAllPitsAction; import org.opensearch.action.search.PitTestsUtil; import org.opensearch.action.search.SearchResponse; +import org.opensearch.client.Requests; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; @@ -36,6 +37,7 @@ import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.threadpool.TestThreadPool; import org.opensearch.threadpool.ThreadPool; +import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; @@ -337,8 +339,12 @@ public void onFailure(Exception e) {} public void validatePitStats(String index, long expectedPitCurrent, long expectedOpenContexts) throws ExecutionException, InterruptedException { + // Clear the index transaction log + FlushRequest flushRequest = Requests.flushRequest(index); + client().admin().indices().flush(flushRequest).get(); + // Test stats IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); - indicesStatsRequest.indices("index"); + indicesStatsRequest.indices(index); indicesStatsRequest.all(); IndicesStatsResponse indicesStatsResponse = client().admin().indices().stats(indicesStatsRequest).get(); long pitCurrent = indicesStatsResponse.getIndex(index).getTotal().search.getTotal().getPitCurrent();