Search in sources :

Example 1 with SearchService

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);
        }
    }
}
Also used : MockBigArrays(org.opensearch.common.util.MockBigArrays) BigArrays(org.opensearch.common.util.BigArrays) MockHttpTransport(org.opensearch.test.MockHttpTransport) MockSearchService(org.opensearch.search.MockSearchService) SearchService(org.opensearch.search.SearchService) ArrayList(java.util.ArrayList) MockSearchService(org.opensearch.search.MockSearchService) Settings(org.opensearch.common.settings.Settings) Plugin(org.opensearch.plugins.Plugin)

Aggregations

ArrayList (java.util.ArrayList)1 Settings (org.opensearch.common.settings.Settings)1 BigArrays (org.opensearch.common.util.BigArrays)1 MockBigArrays (org.opensearch.common.util.MockBigArrays)1 Plugin (org.opensearch.plugins.Plugin)1 MockSearchService (org.opensearch.search.MockSearchService)1 SearchService (org.opensearch.search.SearchService)1 MockHttpTransport (org.opensearch.test.MockHttpTransport)1