[TEST] Wait for merging to complete before testing breaker
It's possible that a merge may be ongoing when we check the breaker and segment
stats' memory usage, this causes the test to fail. Instead, we should wait for
merging to complete.
Resolves
@@ -2708,6 +2708,10 @@ public class IndexShardTests extends IndexShardTestCase {
t.join();
}
+ // We need to wait for all ongoing merges to complete. The reason is that during a merge the
+ // IndexWriter holds the core cache key open and causes the memory to be registered in the breaker
+ primary.forceMerge(new ForceMergeRequest());
+
// Close remaining searchers
IOUtils.close(searchers);
