Skip to content

Commit

Permalink
Update IndicesRequestCacheTests.java
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Prakash <[email protected]>
  • Loading branch information
kiranprakash154 committed Apr 8, 2024
1 parent f42ebb8 commit 56f4e1f
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void cleanup() throws IOException {

public void testBasicOperationsCache() throws Exception {
threadPool = getThreadPool();
cache = getIndicesRequestCache(Settings.EMPTY, threadPool);
cache = getIndicesRequestCache(Settings.EMPTY);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());

Expand Down Expand Up @@ -164,7 +164,7 @@ public void testBasicOperationsCache() throws Exception {
public void testBasicOperationsCacheWithFeatureFlag() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.PLUGGABLE_CACHE, "true").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());

Expand Down Expand Up @@ -215,7 +215,7 @@ public void testBasicOperationsCacheWithFeatureFlag() throws Exception {

public void testCacheDifferentReaders() throws Exception {
threadPool = getThreadPool();
cache = getIndicesRequestCache(Settings.EMPTY, threadPool);
cache = getIndicesRequestCache(Settings.EMPTY);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());

Expand Down Expand Up @@ -333,7 +333,7 @@ public void testCacheCleanupThresholdSettingValidator_Invalid_Percentage() {
public void testCacheCleanupBasedOnZeroThreshold() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0%").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
DirectoryReader secondReader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -361,7 +361,7 @@ public void testCacheCleanupBasedOnZeroThreshold() throws Exception {
public void testCacheCleanupBasedOnStaleThreshold_StalenessHigherThanThreshold() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.49").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);

writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -396,7 +396,7 @@ public void testCacheCleanupBasedOnStaleThreshold_StalenessHigherThanThreshold()
public void testCacheCleanupBasedOnStaleThreshold_StalenessEqualToThreshold() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.5").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
DirectoryReader secondReader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -428,7 +428,7 @@ public void testCacheCleanupBasedOnStaleThreshold_StalenessEqualToThreshold() th
public void testStaleCount_OnRemovalNotificationOfStaleKey_DecrementsStaleCount() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
DirectoryReader secondReader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -462,7 +462,7 @@ public void testStaleCount_OnRemovalNotificationOfStaleKey_DecrementsStaleCount(
public void testStaleCount_OnRemovalNotificationOfStaleKey_DoesNotDecrementsStaleCount() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
DirectoryReader secondReader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -497,7 +497,7 @@ public void testStaleCount_OnRemovalNotificationOfStaleKey_DoesNotDecrementsStal
public void testStaleCount_WithoutReaderClosing_DecrementsStaleCount() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);

writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -525,7 +525,7 @@ public void testStaleCount_WithoutReaderClosing_DecrementsStaleCount() throws Ex
public void testStaleCount_OnRemovalNotifications() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);

writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -574,7 +574,7 @@ public void testStaleCount_OnRemovalNotifications() throws Exception {
public void testCacheCleanupBasedOnStaleThreshold_StalenessLesserThanThreshold() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "51%").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);

writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
Expand Down Expand Up @@ -607,7 +607,7 @@ public void testCacheCleanupBasedOnStaleThreshold_StalenessLesserThanThreshold()
public void testCleanupKeyToCountMapAreSetAppropriately() throws Exception {
threadPool = getThreadPool();
Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build();
cache = getIndicesRequestCache(settings, threadPool);
cache = getIndicesRequestCache(settings);

writer.addDocument(newDoc(0, "foo"));
ShardId shardId = indexShard.shardId();
Expand Down Expand Up @@ -656,7 +656,7 @@ private DirectoryReader getReader(IndexWriter writer, ShardId shardId) throws IO
return OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), shardId);
}

private IndicesRequestCache getIndicesRequestCache(Settings settings, ThreadPool threadPool) {
private IndicesRequestCache getIndicesRequestCache(Settings settings){
IndicesService indicesService = getInstanceFromNode(IndicesService.class);
return new IndicesRequestCache(settings, (shardId -> {
IndexService indexService = null;
Expand Down Expand Up @@ -692,7 +692,7 @@ public void testEviction() throws Exception {
final ByteSizeValue size;
{
threadPool = getThreadPool();
cache = getIndicesRequestCache(Settings.EMPTY, threadPool);
cache = getIndicesRequestCache(Settings.EMPTY);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
writer.updateDocument(new Term("id", "0"), newDoc(0, "bar"));
Expand Down Expand Up @@ -735,7 +735,7 @@ public void testEviction() throws Exception {

public void testClearAllEntityIdentity() throws Exception {
threadPool = getThreadPool();
cache = getIndicesRequestCache(Settings.EMPTY, threadPool);
cache = getIndicesRequestCache(Settings.EMPTY);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());
IndicesService.IndexShardCacheEntity entity = new IndicesService.IndexShardCacheEntity(indexShard);
Expand Down Expand Up @@ -814,7 +814,7 @@ public BytesReference get() {

public void testInvalidate() throws Exception {
threadPool = getThreadPool();
IndicesRequestCache cache = getIndicesRequestCache(Settings.EMPTY, threadPool);
IndicesRequestCache cache = getIndicesRequestCache(Settings.EMPTY);
writer.addDocument(newDoc(0, "foo"));
DirectoryReader reader = getReader(writer, indexShard.shardId());

Expand Down

0 comments on commit 56f4e1f

Please sign in to comment.