Class AggregatorTestCase
java.lang.Object
org.junit.Assert
org.apache.lucene.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.search.aggregations.AggregatorTestCase
Base class for testing
Aggregator
implementations.
Provides helpers for constructing and searching an Aggregator
implementation based on a provided
AggregationBuilder
instance.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Nested classes/interfaces inherited from class org.elasticsearch.test.ESTestCase
ESTestCase.DeprecationWarning, ESTestCase.GeohashGenerator, ESTestCase.TestAnalysis
Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase
LuceneTestCase.AwaitsFix, LuceneTestCase.BadApple, LuceneTestCase.Monster, LuceneTestCase.Nightly, LuceneTestCase.Slow, LuceneTestCase.SuppressCodecs, LuceneTestCase.SuppressFileSystems, LuceneTestCase.SuppressFsync, LuceneTestCase.SuppressReproduceLine, LuceneTestCase.SuppressSysoutChecks, LuceneTestCase.SuppressTempFileChecks, LuceneTestCase.ThrowingRunnable, LuceneTestCase.Weekly
-
Field Summary
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Hook for checking things after allAggregator
s have been closed.static AggregationBuilder
Request an aggregation that returns theCardinalityUpperBound
that was passed to its ctor.protected FieldMapper
Build aFieldMapper
to create theMappingLookup
used for the aggs.void
protected AggregationBuilder
createAggBuilderForTypeTest
(MappedFieldType fieldType, String fieldName) This method is invoked each time a field type is tested intestSupportedFieldTypes()
.protected AggregationContext
createAggregationContext
(org.apache.lucene.search.IndexSearcher indexSearcher, org.apache.lucene.search.Query query, MappedFieldType... fieldTypes) Create a AggregationContext for testing anAggregator
.protected AggregationContext
createAggregationContext
(org.apache.lucene.search.IndexSearcher indexSearcher, IndexSettings indexSettings, org.apache.lucene.search.Query query, CircuitBreakerService breakerService, long bytesToPreallocate, int maxBucket, MappedFieldType... fieldTypes) Create a AggregationContext for testing anAggregator
.protected <A extends Aggregator>
AcreateAggregator
(AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher searcher, MappedFieldType... fieldTypes) protected <A extends Aggregator>
AcreateAggregator
(AggregationBuilder builder, AggregationContext context) protected AnalysisModule
protected IndexSettings
protected DateFieldMapper.DateFieldType
dateField
(String name, DateFieldMapper.Resolution resolution) Make a DateFieldMapper.DateFieldType for adate
.protected <R extends InternalAggregation>
voiddebugTestCase
(AggregationBuilder builder, org.apache.lucene.search.Query query, org.apache.lucene.search.IndexSearcher searcher, TriConsumer<R, Class<? extends Aggregator>, Map<String, Map<String, Object>>> verify, MappedFieldType... fieldTypes) Execute and aggregation and collect itsdebug
information.protected <R extends InternalAggregation>
voiddebugTestCase
(AggregationBuilder builder, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, TriConsumer<R, Class<? extends Aggregator>, Map<String, Map<String, Object>>> verify, MappedFieldType... fieldTypes) Execute and aggregation and collect itsdebug
information.protected void
doAssertReducedMultiBucketConsumer
(Aggregation agg, MultiBucketConsumerService.MultiBucketConsumer bucketConsumer) protected NumberFieldMapper.NumberFieldType
doubleField
(String name) Make a NumberFieldMapper.NumberFieldType for adouble
.protected GeoPointFieldMapper.GeoPointFieldType
geoPointField
(String name) Make a GeoPointFieldMapper.GeoPointFieldType for ageo_point
.protected ScriptService
Sub-tests that need scripting can override this method to provide a script service and pre-baked scriptsprotected List<SearchPlugin>
Test cases should override this if they have plugins that need to be loaded, e.g.protected List<ValuesSourceType>
Implementors should return a list ofValuesSourceType
that the aggregator supports.void
final void
protected KeywordFieldMapper.KeywordFieldType
keywordField
(String name) Make a DateFieldMapper.DateFieldType for adate
.protected NumberFieldMapper.NumberFieldType
Make a NumberFieldMapper.NumberFieldType for along
.protected static IndexReader
maybeWrapReaderEs
(DirectoryReader reader) Added to randomly run with more assertions on the index reader level, likeLuceneTestCase.wrapReader(IndexReader)
, which can't be used because it also wraps in the IndexReader with other implementations that we can't handle.protected static org.apache.lucene.search.IndexSearcher
newIndexSearcher
(IndexReader indexReader) Added to randomly run with more assertions on the index searcher level, likeLuceneTestCase.newSearcher(IndexReader)
, which can't be used because it also wraps in the IndexSearcher's IndexReader with other implementations that we can't handle.protected List<ObjectMapper>
ObjectMapper
s to add to the lookup.protected RangeFieldMapper.RangeFieldType
rangeField
(String name, RangeType rangeType) Make a NumberFieldMapper.NumberFieldType for arange
.protected <A extends InternalAggregation,
C extends Aggregator>
AsearchAndReduce
(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, int maxBucket, MappedFieldType... fieldTypes) protected <A extends InternalAggregation,
C extends Aggregator>
AsearchAndReduce
(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, MappedFieldType... fieldTypes) protected <A extends InternalAggregation,
C extends Aggregator>
AsearchAndReduce
(IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, int maxBucket, boolean splitLeavesIntoSeparateAggregators, MappedFieldType... fieldTypes) Collects all documents that match the provided queryQuery
and returns the reducedInternalAggregation
.protected <A extends InternalAggregation,
C extends Aggregator>
AsearchAndReduce
(IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, int maxBucket, MappedFieldType... fieldTypes) Collects all documents that match the provided queryQuery
and returns the reducedInternalAggregation
.protected <A extends InternalAggregation,
C extends Aggregator>
AsearchAndReduce
(IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, MappedFieldType... fieldTypes) protected <T extends AggregationBuilder,
V extends InternalAggregation>
voidtestCase
(T aggregationBuilder, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, Consumer<V> verify, MappedFieldType... fieldTypes) void
This test will validate that an aggregator succeeds or fails to run against all the field types that are registered inIndicesModule
(e.g.A method that allows implementors to specifically blacklist particular field types (based on their content_name).protected <T extends AggregationBuilder,
V extends InternalAggregation>
voidverifyOutputFieldNames
(T aggregationBuilder, V agg) protected void
withAggregator
(AggregationBuilder aggregationBuilder, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, CheckedBiConsumer<org.apache.lucene.search.IndexSearcher, Aggregator, IOException> verify, MappedFieldType... fieldTypes) protected void
withIndex
(org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.search.IndexSearcher, IOException> consume) protected void
withNonMergingIndex
(org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.search.IndexSearcher, IOException> consume) protected IndexReader
wrapDirectoryReader
(DirectoryReader reader) Override to wrap the DirectoryReader for aggs likeNestedAggregationBuilder
.protected static DirectoryReader
wrapInMockESDirectoryReader
(DirectoryReader directoryReader) protected final NamedWriteableRegistry
TheNamedWriteableRegistry
to use for this test.Methods inherited from class org.elasticsearch.test.ESTestCase
after, afterIfFailed, afterIfSuccessful, allowedWarnings, assertArrayEquals, assertBusy, assertBusy, assertEquals, assertSettingDeprecationsAndWarnings, assertWarnings, 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, ensureNoWarnings, ensureSupportedLocale, filteredWarnings, frequently, generateRandomStringArray, generateRandomStringArray, getDataPath, getPortRange, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, getWorkerBasePort, 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, randomFrom, randomGeohash, randomInt, randomInt, randomIntBetween, randomIp, randomList, randomList, randomLong, randomLongBetween, randomMap, randomMillisUpToYear9999, randomNonEmptySubsetOf, 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, safeAwait, scaledRandomIntBetween, setContentType, setFileSystem, setHeaderWarningAppender, settings, shuffleMap, shuffleXContent, shuffleXContent, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, terminate, terminate, tmpPaths, toShuffledXContent, waitUntil, waitUntil, 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, 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, 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
-
valuesSourceRegistry
-
-
Constructor Details
-
AggregatorTestCase
public AggregatorTestCase()
-
-
Method Details
-
initPlugns
public final void initPlugns() -
initAnalysisRegistry
- Throws:
Exception
-
createAnalysisModule
- Returns:
- a new analysis module. Tests that require a fully constructed analysis module (used to create an analysis registry) should override this method
- Throws:
Exception
-
getSearchPlugins
Test cases should override this if they have plugins that need to be loaded, e.g. the plugins their aggregators are in. -
createAggregator
protected <A extends Aggregator> A createAggregator(AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher searcher, MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregator
protected <A extends Aggregator> A createAggregator(AggregationBuilder builder, AggregationContext context) throws IOException - Throws:
IOException
-
createAggregationContext
protected AggregationContext createAggregationContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.apache.lucene.search.Query query, MappedFieldType... fieldTypes) throws IOException Create a AggregationContext for testing anAggregator
. While AggregationContext isReleasable
the caller is not responsible for releasing it. Instead, it is released automatically in incleanupReleasables()
.- Throws:
IOException
-
createAggregationContext
protected AggregationContext createAggregationContext(org.apache.lucene.search.IndexSearcher indexSearcher, IndexSettings indexSettings, org.apache.lucene.search.Query query, CircuitBreakerService breakerService, long bytesToPreallocate, int maxBucket, MappedFieldType... fieldTypes) throws IOException Create a AggregationContext for testing anAggregator
. While AggregationContext isReleasable
the caller is not responsible for releasing it. Instead, it is released automatically in incleanupReleasables()
.- Throws:
IOException
-
buildMockFieldMapper
Build aFieldMapper
to create theMappingLookup
used for the aggs.protected
so subclasses can have it. -
objectMappers
ObjectMapper
s to add to the lookup. By default we don't need anyObjectMapper
s but testing nested objects will require adding some. -
createIndexSettings
-
getMockScriptService
Sub-tests that need scripting can override this method to provide a script service and pre-baked scripts -
searchAndReduce
protected <A extends InternalAggregation,C extends Aggregator> A searchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends InternalAggregation,C extends Aggregator> A searchAndReduce(IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends InternalAggregation,C extends Aggregator> A searchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, int maxBucket, MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends InternalAggregation,C extends Aggregator> A searchAndReduce(IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, int maxBucket, MappedFieldType... fieldTypes) throws IOException Collects all documents that match the provided queryQuery
and returns the reducedInternalAggregation
.Half the time it aggregates each leaf individually and reduces all results together. The other half the time it aggregates across the entire index at once and runs a final reduction on the single resulting agg.
- Throws:
IOException
-
searchAndReduce
protected <A extends InternalAggregation,C extends Aggregator> A searchAndReduce(IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, AggregationBuilder builder, int maxBucket, boolean splitLeavesIntoSeparateAggregators, MappedFieldType... fieldTypes) throws IOException Collects all documents that match the provided queryQuery
and returns the reducedInternalAggregation
. It runs the aggregation as well using a circuit breaker that randomly throwsCircuitBreakingException
in order to mak sure the implementation does not leak.- Parameters:
splitLeavesIntoSeparateAggregators
- If true this creates a newAggregator
for each leaf as though it were a separate index. If false this aggregates all leaves together, like we do in production.- Throws:
IOException
-
doAssertReducedMultiBucketConsumer
protected void doAssertReducedMultiBucketConsumer(Aggregation agg, MultiBucketConsumerService.MultiBucketConsumer bucketConsumer) -
testCase
protected <T extends AggregationBuilder,V extends InternalAggregation> void testCase(T aggregationBuilder, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, Consumer<V> verify, MappedFieldType... fieldTypes) throws IOException- Throws:
IOException
-
withIndex
protected void withIndex(org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.search.IndexSearcher, throws IOExceptionIOException> consume) - Throws:
IOException
-
withNonMergingIndex
protected void withNonMergingIndex(org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.search.IndexSearcher, throws IOExceptionIOException> consume) - Throws:
IOException
-
debugTestCase
protected <R extends InternalAggregation> void debugTestCase(AggregationBuilder builder, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, TriConsumer<R, throws IOExceptionClass<? extends Aggregator>, Map<String, Map<String, Object>>> verify, MappedFieldType... fieldTypes) Execute and aggregation and collect itsdebug
information. UnliketestCase(T, org.apache.lucene.search.Query, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.index.RandomIndexWriter, java.io.IOException>, java.util.function.Consumer<V>, org.elasticsearch.index.mapper.MappedFieldType...)
this doesn't randomly create anAggregator
per leaf and perform partial reductions. It always creates a singleAggregator
so we can get consistent debug info.- Throws:
IOException
-
debugTestCase
protected <R extends InternalAggregation> void debugTestCase(AggregationBuilder builder, org.apache.lucene.search.Query query, org.apache.lucene.search.IndexSearcher searcher, TriConsumer<R, Class<? extends Aggregator>, throws IOExceptionMap<String, Map<String, Object>>> verify, MappedFieldType... fieldTypes) Execute and aggregation and collect itsdebug
information. UnliketestCase(T, org.apache.lucene.search.Query, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.index.RandomIndexWriter, java.io.IOException>, java.util.function.Consumer<V>, org.elasticsearch.index.mapper.MappedFieldType...)
this doesn't randomly create anAggregator
per leaf and perform partial reductions. It always creates a singleAggregator
so we can get consistent debug info.- Throws:
IOException
-
withAggregator
protected void withAggregator(AggregationBuilder aggregationBuilder, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<RandomIndexWriter, IOException> buildIndex, CheckedBiConsumer<org.apache.lucene.search.IndexSearcher, throws IOExceptionAggregator, IOException> verify, MappedFieldType... fieldTypes) - Throws:
IOException
-
verifyOutputFieldNames
protected <T extends AggregationBuilder,V extends InternalAggregation> void verifyOutputFieldNames(T aggregationBuilder, V agg) throws IOException - Throws:
IOException
-
wrapDirectoryReader
Override to wrap the DirectoryReader for aggs likeNestedAggregationBuilder
.- Throws:
IOException
-
wrapInMockESDirectoryReader
protected static DirectoryReader wrapInMockESDirectoryReader(DirectoryReader directoryReader) throws IOException - Throws:
IOException
-
newIndexSearcher
Added to randomly run with more assertions on the index searcher level, likeLuceneTestCase.newSearcher(IndexReader)
, which can't be used because it also wraps in the IndexSearcher's IndexReader with other implementations that we can't handle. (e.g. ParallelCompositeReader) -
maybeWrapReaderEs
Added to randomly run with more assertions on the index reader level, likeLuceneTestCase.wrapReader(IndexReader)
, which can't be used because it also wraps in the IndexReader with other implementations that we can't handle. (e.g. ParallelCompositeReader)- Throws:
IOException
-
getSupportedValuesSourceTypes
Implementors should return a list ofValuesSourceType
that the aggregator supports. This is used to test the matrix of supported/unsupported field types against the aggregator and verify it works (or doesn't) as expected. If this method is implemented,createAggBuilderForTypeTest(MappedFieldType, String)
should be implemented as well.- Returns:
- list of supported ValuesSourceTypes
-
createAggBuilderForTypeTest
protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldType, String fieldName) This method is invoked each time a field type is tested intestSupportedFieldTypes()
. The field type and name are provided, and the implementor is expected to return an AggBuilder accordingly. The AggBuilder should be returned even if the aggregation does not support the field type, because the test will check if an exception is thrown in that case. The list of supported types are provided bygetSupportedValuesSourceTypes()
, which must also be implemented.- Parameters:
fieldType
- the type of the field that will be testedfieldName
- the name of the field that will be test- Returns:
- an aggregation builder to test against the field
-
unsupportedMappedFieldTypes
A method that allows implementors to specifically blacklist particular field types (based on their content_name). This is needed in some areas where the ValuesSourceType is not granular enough, for example integer values vs floating points, or `keyword` bytes vs `binary` bytes (which are not searchable) This is a blacklist instead of a whitelist because there are vastly more field types than ValuesSourceTypes, and it's expected that these unsupported cases are exceptional rather than common -
testSupportedFieldTypes
This test will validate that an aggregator succeeds or fails to run against all the field types that are registered inIndicesModule
(e.g. all the core field types). An aggregator is provided by the implementor class, and it is executed against each field type in turn. If an exception is thrown when the field is supported, that will fail the test. Similarly, if an exception _is not_ thrown when a field is unsupported, that will also fail the test. Exception types/messages are not currently checked, just presence/absence of an exception.- Throws:
IOException
-
cleanupReleasables
public void cleanupReleasables() -
afterClose
protected void afterClose()Hook for checking things after allAggregator
s have been closed. -
dateField
protected DateFieldMapper.DateFieldType dateField(String name, DateFieldMapper.Resolution resolution) Make a DateFieldMapper.DateFieldType for adate
. -
doubleField
Make a NumberFieldMapper.NumberFieldType for adouble
. -
geoPointField
Make a GeoPointFieldMapper.GeoPointFieldType for ageo_point
. -
keywordField
Make a DateFieldMapper.DateFieldType for adate
. -
longField
Make a NumberFieldMapper.NumberFieldType for along
. -
rangeField
Make a NumberFieldMapper.NumberFieldType for arange
. -
writableRegistry
Description copied from class:ESTestCase
TheNamedWriteableRegistry
to use for this test. Subclasses should override and use liberally.- Overrides:
writableRegistry
in classESTestCase
-
aggCardinalityUpperBound
Request an aggregation that returns theCardinalityUpperBound
that was passed to its ctor.
-