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
Superclass for tests that interact with an external test cluster using Elasticsearch's
RestClient
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
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
FieldsModifier and TypeFieldDescriptionstatic String
static String
static String
static String
static String
static String
static String
static String
Fields inherited from class org.elasticsearch.test.ESTestCase
checkIndexFailures, DEFAULT_NAMED_WRITABLE_REGISTRY, DEFAULT_TEST_WORKER_ID, failureAndSuccessEvents, FIPS_SYSPROP, JAVA_TIMEZONE_IDS, JAVA_ZONE_IDS, JODA_TIMEZONE_IDS, logger, MIN_PRIVATE_PORT, 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected static org.elasticsearch.client.RestClient
Get the client used for test administrative actions.protected static boolean
aliasExists(String alias)
protected static boolean
aliasExists(String index, String alias)
static org.elasticsearch.client.RequestOptions
Deprecated.this method is only required while we deprecate types and can be removed in 8.0void
assertEmptyTranslog(String index)
Asserts that we do not retain any extra translog for the given index (i.e., turn off the translog retention)void
assertNoFileBasedRecovery(String indexName, Predicate<String> targetNode)
Asserts that replicas on nodes satisfying thetargetNode
should have perform operation-based recoveries.static void
assertOK(org.elasticsearch.client.Response response)
static String
basicAuthHeaderValue(String username, org.elasticsearch.common.settings.SecureString passwd)
Construct a Basic auth headerprotected org.elasticsearch.client.RestClient
buildClient(org.elasticsearch.common.settings.Settings settings, org.apache.http.HttpHost[] hosts)
protected org.apache.http.HttpHost
buildHttpHost(String host, int port)
Construct an HttpHost from the given host and portvoid
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
protected static void
closeIndex(String index)
protected static void
configureClient(org.elasticsearch.client.RestClientBuilder builder, org.elasticsearch.common.settings.Settings settings)
protected static void
createIndex(String name, org.elasticsearch.common.settings.Settings settings)
protected static void
createIndex(String name, org.elasticsearch.common.settings.Settings settings, String mapping)
protected static void
createIndex(String name, org.elasticsearch.common.settings.Settings settings, String mapping, String aliases)
protected static void
createSnapshot(String repository, String snapshot, boolean waitForCompletion)
protected static void
createSnapshot(org.elasticsearch.client.RestClient client, String repository, String snapshot, boolean waitForCompletion)
protected void
If any nodes are registered for shutdown, removes their metadata.protected static void
deleteIndex(String name)
protected static void
deleteIndex(org.elasticsearch.client.RestClient client, String name)
protected void
deleteRepository(String repoName)
protected static void
deleteSnapshot(String repository, String snapshot, boolean ignoreMissing)
protected static void
deleteSnapshot(org.elasticsearch.client.RestClient client, String repository, String snapshot, boolean ignoreMissing)
void
ensureGreen(String index)
checks that the specific index is green.static void
ensureHealth(String index, Consumer<org.elasticsearch.client.Request> requestConsumer)
protected static void
ensureHealth(Consumer<org.elasticsearch.client.Request> requestConsumer)
protected static void
ensureHealth(org.elasticsearch.client.RestClient client, String index, Consumer<org.elasticsearch.client.Request> requestConsumer)
protected static void
waits until all shard initialization is completed.void
Peer recovery retention leases are renewed and synced to replicas periodically (every 30 seconds).entityAsList(org.elasticsearch.client.Response response)
Convert the entity from aResponse
into a list of maps.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, String indexName)
protected static void
expectTranslogRetentionWarning(org.elasticsearch.client.Request request)
static org.elasticsearch.client.RequestOptions
expectVersionSpecificWarnings(Consumer<ESRestTestCase.VersionSensitiveWarningsHandler> expectationsSetter)
static org.elasticsearch.client.RequestOptions
expectWarnings(String... warnings)
Creates request options designed to be used when making a call that can return warnings, for example a deprecated request.void
protected List<org.apache.http.HttpHost>
Get the list of hosts in the cluster.protected String
Permits subclasses to increase the default timeout when waiting for green healthstatic Boolean
getIndexSettings(String index)
getIndexSettingsAsMap(String index)
protected String
Override this to switch to testing https.protected String
static boolean
hasXPack()
Does any node in the cluster being tested have x-pack installed?protected static boolean
indexExists(String index)
void
protected static boolean
protected static boolean
isXPackTemplate(String name)
Is this template one that is automatically created by xpack?protected static org.elasticsearch.Version
Returns the minimum node version among all nodes of the clusterprotected static void
protected static void
performSyncedFlush(String indexName, boolean retryOnConflict)
protected boolean
Returns whether to preserve auto-follow patterns.protected boolean
Controls whether or not to preserve cluster settings upon completion of the test.protected boolean
Returns whether to preserve the state of the cluster upon completion of this test.protected boolean
Determines if data streams are preserved upon completion of this test.protected boolean
Returns whether to preserve ILM Policies of this test.A set of ILM policies that should be preserved between runs.protected boolean
Returns whether to preserve the indices created during this test on completion of this test.protected boolean
Returns whether to preserve the repositories on completion of this test.protected boolean
Returns whether to preserve the rollup jobs of this test.protected boolean
Returns whether to preserve searchable snapshots indices.protected boolean
Returns whether to preserve SLM Policies of this test.protected boolean
Returns whether to preserve the snapshots in repositories on completion of this test.protected boolean
Controls whether or not to preserve templates upon completion of this test.protected void
protected static void
registerRepository(String repository, String type, boolean verify, org.elasticsearch.common.settings.Settings settings)
protected static void
registerRepository(org.elasticsearch.client.RestClient client, String repository, String type, boolean verify, org.elasticsearch.common.settings.Settings settings)
responseAsMap(org.elasticsearch.client.Response response)
protected org.elasticsearch.common.settings.Settings
Returns the REST client settings used for admin actions like cleaning up after the test has completed.protected org.elasticsearch.common.settings.Settings
Used to obtain settings for the REST client that is used to send REST requests.protected static void
restoreSnapshot(String repository, String snapshot, boolean waitForCompletion)
protected static void
updateIndexSettings(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
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, Predicate<String> taskFilter)
Wait for outstanding tasks to complete.protected static void
protected static void
protected void
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, createDefaultIndexAnalyzers, createParser, createParser, createParser, createParser, createParser, createParser, createTestAnalysis, createTestAnalysis, createTestAnalysis, enableJodaDeprecationWarningsCheck, enableWarningsCheck, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureSupportedLocale, filteredWarnings, frequently, generateRandomStringArray, generateRandomStringArray, getBasePort, getDataPath, getPortRange, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, inFipsJvm, iterations, maybeSet, mockScript, newEnvironment, newEnvironment, newNodeEnvironment, newNodeEnvironment, randomAlphaOfLength, randomAlphaOfLengthBetween, randomArray, randomArray, randomBigInteger, randomBoolean, randomByte, randomByteArrayOfLength, randomDateFormatterPattern, randomDateTimeZone, randomDouble, randomDoubleBetween, randomFloat, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomInt, randomInt, randomIntBetween, randomIp, randomList, randomList, randomLong, randomLongBetween, randomMap, randomMillisUpToYear9999, randomNonNegativeByte, randomNonNegativeLong, randomPositiveTimeValue, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomValueOtherThan, randomValueOtherThanMany, randomZone, removeHeaderWarningAppender, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, scaledRandomIntBetween, setContentType, setFileSystem, setHeaderWarningAppender, 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
- See Also:
- Constant Field Values
-
TRUSTSTORE_PASSWORD
- See Also:
- Constant Field Values
-
CERTIFICATE_AUTHORITIES
- See Also:
- Constant Field Values
-
CLIENT_CERT_PATH
- See Also:
- Constant Field Values
-
CLIENT_KEY_PATH
- See Also:
- Constant Field Values
-
CLIENT_KEY_PASSWORD
- See Also:
- Constant Field Values
-
CLIENT_SOCKET_TIMEOUT
- See Also:
- Constant Field Values
-
CLIENT_PATH_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ESRestTestCase
public ESRestTestCase()
-
-
Method Details
-
entityAsMap
public static Map<String,Object> entityAsMap(org.elasticsearch.client.Response response) throws IOExceptionConvert the entity from aResponse
into a map of maps.- Throws:
IOException
-
entityAsList
public static List<Object> entityAsList(org.elasticsearch.client.Response response) throws IOExceptionConvert the entity from aResponse
into a list of maps.- Throws:
IOException
-
hasXPack
public static boolean hasXPack()Does any node in the cluster being tested have x-pack installed? -
initClient
- Throws:
IOException
-
getTestRestCluster
-
expectVersionSpecificWarnings
public static org.elasticsearch.client.RequestOptions expectVersionSpecificWarnings(Consumer<ESRestTestCase.VersionSensitiveWarningsHandler> expectationsSetter) -
expectWarnings
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.
-
basicAuthHeaderValue
public static String basicAuthHeaderValue(String username, org.elasticsearch.common.settings.SecureString passwd)Construct a Basic auth header- Parameters:
username
- user namepasswd
- user password
-
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
Construct an HttpHost from the given host and port -
cleanUpCluster
Clean up after the test case.- Throws:
Exception
-
closeClients
- Throws:
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 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:
Exception
- if an exception is thrown while checking the outstanding tasks
-
waitForPendingTasks
public static void waitForPendingTasks(org.elasticsearch.client.RestClient adminClient, Predicate<String> taskFilter) throws 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:
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
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. -
preserveSearchableSnapshotsIndicesUponCompletion
protected boolean preserveSearchableSnapshotsIndicesUponCompletion()Returns whether to preserve searchable snapshots indices. 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. -
deleteAllNodeShutdownMetadata
If any nodes are registered for shutdown, removes their metadata.- Throws:
IOException
-
wipeAllIndices
- Throws:
IOException
-
wipeDataStreams
- Throws:
IOException
-
wipeSearchableSnapshotsIndices
- Throws:
IOException
-
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. 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:
IOException
-
deleteRepository
- Throws:
IOException
-
refreshAllIndices
- Throws:
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
Get the list of hosts in the cluster. -
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 IOException- Throws:
IOException
-
configureClient
protected static void configureClient(org.elasticsearch.client.RestClientBuilder builder, org.elasticsearch.common.settings.Settings settings) throws IOException- Throws:
IOException
-
assertOK
public static void assertOK(org.elasticsearch.client.Response response) -
getEnsureGreenTimeout
Permits subclasses to increase the default timeout when waiting for green health -
ensureGreen
checks 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:
IOException
-
ensureHealth
protected static void ensureHealth(Consumer<org.elasticsearch.client.Request> requestConsumer) throws IOException- Throws:
IOException
-
ensureHealth
public static void ensureHealth(String index, Consumer<org.elasticsearch.client.Request> requestConsumer) throws IOException- Throws:
IOException
-
ensureHealth
protected static void ensureHealth(org.elasticsearch.client.RestClient client, String index, Consumer<org.elasticsearch.client.Request> requestConsumer) throws IOException- Throws:
IOException
-
ensureNoInitializingShards
waits 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:
IOException
-
createIndex
protected static void createIndex(String name, org.elasticsearch.common.settings.Settings settings) throws IOException- Throws:
IOException
-
createIndex
protected static void createIndex(String name, org.elasticsearch.common.settings.Settings settings, String mapping) throws IOException- Throws:
IOException
-
createIndex
protected static void createIndex(String name, org.elasticsearch.common.settings.Settings settings, String mapping, String aliases) throws IOException- Throws:
IOException
-
deleteIndex
- Throws:
IOException
-
deleteIndex
protected static void deleteIndex(org.elasticsearch.client.RestClient client, String name) throws IOException- Throws:
IOException
-
updateIndexSettings
protected static void updateIndexSettings(String index, org.elasticsearch.common.settings.Settings.Builder settings) throws IOException- Throws:
IOException
-
expectSoftDeletesWarning
protected static void expectSoftDeletesWarning(org.elasticsearch.client.Request request, String indexName) -
expectTranslogRetentionWarning
protected static void expectTranslogRetentionWarning(org.elasticsearch.client.Request request) -
getIndexSettings
- Throws:
IOException
-
getIndexSettingsAsMap
- Throws:
IOException
-
indexExists
- Throws:
IOException
-
closeIndex
- Throws:
IOException
-
openIndex
- Throws:
IOException
-
aliasExists
- Throws:
IOException
-
aliasExists
- Throws:
IOException
-
getAlias
- Throws:
IOException
-
getAsMap
- Throws:
IOException
-
responseAsMap
protected static Map<String,Object> responseAsMap(org.elasticsearch.client.Response response) throws IOException- Throws:
IOException
-
registerRepository
protected static void registerRepository(String repository, String type, boolean verify, org.elasticsearch.common.settings.Settings settings) throws IOException- Throws:
IOException
-
registerRepository
protected static void registerRepository(org.elasticsearch.client.RestClient client, String repository, String type, boolean verify, org.elasticsearch.common.settings.Settings settings) throws IOException- Throws:
IOException
-
createSnapshot
protected static void createSnapshot(String repository, String snapshot, boolean waitForCompletion) throws IOException- Throws:
IOException
-
createSnapshot
protected static void createSnapshot(org.elasticsearch.client.RestClient client, String repository, String snapshot, boolean waitForCompletion) throws IOException- Throws:
IOException
-
restoreSnapshot
protected static void restoreSnapshot(String repository, String snapshot, boolean waitForCompletion) throws IOException- Throws:
IOException
-
deleteSnapshot
protected static void deleteSnapshot(String repository, String snapshot, boolean ignoreMissing) throws IOException- Throws:
IOException
-
deleteSnapshot
protected static void deleteSnapshot(org.elasticsearch.client.RestClient client, String repository, String snapshot, boolean ignoreMissing) throws IOException- Throws:
IOException
-
isXPackTemplate
Is this template one that is automatically created by xpack? -
flush
- Throws:
IOException
-
assertNoFileBasedRecovery
public void assertNoFileBasedRecovery(String indexName, Predicate<String> targetNode) throws IOExceptionAsserts that replicas on nodes satisfying thetargetNode
should have perform operation-based recoveries.- Throws:
IOException
-
assertEmptyTranslog
Asserts that we do not retain any extra translog for the given index (i.e., turn off the translog retention)- Throws:
Exception
-
ensurePeerRecoveryRetentionLeasesRenewedAndSynced
Peer 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:
Exception
-
getHasXPack
-
minimumNodeVersion
Returns the minimum node version among all nodes of the cluster- Throws:
IOException
-
performSyncedFlush
protected static void performSyncedFlush(String indexName, boolean retryOnConflict) throws Exception- Throws:
Exception
-
waitForActiveLicense
protected static void waitForActiveLicense(org.elasticsearch.client.RestClient restClient) throws 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:
Exception
- if an exception is thrown while checking the status of the license
-
useIgnoreMultipleMatchingTemplatesWarningsHandler
protected static void useIgnoreMultipleMatchingTemplatesWarningsHandler(org.elasticsearch.client.Request request) throws IOException- Throws:
IOException
-
isNotFoundResponseException
-