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 9, 2024
1 parent 139cbfc commit eaeba38
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.opensearch.common.CheckedSupplier;
import org.opensearch.common.SuppressForbidden;
import org.opensearch.common.cache.RemovalNotification;
import org.opensearch.common.cache.RemovalReason;
import org.opensearch.common.cache.module.CacheModule;
Expand Down Expand Up @@ -657,6 +658,7 @@ public void testCleanupKeyToCountMapAreSetAppropriately() throws Exception {

// when registering a closed listener raises an exception, we should
@Test(expected = Exception.class)
@SuppressForbidden(reason = "only way to avoid registering a reader after caching a key")
public void testAddReaderCloseListenerRaisingException_shouldTrackStaleCountAppropriately() throws Exception {
IndexReader.CacheHelper cacheHelper = mock(IndexReader.CacheHelper.class);
doThrow(new Exception("Mock exception")).when(cacheHelper).addClosedListener(any());
Expand All @@ -681,6 +683,7 @@ public void testAddReaderCloseListenerRaisingException_shouldTrackStaleCountAppr
}

@Test(expected = Exception.class)
@SuppressForbidden(reason = "only way to avoid registering a reader after caching a key")
public void testAddReaderCloseListenerRaisingException_shouldCleanupCacheCorrectly() throws Exception {
IndexReader.CacheHelper cacheHelper = mock(IndexReader.CacheHelper.class);
doThrow(new Exception("Mock exception")).when(cacheHelper).addClosedListener(any());
Expand Down

0 comments on commit eaeba38

Please sign in to comment.