diff --git a/src/test/java/org/opensearch/knn/index/memory/NativeMemoryCacheManagerTests.java b/src/test/java/org/opensearch/knn/index/memory/NativeMemoryCacheManagerTests.java index 8a46a781e..5cdedf11b 100644 --- a/src/test/java/org/opensearch/knn/index/memory/NativeMemoryCacheManagerTests.java +++ b/src/test/java/org/opensearch/knn/index/memory/NativeMemoryCacheManagerTests.java @@ -12,7 +12,6 @@ package org.opensearch.knn.index.memory; import com.google.common.cache.CacheStats; -import org.junit.After; import org.junit.Before; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.opensearch.common.settings.Settings; @@ -41,18 +40,11 @@ public class NativeMemoryCacheManagerTests extends OpenSearchSingleNodeTestCase private ThreadPool threadPool; @Before - public void setUp() throws Exception { - super.setUp(); + public void setThreadPool() { threadPool = new ThreadPool(Settings.builder().put("node.name", "NativeMemoryCacheManagerTests").build()); NativeMemoryCacheManager.setThreadPool(threadPool); } - @After - public void shutdown() throws Exception { - super.tearDown(); - terminate(threadPool); - } - @Override public void tearDown() throws Exception { // Clear out persistent metadata @@ -61,6 +53,7 @@ public void tearDown() throws Exception { clusterUpdateSettingsRequest.persistentSettings(circuitBreakerSettings); client().admin().cluster().updateSettings(clusterUpdateSettingsRequest).get(); NativeMemoryCacheManager.getInstance().close(); + terminate(threadPool); super.tearDown(); } diff --git a/src/test/java/org/opensearch/knn/quantization/models/quantizationState/QuantizationStateCacheTests.java b/src/test/java/org/opensearch/knn/quantization/models/quantizationState/QuantizationStateCacheTests.java index 1a3c56e9a..3886e0c9a 100644 --- a/src/test/java/org/opensearch/knn/quantization/models/quantizationState/QuantizationStateCacheTests.java +++ b/src/test/java/org/opensearch/knn/quantization/models/quantizationState/QuantizationStateCacheTests.java @@ -36,15 +36,13 @@ public class QuantizationStateCacheTests extends KNNTestCase { private ThreadPool threadPool; @Before - public void setUp() throws Exception { - super.setUp(); + public void setThreadPool() { threadPool = new ThreadPool(Settings.builder().put("node.name", "QuantizationStateCacheTests").build()); QuantizationStateCache.setThreadPool(threadPool); } @After - public void shutdown() throws Exception { - super.tearDown(); + public void terminateThreadPool() { terminate(threadPool); }