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:
JsonLogsIntegTestCase
Superclass for tests that interact with an external test cluster using Elasticsearch's
RestClient
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static 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.DeprecationWarning, ESTestCase.GeohashGenerator, ESTestCase.TestAnalysis, ESTestCase.WithoutSecurityManager
Nested 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.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 String
static final String
static final String
static final String
static final String
static final String
protected static TestFeatureService
static final String
static final String
Fields 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, SAFE_AWAIT_TIMEOUT, TEST_REQUEST_TIMEOUT, TEST_WORKER_SYS_PROPERTY, TEST_WORKER_VM_ID, UNSIGNED_LONG_MAX
Fields 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_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_THROTTLING, TEST_WEEKLY, VERBOSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<FeatureSpecification>
Override to provide additional test-only historical features.static void
addXContentBody
(Request request, org.elasticsearch.xcontent.ToXContent body) protected static RestClient
Get the client used for test administrative actions.protected static boolean
aliasExists
(String alias) protected static boolean
aliasExists
(String index, String alias) static void
assertAcknowledged
(Response response) static void
assertDocCount
(RestClient client, String indexName, long docCount) Assert that the index in question has the given number of documents presentvoid
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 Response
static void
assertOKAndConsume
(Response response) static ObjectPath
assertOKAndCreateObjectPath
(Response response) static String
basicAuthHeaderValue
(String username, SecureString passwd) Construct a Basic auth headerprotected RestClient
buildClient
(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 portfinal void
Clean up after the test case.protected static RestClient
client()
Get the client used for ordinary api calls while writing a teststatic void
protected static void
closeIndex
(String index) clusterHasCapability
(String method, String path, Collection<String> parameters, Collection<String> capabilities) Does the cluster being tested support the set of capabilities for specified path and method.clusterHasCapability
(RestClient client, String method, String path, Collection<String> parameters, Collection<String> capabilities) Does the cluster on the other side ofclient
support the set of capabilities for specified path and method.protected static boolean
clusterHasFeature
(String featureId) protected static boolean
clusterHasFeature
(NodeFeature feature) protected void
configureClient
(RestClientBuilder builder, Settings settings) Override this to configure the client with additional settings.protected static CreateIndexResponse
createIndex
(String name) protected static CreateIndexResponse
createIndex
(String name, Settings settings) protected static CreateIndexResponse
createIndex
(String name, Settings settings, String mapping) protected static CreateIndexResponse
createIndex
(String name, Settings settings, String mapping, String aliases) protected static CreateIndexResponse
createIndex
(RestClient client, String name, Settings settings) protected static CreateIndexResponse
createIndex
(RestClient client, String name, Settings settings, String mapping) static CreateIndexResponse
createIndex
(RestClient client, String name, Settings settings, String mapping, String aliases) protected static void
createSnapshot
(String repository, String snapshot, boolean waitForCompletion) protected static void
createSnapshot
(RestClient restClient, String repository, String snapshot, boolean waitForCompletion) protected final TestFeatureService
createTestFeatureService
(Map<String, Set<String>> clusterStateFeatures, Set<Version> semanticNodeVersions) protected void
If any nodes are registered for shutdown, removes their metadata.protected static AcknowledgedResponse
deleteIndex
(String name) protected static AcknowledgedResponse
deleteIndex
(RestClient restClient, String name) protected void
deleteRepository
(String repoName) protected static void
deleteSnapshot
(String repository, String snapshot, boolean ignoreMissing) protected static void
deleteSnapshot
(RestClient restClient, String repository, String snapshot, boolean ignoreMissing) protected static void
doConfigureClient
(RestClientBuilder builder, Settings settings) final void
ensureGreen
(String index) checks that the specific index is green.static void
ensureHealth
(String index, Consumer<Request> requestConsumer) protected static void
ensureHealth
(Consumer<Request> requestConsumer) protected static void
ensureHealth
(RestClient restClient, String index, Consumer<Request> requestConsumer) static void
ensureHealth
(RestClient restClient, Consumer<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
(Response response) Convert the entity from aResponse
into a list of maps.entityAsMap
(org.apache.http.HttpEntity entity) Convert the entity from aResponse
into a map of maps.entityAsMap
(Response response) Convert the entity from aResponse
into a map of maps.protected static void
expectSoftDeletesWarning
(Request request, String indexName) static RequestOptions
expectVersionSpecificWarnings
(Consumer<ESRestTestCase.VersionSensitiveWarningsHandler> expectationsSetter) static RequestOptions
expectWarnings
(String... warnings) Creates request options designed to be used when making a call that can return warnings, for example a deprecated request.protected FieldCapabilitiesResponse
fieldCaps
(List<String> indices, List<String> fields, QueryBuilder indexFilter, String fieldTypes, String fieldFilters) protected FieldCapabilitiesResponse
fieldCaps
(RestClient restClient, List<String> indices, List<String> fields, QueryBuilder indexFilter, String fieldTypes, String fieldFilters) void
getAsMap
(RestClient client, String endpoint) getAsOrderedMap
(String endpoint) protected final List<org.apache.http.HttpHost>
Get the list of hosts in the cluster.getClusterStateFeatures
(RestClient adminClient) protected String
Permits subclasses to increase the default timeout when waiting for green healthgetIndexMapping
(String index) getIndexMappingAsMap
(String index) getIndexSettings
(String index) getIndexSettingsAsMap
(String index) getNodesInfo
(RestClient adminClient) protected String
Override this to switch to testing https.protected String
protected String
protected static TransportVersion
getTransportVersionWithFallback
(String versionField, Object transportVersionField, Supplier<TransportVersion> fallbackSupplier) protected static boolean
has
(ESRestTestCase.ProductFeature feature) 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 IndexVersion
Returns the minimum index version among all nodes of the clusterprotected static TransportVersion
Returns the minimum transport version among all nodes of the clusterstatic Request
newXContentRequest
(io.netty.handler.codec.http.HttpMethod method, String endpoint, org.elasticsearch.xcontent.ToXContent body) protected static void
protected List<org.apache.http.HttpHost>
parseClusterHosts
(String hostsString) parseLegacyVersion
(String version) 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 the security indices created during this test on completion of this test.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.readVersionsFromNodesInfo
(RestClient adminClient) protected static BroadcastResponse
protected static BroadcastResponse
refresh
(RestClient client, String index) protected void
protected static void
registerRepository
(String repository, String type, boolean verify, Settings settings) protected static void
registerRepository
(RestClient restClient, String repository, String type, boolean verify, Settings settings) protected boolean
Determines whether the system feature reset API should be invoked between tests.protected static BytesReference
responseAsBytes
(Response response) responseAsMap
(Response response) responseAsOrderedMap
(Response response) static org.elasticsearch.xcontent.XContentParser
responseAsParser
(Response response) protected Settings
Returns the REST client settings used for admin actions like cleaning up after the test has completed.protected 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) static void
setIgnoredErrorResponseCodes
(Request request, RestStatus... restStatuses) protected static boolean
static void
updateClusterSettings
(RestClient client, Settings settings) Updates the cluster with the provided settings (as persistent settings)static void
updateClusterSettings
(Settings settings) Updates the cluster with the provided settings (as persistent settings)protected static void
updateIndexSettings
(String index, Settings.Builder settings) protected static void
protected static void
waitForActiveLicense
(RestClient restClient) Wait for the license to be applied and active.static void
waitForPendingTasks
(RestClient restClient) Wait for outstanding tasks to complete.static void
waitForPendingTasks
(RestClient restClient, Predicate<String> taskFilter) Wait for outstanding tasks to complete.protected static void
protected static void
wipeAllIndices
(boolean preserveSecurityIndices) protected static void
protected 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, allBreakersMemoryReleased, asInstanceOf, assertArrayEquals, assertBusy, assertBusy, assertCriticalWarnings, assertEquals, assertLeakDetected, assertSettingDeprecationsAndWarnings, assertThat, assertThat, assertWarnings, assertWarnings, before, between, buildEnvSettings, buildNewFakeTransportAddress, checkStaticState, compatibleMediaType, copyInstance, copyNamedWriteable, copyNamedWriteable, copyWriteable, copyWriteable, createDefaultIndexAnalyzers, createParser, createParser, createParser, createParser, createParser, createParser, createParserWithCompatibilityFor, createTestAnalysis, createTestAnalysis, createTestAnalysis, createThreadPool, enableBigArraysReleasedCheck, enableWarningsCheck, ensureAllContextsReleased, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureNoWarnings, ensureSupportedLocale, expectThrows, expectThrows, fail, fail, filteredWarnings, flushThreadPoolExecutor, frequently, generateRandomStringArray, generateRandomStringArray, getDataPath, getPortRange, getResourceDataPath, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, getWorkerBasePort, indexSettings, indexSettings, inFipsJvm, isTurkishLocale, iterations, maybeRestoreClassSecurityManager, maybeSet, maybeStashClassSecurityManager, mockScript, newEnvironment, newEnvironment, newLimitedBreaker, newNodeEnvironment, newNodeEnvironment, parserConfig, randomAlphaOfLength, randomAlphaOfLengthBetween, randomArray, randomArray, randomBigInteger, randomBoolean, randomByte, randomByteArrayOfLength, randomByteBetween, randomBytesBetween, randomByteSizeValue, randomBytesReference, randomCompatibleMediaType, randomDateFormatterPattern, randomDouble, randomDoubleBetween, randomDoubles, randomDoubles, randomExecutor, randomFloat, randomFloatBetween, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomIdentifier, randomInstantBetween, randomInt, randomInt, randomIntBetween, randomInts, randomInts, randomIp, randomList, randomList, randomLong, randomLongBetween, randomLongs, randomLongs, randomMap, randomMillisUpToYear9999, randomNegativeInt, randomNonEmptySubsetOf, randomNonNegativeByte, randomNonNegativeInt, randomNonNegativeLong, randomNullOrAlphaOfLength, randomOptionalBoolean, randomPositiveTimeValue, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomSecureStringOfLength, randomSet, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomUnsignedLongBetween, randomUUID, randomValueOtherThan, randomValueOtherThanMany, randomVendorType, randomZone, removeHeaderWarningAppender, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, runInParallel, safeAcquire, safeAcquire, safeAwait, safeAwait, safeAwait, safeAwait, safeAwaitAndUnwrapFailure, safeAwaitFailure, safeAwaitFailure, safeAwaitFailure, safeAwaitFailure, safeExecute, safeGet, safeGet, safeSleep, safeSleep, scaledRandomIntBetween, secureRandom, secureRandom, secureRandomFips, secureRandomFips, secureRandomNonFips, secureRandomNonFips, setContentType, setFileSystem, setHeaderWarningAppender, settings, shuffledList, shuffleMap, shuffleXContent, shuffleXContent, skipTestWaitingForLuceneFix, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, startInParallel, terminate, terminate, tmpPaths, toShuffledXContent, waitUntil, waitUntil, writableRegistry, xContentRegistry
Methods inherited from class org.apache.lucene.tests.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertDoubleUlpEquals, assertFieldInfosEquals, assertFloatUlpEquals, 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, getJvmForkArguments, 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, newSnapshotIndexWriterConfig, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, randomVectorFormat, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setUp, setupCPUCoreCount, setUpExecutorService, shutdownExecutorService, 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, assertThrows, assertThrows, 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:
-
testFeatureService
-
-
Constructor Details
-
ESRestTestCase
public ESRestTestCase()
-
-
Method Details
-
entityAsMap
Convert the entity from aResponse
into a map of maps. Consumes the underlying HttpEntity, releasing any resources it may be holding.- Throws:
IOException
-
entityAsMap
Convert the entity from aResponse
into a map of maps. Consumes the underlying HttpEntity, releasing any resources it may be holding.- Throws:
IOException
-
entityAsList
Convert the entity from aResponse
into a list of maps. Consumes the underlying HttpEntity, releasing any resources it may be holding.- Throws:
IOException
-
hasXPack
public static boolean hasXPack()Does any node in the cluster being tested have x-pack installed? -
getCachedNodesVersions
-
readVersionsFromNodesInfo
- Throws:
IOException
-
getNodesInfo
- Throws:
IOException
-
clusterHasCapability
protected static Optional<Boolean> clusterHasCapability(String method, String path, Collection<String> parameters, Collection<String> capabilities) throws IOException Does the cluster being tested support the set of capabilities for specified path and method.- Throws:
IOException
-
clusterHasCapability
protected static Optional<Boolean> clusterHasCapability(RestClient client, String method, String path, Collection<String> parameters, Collection<String> capabilities) throws IOException Does the cluster on the other side ofclient
support the set of capabilities for specified path and method.- Throws:
IOException
-
clusterHasFeature
-
clusterHasFeature
-
testFeatureServiceInitialized
protected static boolean testFeatureServiceInitialized() -
initClient
- Throws:
IOException
-
additionalTestOnlyHistoricalFeatures
Override to provide additional test-only historical features. Note: This extension point cannot be used to add cluster features. The providedFeatureSpecification
s must contain only historical features, otherwise an assertion error is thrown. -
createTestFeatureService
-
has
-
parseClusterHosts
-
getTestRestCluster
-
getTestReadinessPorts
-
expectVersionSpecificWarnings
public static 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 on the current version and will allow (but not require) the warnings if any node is running an older version.- Parameters:
warnings
- The expected warnings.
-
basicAuthHeaderValue
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
Get the client used for ordinary api calls while writing a test -
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
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(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. In addition to the expected tasks that are defined by the filter we expect the list task to be there since it is created by the call and the health node task which is always running on the background.- 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). -
preserveSecurityIndicesUponCompletion
protected boolean preserveSecurityIndicesUponCompletion()Returns whether to preserve the security indices created during this test on completion of this test. Defaults tofalse
. Override this method if security 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 security entities need to be preserved between test runs -
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
-
resetFeatureStates
protected boolean resetFeatureStates()Determines whether the system feature reset API should be invoked between tests. The default implementation is to reset all feature states, deleting system indices, system associated indices, and system data streams. -
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. -
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. -
deleteAllNodeShutdownMetadata
If any nodes are registered for shutdown, removes their metadata.- Throws:
IOException
-
wipeAllIndices
- 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.- Throws:
IOException
-
deleteRepository
- Throws:
IOException
-
refreshAllIndices
- Throws:
IOException
-
refresh
- Throws:
IOException
-
refresh
- Throws:
IOException
-
restClientSettings
Used to obtain settings for the REST client that is used to send REST requests. -
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 RestClient buildClient(Settings settings, org.apache.http.HttpHost[] hosts) throws IOException - Throws:
IOException
-
configureClient
Override this to configure the client with additional settings.- Throws:
IOException
-
doConfigureClient
protected static void doConfigureClient(RestClientBuilder builder, Settings settings) throws IOException - Throws:
IOException
-
assertOK
-
assertOKAndConsume
-
assertOKAndCreateObjectPath
- Throws:
IOException
-
assertDocCount
public static void assertDocCount(RestClient client, String indexName, long docCount) throws IOException Assert that the index in question has the given number of documents present- Throws:
IOException
-
assertAcknowledged
- Throws:
IOException
-
updateClusterSettings
Updates the cluster with the provided settings (as persistent settings)- Throws:
IOException
-
updateClusterSettings
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
- Throws:
IOException
-
ensureHealth
- Throws:
IOException
-
ensureHealth
public static void ensureHealth(RestClient restClient, Consumer<Request> requestConsumer) throws IOException - Throws:
IOException
-
ensureHealth
protected static void ensureHealth(RestClient restClient, String index, Consumer<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
- Throws:
IOException
-
createIndex
- Throws:
IOException
-
createIndex
protected static CreateIndexResponse createIndex(RestClient client, String name, Settings settings) throws IOException - Throws:
IOException
-
createIndex
protected static CreateIndexResponse createIndex(RestClient client, String name, Settings settings, String mapping) throws IOException - Throws:
IOException
-
createIndex
protected static CreateIndexResponse createIndex(String name, Settings settings, String mapping) throws IOException - Throws:
IOException
-
createIndex
protected static CreateIndexResponse createIndex(String name, Settings settings, String mapping, String aliases) throws IOException - Throws:
IOException
-
createIndex
public static CreateIndexResponse createIndex(RestClient client, String name, Settings settings, String mapping, String aliases) throws IOException - Throws:
IOException
-
deleteIndex
- Throws:
IOException
-
deleteIndex
protected static AcknowledgedResponse deleteIndex(RestClient restClient, String name) throws IOException - Throws:
IOException
-
updateIndexSettings
protected static void updateIndexSettings(String index, Settings.Builder settings) throws IOException - Throws:
IOException
-
expectSoftDeletesWarning
protected static void expectSoftDeletesWarning(Request request, String indexName) throws IOException - Throws:
IOException
-
getIndexSettings
- Throws:
IOException
-
getIndexSettingsAsMap
- Throws:
IOException
-
getIndexMapping
- Throws:
IOException
-
getIndexMappingAsMap
- Throws:
IOException
-
indexExists
- Throws:
IOException
-
closeIndex
- Throws:
IOException
-
openIndex
- Throws:
IOException
-
aliasExists
- Throws:
IOException
-
aliasExists
- Throws:
IOException
-
getAlias
- Throws:
IOException
-
getAsMap
- Throws:
IOException
-
getAsOrderedMap
- Throws:
IOException
-
getAsMap
- Throws:
IOException
-
responseAsMap
- Throws:
IOException
-
responseAsOrderedMap
- Throws:
IOException
-
responseAsParser
public static org.elasticsearch.xcontent.XContentParser responseAsParser(Response response) throws IOException - Throws:
IOException
-
responseAsBytes
- Throws:
IOException
-
registerRepository
protected static void registerRepository(String repository, String type, boolean verify, Settings settings) throws IOException - Throws:
IOException
-
registerRepository
protected static void registerRepository(RestClient restClient, String repository, String type, boolean verify, 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(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(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 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
-
getClusterStateFeatures
protected static Map<String,Set<String>> getClusterStateFeatures(RestClient adminClient) throws IOException - Throws:
IOException
-
minimumIndexVersion
Returns the minimum index version among all nodes of the cluster- Throws:
IOException
-
minimumTransportVersion
Returns the minimum transport version among all nodes of the cluster- Throws:
IOException
-
getTransportVersionWithFallback
protected static TransportVersion getTransportVersionWithFallback(String versionField, Object transportVersionField, Supplier<TransportVersion> fallbackSupplier) -
parseLegacyVersion
-
waitForActiveLicense
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(Request request) throws IOException - Throws:
IOException
-
isNotFoundResponseException
-
fieldCaps
protected FieldCapabilitiesResponse fieldCaps(List<String> indices, List<String> fields, QueryBuilder indexFilter, String fieldTypes, String fieldFilters) throws IOException - Throws:
IOException
-
fieldCaps
protected FieldCapabilitiesResponse fieldCaps(RestClient restClient, List<String> indices, List<String> fields, QueryBuilder indexFilter, String fieldTypes, String fieldFilters) throws IOException - Throws:
IOException
-
setIgnoredErrorResponseCodes
-
addXContentBody
public static void addXContentBody(Request request, org.elasticsearch.xcontent.ToXContent body) throws IOException - Throws:
IOException
-
newXContentRequest
public static Request newXContentRequest(io.netty.handler.codec.http.HttpMethod method, String endpoint, org.elasticsearch.xcontent.ToXContent body) throws IOException - Throws:
IOException
-