Package org.elasticsearch.test.rest
Class ESRestTestCase
java.lang.Object
org.junit.Assert
org.apache.lucene.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.test.rest.ESRestTestCase
- Direct Known Subclasses:
AbstractFullClusterRestartTestCase
,ESClientYamlSuiteTestCase
,JsonLogsIntegTestCase
public abstract class ESRestTestCase extends ESTestCase
Superclass for tests that interact with an external test cluster using Elasticsearch's
RestClient
.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ESRestTestCase.VersionSensitiveWarningsHandler
Helper class to check warnings in REST responses with sensitivity to versions used in the target cluster.Nested classes/interfaces inherited from class org.elasticsearch.test.ESTestCase
ESTestCase.GeohashGenerator, ESTestCase.TestAnalysis
Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase
org.apache.lucene.util.LuceneTestCase.AwaitsFix, org.apache.lucene.util.LuceneTestCase.BadApple, org.apache.lucene.util.LuceneTestCase.Monster, org.apache.lucene.util.LuceneTestCase.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.util.LuceneTestCase.SuppressFsync, org.apache.lucene.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.util.LuceneTestCase.Weekly
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLIENT_PATH_PREFIX
static java.lang.String
CLIENT_SOCKET_TIMEOUT
static java.lang.String
TRUSTSTORE_PASSWORD
static java.lang.String
TRUSTSTORE_PATH
Fields inherited from class org.elasticsearch.test.ESTestCase
checkIndexFailures, DEFAULT_TEST_WORKER_ID, failureAndSuccessEvents, FIPS_SYSPROP, JAVA_TIMEZONE_IDS, JAVA_ZONE_IDS, JODA_TIMEZONE_IDS, logger, TEST_WORKER_SYS_PROPERTY, TEST_WORKER_VM_ID
Fields inherited from class org.apache.lucene.util.LuceneTestCase
assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_BADAPPLES, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
-
Constructor Summary
Constructors Constructor Description ESRestTestCase()
-
Method Summary
Modifier and Type Method Description protected static org.elasticsearch.client.RestClient
adminClient()
Get the client used for test administrative actions.protected static boolean
aliasExists(java.lang.String alias)
protected static boolean
aliasExists(java.lang.String index, java.lang.String alias)
static org.elasticsearch.client.RequestOptions
allowTypesRemovalWarnings()
Deprecated.this method is only required while we deprecate types and can be removed in 8.0void
assertEmptyTranslog(java.lang.String index)
Asserts that we do not retain any extra translog for the given index (i.e., turn off the translog retention)void
assertNoFileBasedRecovery(java.lang.String indexName, java.util.function.Predicate<java.lang.String> targetNode)
Asserts that replicas on nodes satisfying thetargetNode
should have perform operation-based recoveries.protected static void
assertOK(org.elasticsearch.client.Response response)
protected org.elasticsearch.client.RestClient
buildClient(org.elasticsearch.common.settings.Settings settings, org.apache.http.HttpHost[] hosts)
protected org.apache.http.HttpHost
buildHttpHost(java.lang.String host, int port)
Construct an HttpHost from the given host and portvoid
cleanUpCluster()
Clean up after the test case.protected static org.elasticsearch.client.RestClient
client()
Get the client used for ordinary api calls while writing a teststatic void
closeClients()
protected static void
closeIndex(java.lang.String index)
protected static void
configureClient(org.elasticsearch.client.RestClientBuilder builder, org.elasticsearch.common.settings.Settings settings)
protected static void
createIndex(java.lang.String name, org.elasticsearch.common.settings.Settings settings)
protected static void
createIndex(java.lang.String name, org.elasticsearch.common.settings.Settings settings, java.lang.String mapping)
protected static void
createIndex(java.lang.String name, org.elasticsearch.common.settings.Settings settings, java.lang.String mapping, java.lang.String aliases)
protected static void
deleteIndex(java.lang.String name)
protected void
deleteRepository(java.lang.String repoName)
protected static void
ensureGreen(java.lang.String index)
checks that the specific index is green.protected static void
ensureHealth(java.lang.String index, java.util.function.Consumer<org.elasticsearch.client.Request> requestConsumer)
protected static void
ensureHealth(java.util.function.Consumer<org.elasticsearch.client.Request> requestConsumer)
protected static void
ensureHealth(org.elasticsearch.client.RestClient client, java.lang.String index, java.util.function.Consumer<org.elasticsearch.client.Request> requestConsumer)
protected static void
ensureNoInitializingShards()
waits until all shard initialization is completed.void
ensurePeerRecoveryRetentionLeasesRenewedAndSynced(java.lang.String index)
Peer recovery retention leases are renewed and synced to replicas periodically (every 30 seconds).static java.util.List<java.lang.Object>
entityAsList(org.elasticsearch.client.Response response)
Convert the entity from aResponse
into a list of maps.static java.util.Map<java.lang.String,java.lang.Object>
entityAsMap(org.elasticsearch.client.Response response)
Convert the entity from aResponse
into a map of maps.protected static void
expectSoftDeletesWarning(org.elasticsearch.client.Request request, java.lang.String indexName)
protected static void
expectTranslogRetentionWarning(org.elasticsearch.client.Request request)
static org.elasticsearch.client.RequestOptions
expectVersionSpecificWarnings(java.util.function.Consumer<ESRestTestCase.VersionSensitiveWarningsHandler> expectationsSetter)
static org.elasticsearch.client.RequestOptions
expectWarnings(java.lang.String... warnings)
Creates request options designed to be used when making a call that can return warnings, for example a deprecated request.void
flush(java.lang.String index, boolean force)
protected static java.util.Map<java.lang.String,java.lang.Object>
getAlias(java.lang.String index, java.lang.String alias)
protected static java.util.Map<java.lang.String,java.lang.Object>
getAsMap(java.lang.String endpoint)
protected java.util.List<org.apache.http.HttpHost>
getClusterHosts()
Get the list of hosts in the cluster.static java.lang.Boolean
getHasXPack()
protected static java.util.Map<java.lang.String,java.lang.Object>
getIndexSettings(java.lang.String index)
protected java.util.Map<java.lang.String,java.lang.Object>
getIndexSettingsAsMap(java.lang.String index)
protected java.lang.String
getProtocol()
Override this to switch to testing https.protected java.lang.String
getTestRestCluster()
static boolean
hasXPack()
Does any node in the cluster being tested have x-pack installed?protected static boolean
indexExists(java.lang.String index)
void
initClient()
protected static boolean
isXPackTemplate(java.lang.String name)
Is this template one that is automatically created by xpack?protected static org.elasticsearch.Version
minimumNodeVersion()
Returns the minimum node version among all nodes of the clusterprotected static void
openIndex(java.lang.String index)
protected static org.elasticsearch.client.Response
performSyncedFlush(java.lang.String indexName)
protected boolean
preserveAutoFollowPatternsUponCompletion()
Returns whether to preserve auto-follow patterns.protected boolean
preserveClusterSettings()
Controls whether or not to preserve cluster settings upon completion of the test.protected boolean
preserveClusterUponCompletion()
Returns whether to preserve the state of the cluster upon completion of this test.protected boolean
preserveDataStreamsUponCompletion()
Determines if data streams are preserved upon completion of this test.protected boolean
preserveILMPoliciesUponCompletion()
Returns whether to preserve ILM Policies of this test.protected java.util.Set<java.lang.String>
preserveILMPolicyIds()
A set of ILM policies that should be preserved between runs.protected boolean
preserveIndicesUponCompletion()
Returns whether to preserve the indices created during this test on completion of this test.protected boolean
preserveReposUponCompletion()
Returns whether to preserve the repositories on completion of this test.protected boolean
preserveRollupJobsUponCompletion()
Returns whether to preserve the rollup jobs of this test.protected boolean
preserveSLMPoliciesUponCompletion()
Returns whether to preserve SLM Policies of this test.protected boolean
preserveSnapshotsUponCompletion()
Returns whether to preserve the snapshots in repositories on completion of this test.protected boolean
preserveTemplatesUponCompletion()
Controls whether or not to preserve templates upon completion of this test.protected void
refreshAllIndices()
protected org.elasticsearch.common.settings.Settings
restAdminSettings()
Returns the REST client settings used for admin actions like cleaning up after the test has completed.protected org.elasticsearch.common.settings.Settings
restClientSettings()
Used to obtain settings for the REST client that is used to send REST requests.protected static void
updateIndexSettings(java.lang.String index, org.elasticsearch.common.settings.Settings.Builder settings)
protected static void
useIgnoreMultipleMatchingTemplatesWarningsHandler(org.elasticsearch.client.Request request)
protected static void
waitForActiveLicense(org.elasticsearch.client.RestClient restClient)
Wait for the license to be applied and active.protected boolean
waitForAllSnapshotsWiped()
Returns whether to wait to make absolutely certain that all snapshots have been deleted.static void
waitForPendingTasks(org.elasticsearch.client.RestClient adminClient)
Wait for outstanding tasks to complete.static void
waitForPendingTasks(org.elasticsearch.client.RestClient adminClient, java.util.function.Predicate<java.lang.String> taskFilter)
Wait for outstanding tasks to complete.protected static void
wipeAllIndices()
protected static void
wipeDataStreams()
protected java.util.Map<java.lang.String,java.util.List<java.util.Map<?,?>>>
wipeSnapshots()
Wipe fs snapshots we created one by one and all repositories so that the next test can create the repositories fresh and they'll start empty.Methods inherited from class org.elasticsearch.test.ESTestCase
after, afterIfFailed, afterIfSuccessful, allowedWarnings, assertArrayEquals, assertBusy, assertBusy, assertEquals, assertSettingDeprecationsAndWarnings, assertSettingDeprecationsAndWarnings, assertWarnings, assertWarnings, before, between, buildEnvSettings, buildNewFakeTransportAddress, checkStaticState, clearAdditionalRoles, copyInstance, copyNamedWriteable, copyNamedWriteable, copyWriteable, copyWriteable, createParser, createParser, createParser, createParser, createParser, createParser, createTestAnalysis, createTestAnalysis, createTestAnalysis, enableJodaDeprecationWarningsCheck, enableWarningsCheck, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureSupportedLocale, frequently, generateRandomStringArray, generateRandomStringArray, getBasePort, getDataPath, getPortRange, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, inFipsJvm, iterations, maybeSet, mockScript, newNodeEnvironment, newNodeEnvironment, randomAlphaOfLength, randomAlphaOfLengthBetween, randomArray, randomArray, randomBoolean, randomByte, randomByteArrayOfLength, randomDateTimeZone, randomDouble, randomDoubleBetween, randomFloat, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomInt, randomInt, randomIntBetween, randomIp, randomList, randomList, randomLong, randomLongBetween, randomNonNegativeLong, randomPositiveTimeValue, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomValueOtherThan, randomValueOtherThanMany, randomZone, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, scaledRandomIntBetween, setContentType, setFileSystem, settings, shuffleMap, shuffleXContent, shuffleXContent, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, terminate, terminate, tmpPaths, toShuffledXContent, waitUntil, waitUntil, writableRegistry, xContentRegistry
Methods inherited from class org.apache.lucene.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, assumeWorkingMMapOnWindows, atLeast, atLeast, callStackContains, callStackContains, callStackContainsAnyOf, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, ensureSaneIWCOnNightly, expectThrows, expectThrows, expectThrows, expectThrowsAnyOf, expectThrowsAnyOf, getBaseTempDirForTestClass, getDataInputStream, getOnlyLeafReader, getTestClass, getTestName, hasWorkingMMapOnWindows, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, restoreSpins, runWithRestrictedPermissions, setIndexWriterMaxDocs, setUp, setupCPUCoreCount, setupSpins, slowFileExists, tearDown, usually, usually, wrapReader
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
-
Field Details
-
TRUSTSTORE_PATH
public static final java.lang.String TRUSTSTORE_PATH- See Also:
- Constant Field Values
-
TRUSTSTORE_PASSWORD
public static final java.lang.String TRUSTSTORE_PASSWORD- See Also:
- Constant Field Values
-
CLIENT_SOCKET_TIMEOUT
public static final java.lang.String CLIENT_SOCKET_TIMEOUT- See Also:
- Constant Field Values
-
CLIENT_PATH_PREFIX
public static final java.lang.String CLIENT_PATH_PREFIX- See Also:
- Constant Field Values
-
-
Constructor Details
-
ESRestTestCase
public ESRestTestCase()
-
-
Method Details
-
entityAsMap
public static java.util.Map<java.lang.String,java.lang.Object> entityAsMap(org.elasticsearch.client.Response response) throws java.io.IOExceptionConvert the entity from aResponse
into a map of maps.- Throws:
java.io.IOException
-
entityAsList
public static java.util.List<java.lang.Object> entityAsList(org.elasticsearch.client.Response response) throws java.io.IOExceptionConvert the entity from aResponse
into a list of maps.- Throws:
java.io.IOException
-
hasXPack
public static boolean hasXPack()Does any node in the cluster being tested have x-pack installed? -
initClient
public void initClient() throws java.io.IOException- Throws:
java.io.IOException
-
getTestRestCluster
protected java.lang.String getTestRestCluster() -
expectVersionSpecificWarnings
public static org.elasticsearch.client.RequestOptions expectVersionSpecificWarnings(java.util.function.Consumer<ESRestTestCase.VersionSensitiveWarningsHandler> expectationsSetter) -
expectWarnings
public static org.elasticsearch.client.RequestOptions expectWarnings(java.lang.String... warnings)Creates request options designed to be used when making a call that can return warnings, for example a deprecated request. The options will ensure that the given warnings are returned if all nodes are onVersion.CURRENT
and will allow (but not require) the warnings if any node is running an older version.- Parameters:
warnings
- The expected warnings.
-
allowTypesRemovalWarnings
@Deprecated public static org.elasticsearch.client.RequestOptions allowTypesRemovalWarnings()Deprecated.this method is only required while we deprecate types and can be removed in 8.0Creates RequestOptions designed to ignore [types removal] warnings but nothing else -
buildHttpHost
protected org.apache.http.HttpHost buildHttpHost(java.lang.String host, int port)Construct an HttpHost from the given host and port -
cleanUpCluster
public final void cleanUpCluster() throws java.lang.ExceptionClean up after the test case.- Throws:
java.lang.Exception
-
closeClients
public static void closeClients() throws java.io.IOException- Throws:
java.io.IOException
-
client
protected static org.elasticsearch.client.RestClient client()Get the client used for ordinary api calls while writing a test -
adminClient
protected static org.elasticsearch.client.RestClient adminClient()Get the client used for test administrative actions. Do not use this while writing a test. Only use it for cleaning up after tests. -
waitForPendingTasks
public static void waitForPendingTasks(org.elasticsearch.client.RestClient adminClient) throws java.lang.ExceptionWait for outstanding tasks to complete. The specified admin client is used to check the outstanding tasks and this is done usingESTestCase.assertBusy(CheckedRunnable)
to give a chance to any outstanding tasks to complete.- Parameters:
adminClient
- the admin client- Throws:
java.lang.Exception
- if an exception is thrown while checking the outstanding tasks
-
waitForPendingTasks
public static void waitForPendingTasks(org.elasticsearch.client.RestClient adminClient, java.util.function.Predicate<java.lang.String> taskFilter) throws java.lang.ExceptionWait for outstanding tasks to complete. The specified admin client is used to check the outstanding tasks and this is done usingESTestCase.assertBusy(CheckedRunnable)
to give a chance to any outstanding tasks to complete. The specified filter is used to filter out outstanding tasks that are expected to be there.- Parameters:
adminClient
- the admin clienttaskFilter
- predicate used to filter tasks that are expected to be there- Throws:
java.lang.Exception
- if an exception is thrown while checking the outstanding tasks
-
preserveClusterUponCompletion
protected boolean preserveClusterUponCompletion()Returns whether to preserve the state of the cluster upon completion of this test. Defaults to false. If true, overrides the value ofpreserveIndicesUponCompletion()
,preserveTemplatesUponCompletion()
,preserveReposUponCompletion()
,preserveSnapshotsUponCompletion()
,preserveRollupJobsUponCompletion()
, andpreserveILMPoliciesUponCompletion()
.- Returns:
- true if the state of the cluster should be preserved
-
preserveIndicesUponCompletion
protected boolean preserveIndicesUponCompletion()Returns whether to preserve the indices created during this test on completion of this test. Defaults tofalse
. Override this method if indices should be preserved after the test, with the assumption that some other process or test will clean up the indices afterward. This is useful if the data directory and indices need to be preserved between test runs (for example, when testing rolling upgrades). -
preserveTemplatesUponCompletion
protected boolean preserveTemplatesUponCompletion()Controls whether or not to preserve templates upon completion of this test. The default implementation is to delete not preserve templates.- Returns:
- whether or not to preserve templates
-
preserveDataStreamsUponCompletion
protected boolean preserveDataStreamsUponCompletion()Determines if data streams are preserved upon completion of this test. The default implementation wipes data streams.- Returns:
- whether or not to preserve data streams
-
preserveClusterSettings
protected boolean preserveClusterSettings()Controls whether or not to preserve cluster settings upon completion of the test. The default implementation is to remove all cluster settings.- Returns:
- true if cluster settings should be preserved and otherwise false
-
preserveReposUponCompletion
protected boolean preserveReposUponCompletion()Returns whether to preserve the repositories on completion of this test. Defaults to not preserving repos. See alsopreserveSnapshotsUponCompletion()
. -
preserveSnapshotsUponCompletion
protected boolean preserveSnapshotsUponCompletion()Returns whether to preserve the snapshots in repositories on completion of this test. Defaults to not preserving snapshots. Only works forfs
repositories. -
preserveRollupJobsUponCompletion
protected boolean preserveRollupJobsUponCompletion()Returns whether to preserve the rollup jobs of this test. Defaults to not preserving them. Only runs at all if xpack is installed on the cluster being tested. -
preserveILMPoliciesUponCompletion
protected boolean preserveILMPoliciesUponCompletion()Returns whether to preserve ILM Policies of this test. Defaults to not preserving them. Only runs at all if xpack is installed on the cluster being tested. -
preserveSLMPoliciesUponCompletion
protected boolean preserveSLMPoliciesUponCompletion()Returns whether to preserve SLM Policies of this test. Defaults to not preserving them. Only runs at all if xpack is installed on the cluster being tested. -
preserveILMPolicyIds
protected java.util.Set<java.lang.String> preserveILMPolicyIds()A set of ILM policies that should be preserved between runs. -
preserveAutoFollowPatternsUponCompletion
protected boolean preserveAutoFollowPatternsUponCompletion()Returns whether to preserve auto-follow patterns. Defaults to not preserving them. Only runs at all if xpack is installed on the cluster being tested. -
waitForAllSnapshotsWiped
protected boolean waitForAllSnapshotsWiped()Returns whether to wait to make absolutely certain that all snapshots have been deleted. -
wipeAllIndices
protected static void wipeAllIndices() throws java.io.IOException- Throws:
java.io.IOException
-
wipeDataStreams
protected static void wipeDataStreams() throws java.io.IOException- Throws:
java.io.IOException
-
wipeSnapshots
protected java.util.Map<java.lang.String,java.util.List<java.util.Map<?,?>>> wipeSnapshots() throws java.io.IOExceptionWipe fs snapshots we created one by one and all repositories so that the next test can create the repositories fresh and they'll start empty. There isn't an API to delete all snapshots. There is an API to delete all snapshot repositories but that leaves all of the snapshots intact in the repository.- Returns:
- Map of repository name to list of snapshots found in unfinished state
- Throws:
java.io.IOException
-
deleteRepository
protected void deleteRepository(java.lang.String repoName) throws java.io.IOException- Throws:
java.io.IOException
-
refreshAllIndices
protected void refreshAllIndices() throws java.io.IOException- Throws:
java.io.IOException
-
restClientSettings
protected org.elasticsearch.common.settings.Settings restClientSettings()Used to obtain settings for the REST client that is used to send REST requests. -
restAdminSettings
protected org.elasticsearch.common.settings.Settings restAdminSettings()Returns the REST client settings used for admin actions like cleaning up after the test has completed. -
getClusterHosts
protected final java.util.List<org.apache.http.HttpHost> getClusterHosts()Get the list of hosts in the cluster. -
getProtocol
protected java.lang.String getProtocol()Override this to switch to testing https. -
buildClient
protected org.elasticsearch.client.RestClient buildClient(org.elasticsearch.common.settings.Settings settings, org.apache.http.HttpHost[] hosts) throws java.io.IOException- Throws:
java.io.IOException
-
configureClient
protected static void configureClient(org.elasticsearch.client.RestClientBuilder builder, org.elasticsearch.common.settings.Settings settings) throws java.io.IOException- Throws:
java.io.IOException
-
assertOK
protected static void assertOK(org.elasticsearch.client.Response response) -
ensureGreen
protected static void ensureGreen(java.lang.String index) throws java.io.IOExceptionchecks that the specific index is green. we force a selection of an index as the tests share a cluster and often leave indices in an non green state- Parameters:
index
- index to test for- Throws:
java.io.IOException
-
ensureHealth
protected static void ensureHealth(java.util.function.Consumer<org.elasticsearch.client.Request> requestConsumer) throws java.io.IOException- Throws:
java.io.IOException
-
ensureHealth
protected static void ensureHealth(java.lang.String index, java.util.function.Consumer<org.elasticsearch.client.Request> requestConsumer) throws java.io.IOException- Throws:
java.io.IOException
-
ensureHealth
protected static void ensureHealth(org.elasticsearch.client.RestClient client, java.lang.String index, java.util.function.Consumer<org.elasticsearch.client.Request> requestConsumer) throws java.io.IOException- Throws:
java.io.IOException
-
ensureNoInitializingShards
protected static void ensureNoInitializingShards() throws java.io.IOExceptionwaits until all shard initialization is completed. This is a handy alternative to ensureGreen as it relates to all shards in the cluster and doesn't require to know how many nodes/replica there are.- Throws:
java.io.IOException
-
createIndex
protected static void createIndex(java.lang.String name, org.elasticsearch.common.settings.Settings settings) throws java.io.IOException- Throws:
java.io.IOException
-
createIndex
protected static void createIndex(java.lang.String name, org.elasticsearch.common.settings.Settings settings, java.lang.String mapping) throws java.io.IOException- Throws:
java.io.IOException
-
createIndex
protected static void createIndex(java.lang.String name, org.elasticsearch.common.settings.Settings settings, java.lang.String mapping, java.lang.String aliases) throws java.io.IOException- Throws:
java.io.IOException
-
deleteIndex
protected static void deleteIndex(java.lang.String name) throws java.io.IOException- Throws:
java.io.IOException
-
updateIndexSettings
protected static void updateIndexSettings(java.lang.String index, org.elasticsearch.common.settings.Settings.Builder settings) throws java.io.IOException- Throws:
java.io.IOException
-
expectSoftDeletesWarning
protected static void expectSoftDeletesWarning(org.elasticsearch.client.Request request, java.lang.String indexName) -
expectTranslogRetentionWarning
protected static void expectTranslogRetentionWarning(org.elasticsearch.client.Request request) -
getIndexSettings
protected static java.util.Map<java.lang.String,java.lang.Object> getIndexSettings(java.lang.String index) throws java.io.IOException- Throws:
java.io.IOException
-
getIndexSettingsAsMap
protected java.util.Map<java.lang.String,java.lang.Object> getIndexSettingsAsMap(java.lang.String index) throws java.io.IOException- Throws:
java.io.IOException
-
indexExists
protected static boolean indexExists(java.lang.String index) throws java.io.IOException- Throws:
java.io.IOException
-
closeIndex
protected static void closeIndex(java.lang.String index) throws java.io.IOException- Throws:
java.io.IOException
-
openIndex
protected static void openIndex(java.lang.String index) throws java.io.IOException- Throws:
java.io.IOException
-
aliasExists
protected static boolean aliasExists(java.lang.String alias) throws java.io.IOException- Throws:
java.io.IOException
-
aliasExists
protected static boolean aliasExists(java.lang.String index, java.lang.String alias) throws java.io.IOException- Throws:
java.io.IOException
-
getAlias
protected static java.util.Map<java.lang.String,java.lang.Object> getAlias(java.lang.String index, java.lang.String alias) throws java.io.IOException- Throws:
java.io.IOException
-
getAsMap
protected static java.util.Map<java.lang.String,java.lang.Object> getAsMap(java.lang.String endpoint) throws java.io.IOException- Throws:
java.io.IOException
-
isXPackTemplate
protected static boolean isXPackTemplate(java.lang.String name)Is this template one that is automatically created by xpack? -
flush
public void flush(java.lang.String index, boolean force) throws java.io.IOException- Throws:
java.io.IOException
-
assertNoFileBasedRecovery
public void assertNoFileBasedRecovery(java.lang.String indexName, java.util.function.Predicate<java.lang.String> targetNode) throws java.io.IOExceptionAsserts that replicas on nodes satisfying thetargetNode
should have perform operation-based recoveries.- Throws:
java.io.IOException
-
assertEmptyTranslog
public void assertEmptyTranslog(java.lang.String index) throws java.lang.ExceptionAsserts that we do not retain any extra translog for the given index (i.e., turn off the translog retention)- Throws:
java.lang.Exception
-
ensurePeerRecoveryRetentionLeasesRenewedAndSynced
public void ensurePeerRecoveryRetentionLeasesRenewedAndSynced(java.lang.String index) throws java.lang.ExceptionPeer recovery retention leases are renewed and synced to replicas periodically (every 30 seconds). This ensures that we have renewed every PRRL to the global checkpoint of the corresponding copy and properly synced to all copies.- Throws:
java.lang.Exception
-
getHasXPack
public static java.lang.Boolean getHasXPack() -
minimumNodeVersion
protected static org.elasticsearch.Version minimumNodeVersion() throws java.io.IOExceptionReturns the minimum node version among all nodes of the cluster- Throws:
java.io.IOException
-
performSyncedFlush
protected static org.elasticsearch.client.Response performSyncedFlush(java.lang.String indexName) throws java.io.IOException- Throws:
java.io.IOException
-
waitForActiveLicense
protected static void waitForActiveLicense(org.elasticsearch.client.RestClient restClient) throws java.lang.ExceptionWait for the license to be applied and active. The specified admin client is used to check the license and this is done usingESTestCase.assertBusy(CheckedRunnable)
to give some time to the License to be applied on nodes.- Parameters:
restClient
- the client to use- Throws:
java.lang.Exception
- if an exception is thrown while checking the status of the license
-
useIgnoreMultipleMatchingTemplatesWarningsHandler
protected static void useIgnoreMultipleMatchingTemplatesWarningsHandler(org.elasticsearch.client.Request request) throws java.io.IOException- Throws:
java.io.IOException
-