diff --git a/modules/cache-common/src/internalClusterTest/java/org/opensearch/cache/common/tier/TieredSpilloverCacheIT.java b/modules/cache-common/src/internalClusterTest/java/org/opensearch/cache/common/tier/TieredSpilloverCacheIT.java index 02be0990eb136..78ee5b8e48603 100644 --- a/modules/cache-common/src/internalClusterTest/java/org/opensearch/cache/common/tier/TieredSpilloverCacheIT.java +++ b/modules/cache-common/src/internalClusterTest/java/org/opensearch/cache/common/tier/TieredSpilloverCacheIT.java @@ -181,7 +181,7 @@ public void testWithDynamicTookTimePolicy() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); @@ -307,7 +307,7 @@ public void testInvalidationWithIndicesRequestCache() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); @@ -341,7 +341,7 @@ public void testInvalidationWithIndicesRequestCache() throws Exception { assertEquals(perQuerySizeInCacheInBytes * numberOfIndexedItems, requestCacheStats.getMemorySizeInBytes()); assertEquals(0, requestCacheStats.getEvictions()); // Explicit refresh would invalidate cache entries. - refreshAndWaitForReplication(); + refresh(); assertBusy(() -> { // Explicit refresh should clear up cache entries assertTrue(getRequestCacheStats(client, "index").getMemorySizeInBytes() == 0); @@ -391,7 +391,7 @@ public void testWithExplicitCacheClear() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); @@ -463,7 +463,7 @@ public void testWithDynamicDiskCacheSetting() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); @@ -530,7 +530,7 @@ public void testWithDynamicDiskCacheSetting() throws Exception { // Step 4: Invalidate entries via refresh. // Explicit refresh would invalidate cache entries. - refreshAndWaitForReplication(); + refresh(); assertBusy(() -> { // Explicit refresh should clear up cache entries assertTrue(getRequestCacheStats(client, "index").getMemorySizeInBytes() == 0); diff --git a/plugins/cache-ehcache/src/internalClusterTest/java/org/opensearch/cache/EhcacheDiskCacheIT.java b/plugins/cache-ehcache/src/internalClusterTest/java/org/opensearch/cache/EhcacheDiskCacheIT.java index 909a493c0734f..a645573ceec30 100644 --- a/plugins/cache-ehcache/src/internalClusterTest/java/org/opensearch/cache/EhcacheDiskCacheIT.java +++ b/plugins/cache-ehcache/src/internalClusterTest/java/org/opensearch/cache/EhcacheDiskCacheIT.java @@ -205,7 +205,7 @@ public void testInvalidationWithIndicesRequestCache() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); @@ -239,7 +239,7 @@ public void testInvalidationWithIndicesRequestCache() throws Exception { assertEquals(perQuerySizeInCacheInBytes * numberOfIndexedItems, requestCacheStats.getMemorySizeInBytes()); assertEquals(0, requestCacheStats.getEvictions()); // Explicit refresh would invalidate cache entries. - refreshAndWaitForReplication(); + refresh(); assertBusy(() -> { // Explicit refresh should clear up cache entries assertTrue(getRequestCacheStats(client, "index").getMemorySizeInBytes() == 0); @@ -278,7 +278,7 @@ public void testExplicitCacheClearWithIndicesRequestCache() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); @@ -340,7 +340,7 @@ public void testEvictionsFlowWithExpirationTime() throws Exception { indexRandom(true, client.prepareIndex("index").setSource("k" + iterator, "hello" + iterator)); } ensureSearchable("index"); - refreshAndWaitForReplication(); + refresh(); // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache ForceMergeResponse forceMergeResponse = client.admin().indices().prepareForceMerge("index").setFlush(true).get(); OpenSearchAssertions.assertAllSuccessful(forceMergeResponse); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java index fad1798f52ef5..5f4b1361a060c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java @@ -72,6 +72,7 @@ import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval; import org.opensearch.search.aggregations.bucket.histogram.Histogram; import org.opensearch.search.aggregations.bucket.histogram.Histogram.Bucket; +import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.ParameterizedOpenSearchIntegTestCase; import org.opensearch.test.hamcrest.OpenSearchAssertions; @@ -684,6 +685,7 @@ public void testProfileDisableCache() throws Exception { } } + // TODO: Move this to its own class with the decorator i guess. Not worth spending a ton of effort to get it cleaned up public void testDeleteAndCreateSameIndexShardOnSameNode() throws Exception { String node_1 = internalCluster().startNode(Settings.builder().build()); Client client = client(node_1);