Skip to content

Commit

Permalink
Performance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nils Bandener <[email protected]>
  • Loading branch information
nibix committed Jul 1, 2024
1 parent 277159c commit f19e79c
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

import org.opensearch.action.ActionRequest;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.metadata.IndexAbstraction;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.metadata.Metadata;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.concurrent.ThreadContext;
Expand All @@ -46,7 +48,6 @@
import com.github.noconnor.junitperf.reporting.providers.HtmlReportGenerator;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;
Expand Down Expand Up @@ -733,9 +734,16 @@ public void evaluate_limitedPrivilegesWithUserAttrAndRegex_10000indices_dnfof()
}

static PrivilegesEvaluator createPrivilegeEvaluator(int numberOfIndices, boolean doNotFailOnForbidden) {
SortedMap<String, IndexAbstraction> metaData = testIndices(numberOfIndices);
ClusterService clusterService = mock(ClusterService.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS).stubOnly());
when(clusterService.state().metadata().getIndicesLookup()).thenReturn(metaData);
SortedMap<String, IndexAbstraction> indicesLookup = testIndices(numberOfIndices);
Metadata metadata = mock(Metadata.class, withSettings().stubOnly());
when(metadata.getIndicesLookup()).thenReturn(indicesLookup);

ClusterState clusterState = mock(ClusterState.class, withSettings().stubOnly());
when(clusterState.getMetadata()).thenReturn(metadata);
when(clusterState.metadata()).thenReturn(metadata);

ClusterService clusterService = mock(ClusterService.class, withSettings().stubOnly());
when(clusterService.state()).thenReturn(clusterState);

ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
ConfigurationRepository configurationRepository = mock(ConfigurationRepository.class, withSettings().stubOnly());
Expand Down

0 comments on commit f19e79c

Please sign in to comment.