Package org.elasticsearch.test
Class TestCluster
java.lang.Object
org.elasticsearch.test.TestCluster
- Direct Known Subclasses:
ExternalTestCluster,InternalTestCluster
Base test cluster that exposes the basis to run tests against any elasticsearch cluster, whose layout
(e.g. number of nodes) is predefined and cannot be changed during the tests execution
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidThis method should be executed during tear down, after each test (but after assertAfterTest)voidThis method checks all the things that need to be checked after each testvoidAssertions that should run before the cluster is wiped should be called in this methodvoidbeforeTest(Random randomGenerator) This method should be executed before each test to reset the cluster to its initial state.abstract Clientclient()Returns a client connected to any node in the clusterabstract voidclose()Closes the current clusterabstract voidEnsures that any breaker statistics are reset to 0.Returns anIterableover all clients in this test clusterabstract StringReturns the cluster nameabstract NamedWriteableRegistryReturns this clustersNamedWriteableRegistrythis is needed to deserialize binary content from this cluster that might include custom named writeablesabstract InetSocketAddress[]Returns the http addresses of the nodes within the cluster.abstract intReturns the number of data and master eligible nodes in the cluster.abstract intReturns the number of data nodes in the cluster.longseed()abstract intsize()Returns the number of nodes in the cluster.voidWipes any data that a test can leave behind: indices, templates (except exclude templates) and repositoriesvoidwipeIndices(String... indices) Deletes the given indices from the tests cluster.voidwipeTemplates(String... templates) Deletes index templates, support wildcard notation.
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
random
-
-
Constructor Details
-
TestCluster
public TestCluster(long seed)
-
-
Method Details
-
seed
public long seed() -
beforeTest
This method should be executed before each test to reset the cluster to its initial state.- Throws:
IOExceptionInterruptedException
-
wipe
Wipes any data that a test can leave behind: indices, templates (except exclude templates) and repositories -
beforeIndexDeletion
Assertions that should run before the cluster is wiped should be called in this method- Throws:
Exception
-
assertAfterTest
This method checks all the things that need to be checked after each test- Throws:
Exception
-
afterTest
This method should be executed during tear down, after each test (but after assertAfterTest)- Throws:
IOException
-
client
Returns a client connected to any node in the cluster -
size
public abstract int size()Returns the number of nodes in the cluster. -
numDataNodes
public abstract int numDataNodes()Returns the number of data nodes in the cluster. -
numDataAndMasterNodes
public abstract int numDataAndMasterNodes()Returns the number of data and master eligible nodes in the cluster. -
httpAddresses
Returns the http addresses of the nodes within the cluster. Can be used to run REST tests against the test cluster. -
close
Closes the current cluster- Throws:
IOException
-
wipeIndices
Deletes the given indices from the tests cluster. If no index name is passed to this method all indices are removed. -
wipeTemplates
Deletes index templates, support wildcard notation. If no template name is passed to this method all templates are removed. -
ensureEstimatedStats
public abstract void ensureEstimatedStats()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. -
getClusterName
Returns the cluster name -
getClients
Returns anIterableover all clients in this test cluster -
getNamedWriteableRegistry
Returns this clustersNamedWriteableRegistrythis is needed to deserialize binary content from this cluster that might include custom named writeables
-