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.StringEXTERNAL_CLUSTER_PREFIX -
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 voidafterTest()This method should be executed during tear down, after each test (but after assertAfterTest)org.elasticsearch.client.Clientclient()Returns a client connected to any node in the clustervoidclose()Closes the current clustervoidensureEstimatedStats()Ensures that any breaker statistics are reset to 0.java.lang.Iterable<org.elasticsearch.client.Client>getClients()Returns anIterableover all clients in this test clusterjava.lang.StringgetClusterName()Returns the cluster nameorg.elasticsearch.common.io.stream.NamedWriteableRegistrygetNamedWriteableRegistry()Returns this clustersNamedWriteableRegistrythis 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.intnumDataAndMasterNodes()Returns the number of data and master eligible nodes in the cluster.intnumDataNodes()Returns the number of data nodes in the cluster.intsize()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
-
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:TestClusterThis method should be executed during tear down, after each test (but after assertAfterTest)- Specified by:
afterTestin classTestCluster
-
client
public org.elasticsearch.client.Client client()Description copied from class:TestClusterReturns a client connected to any node in the cluster- Specified by:
clientin classTestCluster
-
size
public int size()Description copied from class:TestClusterReturns the number of nodes in the cluster.- Specified by:
sizein classTestCluster
-
numDataNodes
public int numDataNodes()Description copied from class:TestClusterReturns the number of data nodes in the cluster.- Specified by:
numDataNodesin classTestCluster
-
numDataAndMasterNodes
public int numDataAndMasterNodes()Description copied from class:TestClusterReturns the number of data and master eligible nodes in the cluster.- Specified by:
numDataAndMasterNodesin classTestCluster
-
httpAddresses
public java.net.InetSocketAddress[] httpAddresses()Description copied from class:TestClusterReturns the http addresses of the nodes within the cluster. Can be used to run REST tests against the test cluster.- Specified by:
httpAddressesin classTestCluster
-
close
public void close() throws java.io.IOExceptionDescription copied from class:TestClusterCloses the current cluster- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classTestCluster- Throws:
java.io.IOException
-
ensureEstimatedStats
public void ensureEstimatedStats()Description copied from class:TestClusterEnsures 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:
ensureEstimatedStatsin classTestCluster
-
getClients
public java.lang.Iterable<org.elasticsearch.client.Client> getClients()Description copied from class:TestClusterReturns anIterableover all clients in this test cluster- Specified by:
getClientsin classTestCluster
-
getNamedWriteableRegistry
public org.elasticsearch.common.io.stream.NamedWriteableRegistry getNamedWriteableRegistry()Description copied from class:TestClusterReturns this clustersNamedWriteableRegistrythis is needed to deserialize binary content from this cluster that might include custom named writeables- Specified by:
getNamedWriteableRegistryin classTestCluster
-
getClusterName
public java.lang.String getClusterName()Description copied from class:TestClusterReturns the cluster name- Specified by:
getClusterNamein classTestCluster
-