use of org.opensearch.cluster.metadata.IndexNameExpressionResolver in project OpenSearch by opensearch-project.
the class GetDataStreamsRequestTests method testGetNonexistentDataStream.
public void testGetNonexistentDataStream() {
final String dataStreamName = "my-data-stream";
ClusterState cs = ClusterState.builder(new ClusterName("_name")).build();
GetDataStreamAction.Request req = new GetDataStreamAction.Request(new String[] { dataStreamName });
IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> GetDataStreamAction.TransportAction.getDataStreams(cs, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), req));
assertThat(e.getMessage(), containsString("no such index [" + dataStreamName + "]"));
}
use of org.opensearch.cluster.metadata.IndexNameExpressionResolver in project OpenSearch by opensearch-project.
the class GetDataStreamsRequestTests method testGetDataStream.
public void testGetDataStream() {
final String dataStreamName = "my-data-stream";
ClusterState cs = getClusterStateWithDataStreams(org.opensearch.common.collect.List.of(new Tuple<>(dataStreamName, 1)), org.opensearch.common.collect.List.of());
GetDataStreamAction.Request req = new GetDataStreamAction.Request(new String[] { dataStreamName });
List<DataStream> dataStreams = GetDataStreamAction.TransportAction.getDataStreams(cs, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), req);
assertThat(dataStreams.size(), equalTo(1));
assertThat(dataStreams.get(0).getName(), equalTo(dataStreamName));
}
use of org.opensearch.cluster.metadata.IndexNameExpressionResolver in project OpenSearch by opensearch-project.
the class GetDataStreamsRequestTests method testGetDataStreamsWithoutWildcards.
public void testGetDataStreamsWithoutWildcards() {
final String[] dataStreamNames = { "my-data-stream", "another-data-stream" };
ClusterState cs = getClusterStateWithDataStreams(org.opensearch.common.collect.List.of(new Tuple<>(dataStreamNames[0], 1), new Tuple<>(dataStreamNames[1], 1)), org.opensearch.common.collect.List.of());
GetDataStreamAction.Request req = new GetDataStreamAction.Request(new String[] { dataStreamNames[0], dataStreamNames[1] });
List<DataStream> dataStreams = GetDataStreamAction.TransportAction.getDataStreams(cs, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), req);
assertThat(dataStreams.size(), equalTo(2));
assertThat(dataStreams.get(0).getName(), equalTo(dataStreamNames[1]));
assertThat(dataStreams.get(1).getName(), equalTo(dataStreamNames[0]));
req = new GetDataStreamAction.Request(new String[] { dataStreamNames[1] });
dataStreams = GetDataStreamAction.TransportAction.getDataStreams(cs, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), req);
assertThat(dataStreams.size(), equalTo(1));
assertThat(dataStreams.get(0).getName(), equalTo(dataStreamNames[1]));
req = new GetDataStreamAction.Request(new String[] { dataStreamNames[0] });
dataStreams = GetDataStreamAction.TransportAction.getDataStreams(cs, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), req);
assertThat(dataStreams.size(), equalTo(1));
assertThat(dataStreams.get(0).getName(), equalTo(dataStreamNames[0]));
GetDataStreamAction.Request req2 = new GetDataStreamAction.Request(new String[] { "foo" });
IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> GetDataStreamAction.TransportAction.getDataStreams(cs, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), req2));
assertThat(e.getMessage(), containsString("no such index [foo]"));
}
use of org.opensearch.cluster.metadata.IndexNameExpressionResolver in project OpenSearch by opensearch-project.
the class IndexModuleTests method testWrapperIsBound.
public void testWrapperIsBound() throws IOException {
final MockEngineFactory engineFactory = new MockEngineFactory(AssertingDirectoryReader.class);
IndexModule module = new IndexModule(indexSettings, emptyAnalysisRegistry, engineFactory, new EngineConfigFactory(indexSettings), Collections.emptyMap(), () -> true, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), Collections.emptyMap());
module.setReaderWrapper(s -> new Wrapper());
IndexService indexService = newIndexService(module);
assertTrue(indexService.getReaderWrapper() instanceof Wrapper);
assertSame(indexService.getEngineFactory(), module.getEngineFactory());
indexService.close("simon says", false);
}
use of org.opensearch.cluster.metadata.IndexNameExpressionResolver in project OpenSearch by opensearch-project.
the class TransportAddVotingConfigExclusionsActionTests method setupForTest.
@Before
public void setupForTest() {
final MockTransport transport = new MockTransport();
transportService = transport.createTransportService(Settings.EMPTY, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundTransportAddress -> localNode, null, emptySet());
final Settings.Builder nodeSettingsBuilder = Settings.builder();
if (randomBoolean()) {
staticMaximum = between(5, 15);
nodeSettingsBuilder.put(MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING.getKey(), staticMaximum);
} else {
staticMaximum = MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING.get(Settings.EMPTY);
}
final Settings nodeSettings = nodeSettingsBuilder.build();
clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
new TransportAddVotingConfigExclusionsAction(nodeSettings, clusterSettings, transportService, clusterService, threadPool, new ActionFilters(emptySet()), new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)));
// registers action
transportService.start();
transportService.acceptIncomingRequests();
final VotingConfiguration allNodesConfig = VotingConfiguration.of(localNode, otherNode1, otherNode2);
setState(clusterService, builder(new ClusterName("cluster")).nodes(new Builder().add(localNode).add(otherNode1).add(otherNode2).add(otherDataNode).localNodeId(localNode.getId()).masterNodeId(localNode.getId())).metadata(Metadata.builder().coordinationMetadata(CoordinationMetadata.builder().lastAcceptedConfiguration(allNodesConfig).lastCommittedConfiguration(allNodesConfig).build())));
clusterStateObserver = new ClusterStateObserver(clusterService, null, logger, threadPool.getThreadContext());
}
Aggregations