84
84
import java .util .Arrays ;
85
85
import java .util .Collection ;
86
86
import java .util .List ;
87
+ import java .util .concurrent .TimeUnit ;
87
88
88
89
import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_REPLICAS ;
89
90
import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_SHARDS ;
@@ -586,6 +587,7 @@ public void testCacheWithFilteredAlias() throws InterruptedException {
586
587
.put (IndicesRequestCache .INDEX_CACHE_REQUEST_ENABLED_SETTING .getKey (), true )
587
588
.put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , 1 )
588
589
.put (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , 0 )
590
+ .put (IndexSettings .INDEX_REFRESH_INTERVAL_SETTING .getKey (), TimeValue .timeValueMillis (-1 ))
589
591
.build ();
590
592
String index = "index" ;
591
593
assertAcked (
@@ -599,13 +601,14 @@ public void testCacheWithFilteredAlias() throws InterruptedException {
599
601
);
600
602
ZonedDateTime now = ZonedDateTime .now (ZoneOffset .UTC );
601
603
client .prepareIndex (index ).setId ("1" ).setRouting ("1" ).setSource ("created_at" , DateTimeFormatter .ISO_LOCAL_DATE .format (now )).get ();
602
- // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
603
- ForceMergeResponse forceMergeResponse = client .admin ().indices ().prepareForceMerge (index ).setFlush (true ).get ();
604
- OpenSearchAssertions .assertAllSuccessful (forceMergeResponse );
605
604
refreshAndWaitForReplication ();
606
605
607
606
indexRandomForConcurrentSearch (index );
608
607
608
+ // Force merge the index to ensure there can be no background merges during the subsequent searches that would invalidate the cache
609
+ ForceMergeResponse forceMergeResponse = client .admin ().indices ().prepareForceMerge (index ).setFlush (true ).get ();
610
+ OpenSearchAssertions .assertAllSuccessful (forceMergeResponse );
611
+
609
612
assertCacheState (client , index , 0 , 0 );
610
613
611
614
SearchResponse r1 = client .prepareSearch (index )
@@ -823,7 +826,7 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
823
826
SearchResponse resp = client .prepareSearch (index )
824
827
.setRequestCache (true )
825
828
.setQuery (timeoutQueryBuilder )
826
- .setTimeout (TimeValue . ZERO )
829
+ .setTimeout (new TimeValue ( 5 , TimeUnit . MILLISECONDS ) )
827
830
.get ();
828
831
assertTrue (resp .isTimedOut ());
829
832
RequestCacheStats requestCacheStats = getRequestCacheStats (client , index );
0 commit comments