Package org.elasticsearch.test.rest
Class ESRestTestCase
java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.test.rest.ESRestTestCase
- Direct Known Subclasses:
AbstractFullClusterRestartTestCase,JsonLogsIntegTestCase
Superclass for tests that interact with an external test cluster using Elasticsearch's
RestClient.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHelper 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.DeprecationWarning, ESTestCase.GeohashGenerator, ESTestCase.TestAnalysisNested classes/interfaces inherited from class org.apache.lucene.tests.util.LuceneTestCase
org.apache.lucene.tests.util.LuceneTestCase.AwaitsFix, org.apache.lucene.tests.util.LuceneTestCase.BadApple, org.apache.lucene.tests.util.LuceneTestCase.Monster, org.apache.lucene.tests.util.LuceneTestCase.Nightly, org.apache.lucene.tests.util.LuceneTestCase.Slow, org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.tests.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.tests.util.LuceneTestCase.SuppressFsync, org.apache.lucene.tests.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.tests.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.tests.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.tests.util.LuceneTestCase.ThrowingConsumer<T extends Object>, org.apache.lucene.tests.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.tests.util.LuceneTestCase.Weekly -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.elasticsearch.test.ESTestCase
checkIndexFailures, DEFAULT_TEST_WORKER_ID, failureAndSuccessEvents, FIPS_SYSPROP, JAVA_TIMEZONE_IDS, JAVA_ZONE_IDS, logger, MIN_PRIVATE_PORT, TEST_WORKER_SYS_PROPERTY, TEST_WORKER_VM_IDFields inherited from class org.apache.lucene.tests.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.RestClientGet the client used for test administrative actions.protected static booleanaliasExists(String alias) protected static booleanaliasExists(String index, String alias) static voidassertAcknowledged(org.elasticsearch.client.Response response) voidassertEmptyTranslog(String index) Asserts that we do not retain any extra translog for the given index (i.e., turn off the translog retention)voidassertNoFileBasedRecovery(String indexName, Predicate<String> targetNode) Asserts that replicas on nodes satisfying thetargetNodeshould have perform operation-based recoveries.static voidassertOK(org.elasticsearch.client.Response response) static StringbasicAuthHeaderValue(String username, org.elasticsearch.common.settings.SecureString passwd) Construct a Basic auth headerprotected org.elasticsearch.client.RestClientbuildClient(org.elasticsearch.common.settings.Settings settings, org.apache.http.HttpHost[] hosts) protected org.apache.http.HttpHostbuildHttpHost(String host, int port) Construct an HttpHost from the given host and portfinal voidClean up after the test case.protected static org.elasticsearch.client.RestClientclient()Get the client used for ordinary api calls while writing a teststatic voidprotected static voidcloseIndex(String index) protected static voidconfigureClient(org.elasticsearch.client.RestClientBuilder builder, org.elasticsearch.common.settings.Settings settings) protected static voidcreateIndex(String name, org.elasticsearch.common.settings.Settings settings) protected static voidcreateIndex(String name, org.elasticsearch.common.settings.Settings settings, String mapping) protected static voidcreateIndex(String name, org.elasticsearch.common.settings.Settings settings, String mapping, String aliases) protected static voidcreateSnapshot(String repository, String snapshot, boolean waitForCompletion) protected static voidcreateSnapshot(org.elasticsearch.client.RestClient restClient, String repository, String snapshot, boolean waitForCompletion) protected voidIf any nodes are registered for shutdown, removes their metadata.protected static voiddeleteIndex(String name) protected static voiddeleteIndex(org.elasticsearch.client.RestClient restClient, String name) protected voiddeleteRepository(String repoName) protected static voiddeleteSnapshot(String repository, String snapshot, boolean ignoreMissing) protected static voiddeleteSnapshot(org.elasticsearch.client.RestClient restClient, String repository, String snapshot, boolean ignoreMissing) final voidensureGreen(String index) checks that the specific index is green.static voidensureHealth(String index, Consumer<org.elasticsearch.client.Request> requestConsumer) protected static voidensureHealth(Consumer<org.elasticsearch.client.Request> requestConsumer) protected static voidensureHealth(org.elasticsearch.client.RestClient restClient, String index, Consumer<org.elasticsearch.client.Request> requestConsumer) static voidensureHealth(org.elasticsearch.client.RestClient restClient, Consumer<org.elasticsearch.client.Request> requestConsumer) protected static voidwaits until all shard initialization is completed.voidPeer recovery retention leases are renewed and synced to replicas periodically (every 30 seconds).entityAsList(org.elasticsearch.client.Response response) Convert the entity from aResponseinto a list of maps.entityAsMap(org.elasticsearch.client.Response response) Convert the entity from aResponseinto a map of maps.protected static voidexpectSoftDeletesWarning(org.elasticsearch.client.Request request, String indexName) static org.elasticsearch.client.RequestOptionsexpectVersionSpecificWarnings(Consumer<ESRestTestCase.VersionSensitiveWarningsHandler> expectationsSetter) static org.elasticsearch.client.RequestOptionsexpectWarnings(String... warnings) Creates request options designed to be used when making a call that can return warnings, for example a deprecated request.protected org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponsefieldCaps(List<String> indices, List<String> fields, org.elasticsearch.index.query.QueryBuilder indexFilter, String fieldTypes, String fieldFilters) protected org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponsefieldCaps(org.elasticsearch.client.RestClient restClient, List<String> indices, List<String> fields, org.elasticsearch.index.query.QueryBuilder indexFilter, String fieldTypes, String fieldFilters) voidprotected final List<org.apache.http.HttpHost>Get the list of hosts in the cluster.protected StringPermits subclasses to increase the default timeout when waiting for green healthgetIndexSettings(String index) getIndexSettingsAsMap(String index) protected StringOverride this to switch to testing https.protected Stringprotected Stringstatic booleanhasXPack()Does any node in the cluster being tested have x-pack installed?protected static booleanindexExists(String index) voidprotected static booleanprotected static booleanisXPackTemplate(String name) Is this template one that is automatically created by xpack?protected static org.elasticsearch.VersionReturns the minimum node version among all nodes of the clusterprotected static voidprotected booleanReturns whether to preserve auto-follow patterns.protected booleanControls whether or not to preserve cluster settings upon completion of the test.protected booleanReturns whether to preserve the state of the cluster upon completion of this test.protected booleanDetermines if data streams are preserved upon completion of this test.protected booleanReturns whether to preserve ILM Policies of this test.A set of ILM policies that should be preserved between runs.protected booleanReturns whether to preserve the indices created during this test on completion of this test.protected booleanReturns whether to preserve the repositories on completion of this test.protected booleanReturns whether to preserve the rollup jobs of this test.protected booleanReturns whether to preserve searchable snapshots indices.protected booleanReturns whether to preserve SLM Policies of this test.protected booleanReturns whether to preserve the snapshots in repositories on completion of this test.protected booleanControls whether or not to preserve templates upon completion of this test.protected voidprotected static voidregisterRepository(String repository, String type, boolean verify, org.elasticsearch.common.settings.Settings settings) protected static voidregisterRepository(org.elasticsearch.client.RestClient restClient, String repository, String type, boolean verify, org.elasticsearch.common.settings.Settings settings) responseAsMap(org.elasticsearch.client.Response response) protected org.elasticsearch.common.settings.SettingsReturns the REST client settings used for admin actions like cleaning up after the test has completed.protected org.elasticsearch.common.settings.SettingsUsed to obtain settings for the REST client that is used to send REST requests.protected static voidrestoreSnapshot(String repository, String snapshot, boolean waitForCompletion) static voidupdateClusterSettings(org.elasticsearch.client.RestClient client, org.elasticsearch.common.settings.Settings settings) Updates the cluster with the provided settings (as persistent settings)static voidupdateClusterSettings(org.elasticsearch.common.settings.Settings settings) Updates the cluster with the provided settings (as persistent settings)protected static voidupdateIndexSettings(String index, org.elasticsearch.common.settings.Settings.Builder settings) protected static voiduseIgnoreMultipleMatchingTemplatesWarningsHandler(org.elasticsearch.client.Request request) protected static voidwaitForActiveLicense(org.elasticsearch.client.RestClient restClient) Wait for the license to be applied and active.protected booleanReturns whether to wait to make absolutely certain that all snapshots have been deleted.static voidwaitForPendingTasks(org.elasticsearch.client.RestClient restClient) Wait for outstanding tasks to complete.static voidwaitForPendingTasks(org.elasticsearch.client.RestClient restClient, Predicate<String> taskFilter) Wait for outstanding tasks to complete.protected static voidprotected static voidprotected voidWipe 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, assertArrayEquals, assertBusy, assertBusy, assertCriticalWarnings, assertEquals, assertSettingDeprecationsAndWarnings, assertWarnings, assertWarnings, before, between, buildEnvSettings, buildNewFakeTransportAddress, checkStaticState, compatibleMediaType, copyInstance, copyNamedWriteable, copyNamedWriteable, copyWriteable, copyWriteable, createDefaultIndexAnalyzers, createParser, createParser, createParser, createParser, createParser, createParser, createParserWithCompatibilityFor, createTestAnalysis, createTestAnalysis, createTestAnalysis, enableWarningsCheck, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureNoWarnings, ensureSupportedLocale, filteredWarnings, frequently, generateRandomStringArray, generateRandomStringArray, getDataPath, getPortRange, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, getWorkerBasePort, inFipsJvm, iterations, maybeSet, mockScript, newEnvironment, newEnvironment, newNodeEnvironment, newNodeEnvironment, parserConfig, randomAlphaOfLength, randomAlphaOfLengthBetween, randomArray, randomArray, randomBigInteger, randomBoolean, randomByte, randomByteArrayOfLength, randomCompatibleMediaType, randomDateFormatterPattern, randomDouble, randomDoubleBetween, randomFloat, randomFrom, 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, randomVendorType, randomZone, removeHeaderWarningAppender, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, scaledRandomIntBetween, setContentType, setFileSystem, setHeaderWarningAppender, settings, shuffleMap, shuffleXContent, shuffleXContent, skipTestWaitingForLuceneFix, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, terminate, terminate, tmpPaths, toShuffledXContent, waitUntil, waitUntil, writableRegistry, xContentRegistryMethods inherited from class org.apache.lucene.tests.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, getDataInputStream, getOnlyLeafReader, getTestClass, getTestName, hasWorkingMMapOnWindows, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, 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, newSearcher, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setUp, setupCPUCoreCount, slowFileExists, tearDown, usually, usually, wrapReaderMethods 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:
-
TRUSTSTORE_PASSWORD
- See Also:
-
CERTIFICATE_AUTHORITIES
- See Also:
-
CLIENT_CERT_PATH
- See Also:
-
CLIENT_KEY_PATH
- See Also:
-
CLIENT_KEY_PASSWORD
- See Also:
-
CLIENT_SOCKET_TIMEOUT
- See Also:
-
CLIENT_PATH_PREFIX
- See Also:
-
-
Constructor Details
-
ESRestTestCase
public ESRestTestCase()
-
-
Method Details
-
entityAsMap
public static Map<String,Object> entityAsMap(org.elasticsearch.client.Response response) throws IOException Convert the entity from aResponseinto a map of maps.- Throws:
IOException
-
entityAsList
public static List<Object> entityAsList(org.elasticsearch.client.Response response) throws IOException Convert the entity from aResponseinto 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
-
getTestReadinessPorts
-
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.CURRENTand 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
-
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 restClient) throws Exception Wait 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:
restClient- the admin client- Throws:
Exception- if an exception is thrown while checking the outstanding tasks
-
waitForPendingTasks
public static void waitForPendingTasks(org.elasticsearch.client.RestClient restClient, Predicate<String> taskFilter) throws Exception Wait 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:
restClient- 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 forfsrepositories. -
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. -
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. -
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. -
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) -
assertAcknowledged
public static void assertAcknowledged(org.elasticsearch.client.Response response) throws IOException - Throws:
IOException
-
updateClusterSettings
public static void updateClusterSettings(org.elasticsearch.common.settings.Settings settings) throws IOException Updates the cluster with the provided settings (as persistent settings)- Throws:
IOException
-
updateClusterSettings
public static void updateClusterSettings(org.elasticsearch.client.RestClient client, org.elasticsearch.common.settings.Settings settings) throws IOException Updates the cluster with the provided settings (as persistent settings)- Throws:
IOException
-
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
public static void ensureHealth(org.elasticsearch.client.RestClient restClient, Consumer<org.elasticsearch.client.Request> requestConsumer) throws IOException - Throws:
IOException
-
ensureHealth
protected static void ensureHealth(org.elasticsearch.client.RestClient restClient, 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 restClient, 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) -
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
-
getAsMap
protected static Map<String,Object> getAsMap(org.elasticsearch.client.RestClient client, String endpoint) throws IOException - 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 restClient, 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 restClient, 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 restClient, 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 IOException Asserts that replicas on nodes satisfying thetargetNodeshould 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
-
minimumNodeVersion
Returns the minimum node version among all nodes of the cluster- Throws:
IOException
-
waitForActiveLicense
protected static void waitForActiveLicense(org.elasticsearch.client.RestClient restClient) throws Exception Wait 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
-
fieldCaps
protected org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse fieldCaps(List<String> indices, List<String> fields, org.elasticsearch.index.query.QueryBuilder indexFilter, String fieldTypes, String fieldFilters) throws IOException - Throws:
IOException
-
fieldCaps
protected org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse fieldCaps(org.elasticsearch.client.RestClient restClient, List<String> indices, List<String> fields, org.elasticsearch.index.query.QueryBuilder indexFilter, String fieldTypes, String fieldFilters) throws IOException - Throws:
IOException
-