Skip to content

Commit

Permalink
Fix sequence of test setup/teardown (#2387)
Browse files Browse the repository at this point in the history
Signed-off-by: owenhalpert <[email protected]>
  • Loading branch information
owenhalpert authored Jan 14, 2025
1 parent 2f021dd commit 60824c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 60824c8

Please sign in to comment.