Search in sources :

Example 6 with MockNode

use of org.elasticsearch.node.MockNode in project elasticsearch by elastic.

the class TribeUnitTests method assertTribeNodeSuccessfullyCreated.

private static void assertTribeNodeSuccessfullyCreated(Settings extraSettings) throws Exception {
    //The tribe clients do need it to make sure they can find their corresponding tribes using the proper transport
    Settings settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put("node.name", "tribe_node").put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put("discovery.type", "local").put("tribe.t1.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put("tribe.t2.transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put(extraSettings).build();
    try (Node node = new MockNode(settings, Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class)).start()) {
        try (Client client = node.client()) {
            assertBusy(() -> {
                ClusterState state = client.admin().cluster().prepareState().clear().setNodes(true).get().getState();
                assertThat(state.getClusterName().value(), equalTo("tribe_node_cluster"));
                assertThat(state.getNodes().getSize(), equalTo(5));
                for (DiscoveryNode discoveryNode : state.getNodes()) {
                    assertThat(discoveryNode.getName(), either(equalTo("tribe1_node")).or(equalTo("tribe2_node")).or(equalTo("tribe_node")).or(equalTo("tribe_node/t1")).or(equalTo("tribe_node/t2")));
                }
            });
        }
    }
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Node(org.elasticsearch.node.Node) MockNode(org.elasticsearch.node.MockNode) MockNode(org.elasticsearch.node.MockNode) TestZenDiscovery(org.elasticsearch.test.discovery.TestZenDiscovery) Client(org.elasticsearch.client.Client) Settings(org.elasticsearch.common.settings.Settings)

Example 7 with MockNode

use of org.elasticsearch.node.MockNode in project elasticsearch-jdbc by jprante.

the class NodeTestUtils method buildNode.

private Node buildNode(String id) throws IOException {
    Settings nodeSettings = settingsBuilder().put(getNodeSettings()).put("name", id).build();
    logger.info("settings={}", nodeSettings.getAsMap());
    Node node = new MockNode(nodeSettings);
    AbstractClient client = (AbstractClient) node.client();
    nodes.put(id, node);
    clients.put(id, client);
    logger.info("clients={}", clients);
    return node;
}
Also used : AbstractClient(org.elasticsearch.client.support.AbstractClient) Node(org.elasticsearch.node.Node) MockNode(org.elasticsearch.node.MockNode) MockNode(org.elasticsearch.node.MockNode) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

MockNode (org.elasticsearch.node.MockNode)7 Settings (org.elasticsearch.common.settings.Settings)6 Node (org.elasticsearch.node.Node)5 TestZenDiscovery (org.elasticsearch.test.discovery.TestZenDiscovery)4 Plugin (org.elasticsearch.plugins.Plugin)3 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)2 MockTcpTransportPlugin (org.elasticsearch.transport.MockTcpTransportPlugin)2 AfterClass (org.junit.AfterClass)2 BeforeClass (org.junit.BeforeClass)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 Client (org.elasticsearch.client.Client)1 AbstractClient (org.elasticsearch.client.support.AbstractClient)1 ClusterState (org.elasticsearch.cluster.ClusterState)1 DiskThresholdSettings (org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings)1 Builder (org.elasticsearch.common.settings.Settings.Builder)1 TransportAddress (org.elasticsearch.common.transport.TransportAddress)1 RecoverySettings (org.elasticsearch.indices.recovery.RecoverySettings)1