Package org.elasticsearch.test
Class ExternalTestCluster
java.lang.Object
org.elasticsearch.test.TestCluster
org.elasticsearch.test.ExternalTestCluster
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class ExternalTestCluster extends TestCluster
External cluster to run the tests against.
It is a pure immutable test cluster that allows to send requests to a pre-existing cluster
and supports by nature all the needed test operations like wipeIndices etc.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EXTERNAL_CLUSTER_PREFIX
Fields inherited from class org.elasticsearch.test.TestCluster
random, transportClientRatio
-
Constructor Summary
Constructors Constructor Description ExternalTestCluster(java.nio.file.Path tempDir, org.elasticsearch.common.settings.Settings additionalSettings, java.util.Collection<java.lang.Class<? extends org.elasticsearch.plugins.Plugin>> pluginClasses, org.elasticsearch.common.transport.TransportAddress... transportAddresses)
-
Method Summary
Modifier and Type Method Description void
afterTest()
This method should be executed during tear down, after each test (but after assertAfterTest)org.elasticsearch.client.Client
client()
Returns a client connected to any node in the clustervoid
close()
Closes the current clustervoid
ensureEstimatedStats()
Ensures that any breaker statistics are reset to 0.java.lang.Iterable<org.elasticsearch.client.Client>
getClients()
Returns anIterable
over all clients in this test clusterjava.lang.String
getClusterName()
Returns the cluster nameorg.elasticsearch.common.io.stream.NamedWriteableRegistry
getNamedWriteableRegistry()
Returns this clustersNamedWriteableRegistry
this is needed to deserialize binary content from this cluster that might include custom named writeablesjava.net.InetSocketAddress[]
httpAddresses()
Returns the http addresses of the nodes within the cluster.int
numDataAndMasterNodes()
Returns the number of data and master eligible nodes in the cluster.int
numDataNodes()
Returns the number of data nodes in the cluster.int
size()
Returns the number of nodes in the cluster.Methods inherited from class org.elasticsearch.test.TestCluster
assertAfterTest, beforeIndexDeletion, beforeTest, seed, wipe, wipeAllTemplates, wipeIndices, wipeRepositories, wipeTemplates
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
EXTERNAL_CLUSTER_PREFIX
public static final java.lang.String EXTERNAL_CLUSTER_PREFIX- See Also:
- Constant Field Values
-
-
Constructor Details
-
ExternalTestCluster
public ExternalTestCluster(java.nio.file.Path tempDir, org.elasticsearch.common.settings.Settings additionalSettings, java.util.Collection<java.lang.Class<? extends org.elasticsearch.plugins.Plugin>> pluginClasses, org.elasticsearch.common.transport.TransportAddress... transportAddresses)
-
-
Method Details
-
afterTest
public void afterTest()Description copied from class:TestCluster
This method should be executed during tear down, after each test (but after assertAfterTest)- Specified by:
afterTest
in classTestCluster
-
client
public org.elasticsearch.client.Client client()Description copied from class:TestCluster
Returns a client connected to any node in the cluster- Specified by:
client
in classTestCluster
-
size
public int size()Description copied from class:TestCluster
Returns the number of nodes in the cluster.- Specified by:
size
in classTestCluster
-
numDataNodes
public int numDataNodes()Description copied from class:TestCluster
Returns the number of data nodes in the cluster.- Specified by:
numDataNodes
in classTestCluster
-
numDataAndMasterNodes
public int numDataAndMasterNodes()Description copied from class:TestCluster
Returns the number of data and master eligible nodes in the cluster.- Specified by:
numDataAndMasterNodes
in classTestCluster
-
httpAddresses
public java.net.InetSocketAddress[] httpAddresses()Description copied from class:TestCluster
Returns the http addresses of the nodes within the cluster. Can be used to run REST tests against the test cluster.- Specified by:
httpAddresses
in classTestCluster
-
close
public void close() throws java.io.IOExceptionDescription copied from class:TestCluster
Closes the current cluster- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classTestCluster
- Throws:
java.io.IOException
-
ensureEstimatedStats
public void ensureEstimatedStats()Description copied from class:TestCluster
Ensures that any breaker statistics are reset to 0. The implementation is specific to the test cluster, because the act of checking some breaker stats can increase them.- Specified by:
ensureEstimatedStats
in classTestCluster
-
getClients
public java.lang.Iterable<org.elasticsearch.client.Client> getClients()Description copied from class:TestCluster
Returns anIterable
over all clients in this test cluster- Specified by:
getClients
in classTestCluster
-
getNamedWriteableRegistry
public org.elasticsearch.common.io.stream.NamedWriteableRegistry getNamedWriteableRegistry()Description copied from class:TestCluster
Returns this clustersNamedWriteableRegistry
this is needed to deserialize binary content from this cluster that might include custom named writeables- Specified by:
getNamedWriteableRegistry
in classTestCluster
-
getClusterName
public java.lang.String getClusterName()Description copied from class:TestCluster
Returns the cluster name- Specified by:
getClusterName
in classTestCluster
-