use of org.opensearch.search.SearchService in project OpenSearch by opensearch-project.
the class MockNodeTests method testComponentsMockedByMarkerPlugins.
/**
* Test that we add the appropriate mock services when their plugins are added. This is a very heavy test for a testing component but
* we've broken it in the past so it is important.
*/
public void testComponentsMockedByMarkerPlugins() throws IOException {
Settings settings = // All these are required or MockNode will fail to build.
Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put("transport.type", getTestTransportType()).build();
List<Class<? extends Plugin>> plugins = new ArrayList<>();
plugins.add(getTestTransportPlugin());
plugins.add(MockHttpTransport.TestPlugin.class);
boolean useMockBigArrays = randomBoolean();
boolean useMockSearchService = randomBoolean();
if (useMockBigArrays) {
plugins.add(NodeMocksPlugin.class);
}
if (useMockSearchService) {
plugins.add(MockSearchService.TestPlugin.class);
}
try (MockNode node = new MockNode(settings, plugins)) {
BigArrays bigArrays = node.injector().getInstance(BigArrays.class);
SearchService searchService = node.injector().getInstance(SearchService.class);
if (useMockBigArrays) {
assertSame(bigArrays.getClass(), MockBigArrays.class);
} else {
assertSame(bigArrays.getClass(), BigArrays.class);
}
if (useMockSearchService) {
assertSame(searchService.getClass(), MockSearchService.class);
} else {
assertSame(searchService.getClass(), SearchService.class);
}
}
}
Aggregations