Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: John Mazanec <[email protected]>
  • Loading branch information
jmazanec15 committed Jan 19, 2023
1 parent 896816c commit 3a0277d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
package org.opensearch.knn.index.memory;

import lombok.Builder;
import lombok.Getter;
import lombok.Value;

@Getter
@Value
@Builder
public class NativeMemoryCacheManagerDto {
private final boolean isWeightLimited;
private final long maxWeight;
private final boolean isExpirationLimited;
private final long expiryTimeInMin;
boolean isWeightLimited;
long maxWeight;
boolean isExpirationLimited;
long expiryTimeInMin;
}
18 changes: 15 additions & 3 deletions src/test/java/org/opensearch/knn/KNNTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package org.opensearch.knn;

import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Setting;
Expand All @@ -22,26 +24,36 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
* Base class for integration tests for KNN plugin. Contains several methods for testing KNN ES functionality.
*/
public class KNNTestCase extends OpenSearchTestCase {

@Mock
protected ClusterService clusterService;
private AutoCloseable openMocks;

@Override
public void setUp() throws Exception {
super.setUp();
openMocks = MockitoAnnotations.openMocks(this);
}

@Override
public void tearDown() throws Exception {
super.tearDown();
resetState();
openMocks.close();
}

public static void resetState() {
public void resetState() {
// Reset all of the counters
for (KNNCounter knnCounter : KNNCounter.values()) {
knnCounter.set(0L);
}

ClusterService clusterService = mock(ClusterService.class);
Set<Setting<?>> defaultClusterSettings = new HashSet<>(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
defaultClusterSettings.addAll(
KNNSettings.state()
Expand Down

0 comments on commit 3a0277d

Please sign in to comment.