From 3136ed1490e41b4c82b8ee05ff2d224e113ef1b8 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 4 Apr 2017 11:04:18 -0400 Subject: [PATCH] Rename random ASCII helper methods This commit renames the random ASCII helper methods in ESTestCase. This is because this method ultimately uses the random ASCII methods from randomized runner, but these methods actually only produce random strings generated from [a-zA-Z]. Relates #23886 --- .../elasticsearch/client/RequestTests.java | 66 +++++++++---------- .../BoundedBreakIteratorScannerTests.java | 4 +- .../java/org/elasticsearch/BuildTests.java | 2 +- .../ElasticsearchExceptionTests.java | 6 +- .../ExceptionSerializationTests.java | 4 +- .../action/OriginalIndicesTests.java | 2 +- .../ClusterAllocationExplainRequestTests.java | 4 +- .../cluster/node/stats/NodeStatsTests.java | 22 +++---- .../admin/cluster/node/tasks/TaskTests.java | 2 +- .../reroute/ClusterRerouteRequestTests.java | 20 +++--- .../ClusterSearchShardsRequestTests.java | 6 +- .../ClusterSearchShardsResponseTests.java | 6 +- .../indices/alias/AliasActionsTests.java | 38 +++++------ .../rollover/RolloverRequestTests.java | 4 +- .../TransportRolloverActionTests.java | 39 +++++------ .../shrink/TransportShrinkActionTests.java | 2 +- .../stats/IndicesStatsResponseTests.java | 2 +- .../action/bulk/BulkItemResponseTests.java | 6 +- .../action/bulk/BulkResponseTests.java | 6 +- .../elasticsearch/action/bulk/RetryTests.java | 2 +- ...ulkByScrollParallelizationHelperTests.java | 2 +- .../byscroll/BulkByScrollResponseTests.java | 4 +- .../byscroll/BulkByScrollTaskStatusTests.java | 2 +- .../bulk/byscroll/BulkByScrollTaskTests.java | 4 +- .../byscroll/DeleteByQueryRequestTests.java | 2 +- .../action/delete/DeleteResponseTests.java | 8 +-- .../FieldCapabilitiesRequestTests.java | 2 +- .../FieldCapabilitiesResponseTests.java | 4 +- .../fieldcaps/FieldCapabilitiesTests.java | 10 +-- .../action/get/MultiGetRequestTests.java | 12 ++-- .../action/get/MultiGetShardRequestTests.java | 6 +- .../action/index/IndexRequestTests.java | 12 ++-- .../action/index/IndexResponseTests.java | 8 +-- .../SimulatePipelineRequestParsingTests.java | 22 +++---- .../ingest/SimulatePipelineRequestTests.java | 2 +- .../ingest/SimulatePipelineResponseTests.java | 4 +- .../ingest/SimulateProcessorResultTests.java | 2 +- .../ingest/WriteableIngestDocumentTests.java | 12 ++-- .../action/main/MainActionTests.java | 4 +- .../action/main/MainResponseTests.java | 14 ++-- .../search/SearchPhaseControllerTests.java | 4 +- .../search/SearchScrollRequestTests.java | 2 +- .../search/ShardSearchFailureTests.java | 8 +-- .../action/support/ActiveShardCountTests.java | 10 +-- .../action/support/AutoCreateIndexTests.java | 36 +++++----- .../TransportActionFilterChainTests.java | 6 +- .../nodes/TransportNodesActionTests.java | 8 +-- .../ReplicationOperationTests.java | 2 +- .../TransportReplicationActionTests.java | 3 +- .../TransportWriteActionTests.java | 6 +- .../action/update/UpdateRequestTests.java | 12 ++-- .../action/update/UpdateResponseTests.java | 2 +- .../bootstrap/BootstrapChecksTests.java | 6 +- ...icsearchUncaughtExceptionHandlerTests.java | 4 +- .../client/AbstractClientHeadersTestCase.java | 4 +- .../ParentTaskAssigningClientTests.java | 2 +- .../cluster/ClusterChangedEventTests.java | 2 +- .../cluster/ClusterInfoTests.java | 10 +-- .../cluster/ClusterStateDiffIT.java | 10 +-- .../health/ClusterStateHealthTests.java | 3 +- .../DateMathExpressionResolverTests.java | 2 +- .../cluster/metadata/IndexGraveyardTests.java | 4 +- .../MetaDataCreateIndexServiceTests.java | 2 +- .../MetaDataDeleteIndexServiceTests.java | 4 +- .../MetaDataIndexAliasesServiceTests.java | 2 +- .../cluster/node/DiscoveryNodesTests.java | 3 +- .../routing/OperationRoutingTests.java | 2 +- .../routing/RandomShardRoutingMutator.java | 6 +- .../cluster/routing/ShardRoutingTests.java | 2 +- .../cluster/routing/UnassignedInfoTests.java | 4 +- .../AllocateUnassignedDecisionTests.java | 2 +- .../allocation/BalancedSingleShardTests.java | 6 +- .../allocation/NodeAllocationResultTests.java | 2 +- .../common/cache/CacheTests.java | 2 +- .../common/io/stream/BytesStreamsTests.java | 30 ++++----- .../logging/DeprecationLoggerTests.java | 8 +-- .../lucene/index/FreqTermsEnumTests.java | 2 +- .../common/settings/SecureStringTests.java | 8 +-- .../common/settings/SettingsTests.java | 2 +- .../common/unit/TimeValueTests.java | 2 +- .../common/util/BytesRefHashTests.java | 2 +- .../common/util/IndexFolderUpgraderTests.java | 8 +-- .../ConstructingObjectParserTests.java | 8 +-- .../UnknownNamedObjectExceptionTests.java | 4 +- .../support/filtering/FilterPathTests.java | 6 +- .../discovery/ZenFaultDetectionTests.java | 4 +- .../zen/PublishClusterStateActionTests.java | 4 +- .../discovery/zen/UnicastZenPingTests.java | 2 +- .../fieldstats/FieldStatsTests.java | 2 +- .../gateway/GatewayMetaStateTests.java | 3 +- .../gateway/MetaDataStateFormatTests.java | 4 +- .../gateway/PrimaryShardAllocatorTests.java | 4 +- .../org/elasticsearch/index/IndexTests.java | 2 +- .../index/engine/InternalEngineTests.java | 2 +- .../index/get/GetFieldTests.java | 4 +- .../index/get/GetResultTests.java | 6 +- .../index/mapper/MultiFieldTests.java | 11 +--- .../index/mapper/RangeFieldTypeTests.java | 2 +- .../query/AbstractTermQueryTestCase.java | 2 +- .../query/CommonTermsQueryBuilderTests.java | 8 +-- .../index/query/ExistsQueryBuilderTests.java | 2 +- .../FieldMaskingSpanQueryBuilderTests.java | 2 +- .../index/query/FuzzyQueryBuilderTests.java | 2 +- .../query/GeoShapeQueryBuilderTests.java | 8 +-- .../query/HasChildQueryBuilderTests.java | 2 +- .../query/HasParentQueryBuilderTests.java | 2 +- .../index/query/IdsQueryBuilderTests.java | 4 +- .../index/query/InnerHitBuilderTests.java | 36 +++++----- .../MatchPhrasePrefixQueryBuilderTests.java | 6 +- .../query/MatchPhraseQueryBuilderTests.java | 6 +- .../index/query/MatchQueryBuilderTests.java | 4 +- .../query/MoreLikeThisQueryBuilderTests.java | 6 +- .../index/query/NestedQueryBuilderTests.java | 3 +- .../query/ParentIdQueryBuilderTests.java | 2 +- .../index/query/PrefixQueryBuilderTests.java | 4 +- .../query/QueryStringQueryBuilderTests.java | 8 +-- .../index/query/RangeQueryBuilderTests.java | 14 ++-- .../index/query/RegexpQueryBuilderTests.java | 4 +- .../query/SimpleQueryStringBuilderTests.java | 8 +-- .../query/SpanTermQueryBuilderTests.java | 6 +- .../index/query/TermQueryBuilderTests.java | 4 +- .../index/query/TermsQueryBuilderTests.java | 10 ++- .../query/WildcardQueryBuilderTests.java | 4 +- .../FunctionScoreQueryBuilderTests.java | 2 +- .../index/seqno/GlobalCheckpointTests.java | 2 +- .../index/shard/IndexShardIT.java | 8 +-- .../shard/IndexingOperationListenerTests.java | 2 +- .../index/shard/ShardIdTests.java | 2 +- .../snapshots/blobstore/FileInfoTests.java | 2 +- .../index/translog/TranslogTests.java | 10 +-- .../elasticsearch/indexing/IndexActionIT.java | 8 +-- .../indices/NodeIndicesStatsTests.java | 2 +- .../indices/TermsLookupTests.java | 27 ++++---- .../PreBuiltAnalyzerIntegrationIT.java | 4 +- ...ClusterStateServiceRandomUpdatesTests.java | 4 +- .../indices/recovery/IndexRecoveryIT.java | 2 +- .../indices/recovery/RecoveryTargetTests.java | 2 +- .../indices/store/IndicesStoreTests.java | 24 ++----- .../ingest/IngestDocumentTests.java | 8 +-- .../monitor/fs/DeviceStatsTests.java | 2 +- .../jvm/JvmGcMonitorServiceSettingsTests.java | 4 +- .../monitor/jvm/JvmGcMonitorServiceTests.java | 2 +- .../monitor/os/OsProbeTests.java | 2 +- .../monitor/os/OsStatsTests.java | 4 +- .../nodesinfo/NodeInfoStreamingTests.java | 18 ++--- .../repositories/IndexIdTests.java | 8 +-- .../repositories/RepositoryDataTests.java | 12 ++-- .../blobstore/BlobStoreRepositoryTests.java | 6 +- .../rest/BaseRestHandlerTests.java | 46 ++++++------- .../rest/BytesRestResponseTests.java | 4 +- .../rest/DeprecationRestHandlerTests.java | 2 +- .../rest/RestControllerTests.java | 24 +++---- .../elasticsearch/rest/RestRequestTests.java | 4 +- .../rest/action/RestMainActionTests.java | 4 +- .../cluster/RestNodesStatsActionTests.java | 5 +- .../indices/RestIndicesStatsActionTests.java | 2 +- .../action/cat/RestIndicesActionTests.java | 2 +- .../action/cat/RestRecoveryActionTests.java | 4 +- .../script/ScriptMetaDataTests.java | 7 +- .../script/ScriptModesTests.java | 4 +- .../script/ScriptServiceTests.java | 8 +-- .../org/elasticsearch/script/ScriptTests.java | 4 +- .../script/StoredScriptTests.java | 4 +- .../elasticsearch/script/StoredScriptsIT.java | 2 +- .../search/AbstractSearchTestCase.java | 2 +- .../search/NestedIdentityTests.java | 2 +- .../elasticsearch/search/SearchHitTests.java | 18 ++--- .../search/SearchRequestTests.java | 8 +-- .../search/SearchSortValuesTests.java | 2 +- .../AggregatorFactoriesTests.java | 4 +- .../aggregations/BaseAggregationTestCase.java | 2 +- .../BasePipelineAggregationTestCase.java | 2 +- .../InternalAggregationTestCase.java | 8 +-- .../aggregations/bucket/ChildrenTests.java | 4 +- .../aggregations/bucket/DateRangeTests.java | 2 +- .../bucket/FilterAggregatorTests.java | 2 +- .../bucket/FiltersAggregatorTests.java | 2 +- .../bucket/GeoDistanceRangeTests.java | 4 +- .../aggregations/bucket/GeoHashGridTests.java | 2 +- .../aggregations/bucket/GlobalTests.java | 2 +- .../aggregations/bucket/IpRangeTests.java | 2 +- .../aggregations/bucket/RangeTests.java | 2 +- .../bucket/SignificantTermsTests.java | 12 ++-- .../aggregations/bucket/StringTermsIT.java | 10 ++- .../aggregations/bucket/TermsTests.java | 16 ++--- .../bucket/nested/NestedTests.java | 2 +- .../bucket/nested/ReverseNestedTests.java | 4 +- .../range/InternalBinaryRangeTests.java | 6 +- .../SignificantStringTermsTests.java | 2 +- .../bucket/terms/StringTermsTests.java | 2 +- .../metrics/AdjacencyMatrixTests.java | 6 +- .../aggregations/metrics/FilterTests.java | 4 +- .../aggregations/metrics/FiltersTests.java | 12 ++-- .../aggregations/metrics/GeoBoundsTests.java | 4 +- .../metrics/GeoCentroidTests.java | 2 +- .../metrics/PercentileRanksTests.java | 2 +- .../metrics/PercentilesTests.java | 2 +- .../metrics/ScriptedMetricIT.java | 2 +- .../metrics/ScriptedMetricTests.java | 2 +- .../aggregations/metrics/TopHitsTests.java | 26 ++++---- .../scripted/InternalScriptedMetricTests.java | 4 +- .../metrics/tophits/InternalTopHitsTests.java | 6 +- .../pipeline/BucketScriptTests.java | 6 +- .../pipeline/BucketSelectorTests.java | 4 +- .../pipeline/CumulativeSumTests.java | 6 +- .../pipeline/DerivativeTests.java | 6 +- .../pipeline/SerialDifferenceTests.java | 6 +- .../AbstractBucketMetricsTestCase.java | 6 +- .../pipeline/moving/avg/MovAvgTests.java | 6 +- .../basic/SearchWhileCreatingIndexIT.java | 4 +- .../search/collapse/CollapseBuilderTests.java | 2 +- .../highlight/HighlightBuilderTests.java | 32 ++++----- .../highlight/HighlightFieldTests.java | 4 +- .../highlight/HighlighterSearchIT.java | 2 +- .../ShardSearchTransportRequestTests.java | 2 +- .../search/profile/ProfileResultTests.java | 6 +- .../SearchProfileShardResultsTests.java | 2 +- .../aggregation/AggregationProfilerIT.java | 4 +- .../profile/query/CollectorResultTests.java | 4 +- .../search/query/MultiMatchQueryIT.java | 2 +- .../rescore/QueryRescoreBuilderTests.java | 4 +- .../searchafter/SearchAfterBuilderTests.java | 8 +-- .../search/searchafter/SearchAfterIT.java | 3 +- .../search/slice/SearchSliceIT.java | 2 +- .../search/slice/SliceBuilderTests.java | 2 +- .../search/sort/AbstractSortTestCase.java | 5 +- .../search/sort/FieldSortBuilderTests.java | 10 +-- .../sort/GeoDistanceSortBuilderTests.java | 6 +- .../search/sort/ScriptSortBuilderTests.java | 4 +- .../search/sort/SortBuilderTests.java | 2 +- .../AbstractSuggestionBuilderTestCase.java | 16 ++--- .../CompletionSuggestionOptionTests.java | 6 +- .../ContextCompletionSuggestSearchIT.java | 2 +- .../suggest/CustomSuggesterSearchIT.java | 6 +- .../search/suggest/SuggestBuilderTests.java | 8 +-- .../search/suggest/SuggestTests.java | 8 +-- .../search/suggest/SuggestionEntryTests.java | 2 +- .../search/suggest/SuggestionOptionTests.java | 4 +- .../search/suggest/SuggestionTests.java | 2 +- .../suggest/TermSuggestionOptionTests.java | 2 +- .../completion/CategoryQueryContextTests.java | 2 +- .../CompletionSuggesterBuilderTests.java | 24 +++---- .../completion/CompletionSuggestionTests.java | 2 +- .../phrase/DirectCandidateGeneratorTests.java | 6 +- .../phrase/PhraseSuggestionBuilderTests.java | 22 +++---- .../term/TermSuggestionBuilderTests.java | 6 +- .../snapshots/BlobStoreFormatIT.java | 4 +- .../DedicatedClusterSnapshotRestoreIT.java | 4 +- .../MinThreadsSnapshotRestoreIT.java | 6 +- ...epositoriesMetaDataSerializationTests.java | 6 +- .../SharedClusterSnapshotRestoreIT.java | 24 +++---- .../snapshots/SnapshotTests.java | 4 +- ...SnapshotsInProgressSerializationTests.java | 8 +-- .../elasticsearch/tasks/TaskResultTests.java | 12 ++-- .../TransportServiceHandshakeTests.java | 2 +- .../java/org/elasticsearch/tribe/TribeIT.java | 12 ++-- .../elasticsearch/update/UpdateNoopIT.java | 12 ++-- .../common/AppendProcessorFactoryTests.java | 4 +- .../ingest/common/AppendProcessorTests.java | 10 +-- .../common/ConvertProcessorFactoryTests.java | 10 +-- .../ingest/common/ConvertProcessorTests.java | 50 +++++++------- .../ingest/common/DateFormatTests.java | 2 +- .../common/DateProcessorFactoryTests.java | 26 ++++---- .../ingest/common/DateProcessorTests.java | 16 ++--- .../common/FailProcessorFactoryTests.java | 4 +- .../ingest/common/FailProcessorTests.java | 4 +- .../common/GrokProcessorFactoryTests.java | 4 +- .../ingest/common/GrokProcessorTests.java | 30 ++++----- .../common/GsubProcessorFactoryTests.java | 2 +- .../ingest/common/GsubProcessorTests.java | 8 +-- .../common/JoinProcessorFactoryTests.java | 2 +- .../ingest/common/JoinProcessorTests.java | 14 ++-- .../common/JsonProcessorFactoryTests.java | 25 ++++--- .../ingest/common/JsonProcessorTests.java | 10 +-- .../common/KeyValueProcessorFactoryTests.java | 10 +-- .../ingest/common/KeyValueProcessorTests.java | 18 ++--- .../LowercaseProcessorFactoryTests.java | 4 +- .../common/LowercaseProcessorTests.java | 2 +- .../common/RemoveProcessorFactoryTests.java | 4 +- .../ingest/common/RemoveProcessorTests.java | 4 +- .../common/RenameProcessorFactoryTests.java | 4 +- .../ingest/common/RenameProcessorTests.java | 24 +++---- .../common/ScriptProcessorFactoryTests.java | 12 ++-- .../ingest/common/ScriptProcessorTests.java | 2 +- .../common/SetProcessorFactoryTests.java | 6 +- .../ingest/common/SetProcessorTests.java | 2 +- .../ingest/common/SortProcessorTests.java | 30 ++++----- .../common/SplitProcessorFactoryTests.java | 2 +- .../ingest/common/SplitProcessorTests.java | 12 ++-- .../common/TrimProcessorFactoryTests.java | 4 +- .../ingest/common/TrimProcessorTests.java | 2 +- .../UppercaseProcessorFactoryTests.java | 2 +- .../common/UppercaseProcessorTests.java | 2 +- .../script/mustache/MustacheTests.java | 2 +- .../painless/ImplementInterfacesTests.java | 6 +- .../PercolateQueryBuilderTests.java | 14 ++-- .../PercolatorFieldMapperTests.java | 4 +- .../percolator/PercolatorQuerySearchIT.java | 4 +- .../percolator/QueryAnalyzerTests.java | 4 +- .../BulkIndexByScrollResponseTests.java | 4 +- .../reindex/DeleteByQueryBasicTests.java | 2 +- .../ReindexFromRemoteWhitelistTests.java | 6 +- .../index/reindex/ReindexRequestTests.java | 10 +-- .../ReindexSourceTargetValidationTests.java | 4 +- .../index/reindex/RoundTripTests.java | 14 ++-- .../TransportRethrottleActionTests.java | 2 +- .../reindex/UpdateByQueryRequestTests.java | 6 +- .../remote/RemoteRequestBuildersTests.java | 4 +- .../RemoteScrollableHitSourceTests.java | 2 +- .../blobstore/url/URLBlobStoreTests.java | 2 +- .../AttachmentProcessorFactoryTests.java | 7 +- .../attachment/AttachmentProcessorTests.java | 13 ++-- .../geoip/GeoIpProcessorFactoryTests.java | 6 +- .../ingest/geoip/GeoIpProcessorTests.java | 23 ++++--- .../UserAgentProcessorFactoryTests.java | 4 +- .../useragent/UserAgentProcessorTests.java | 13 ++-- ...leCloudStorageBlobStoreContainerTests.java | 2 +- .../gcs/GoogleCloudStorageBlobStoreTests.java | 2 +- .../blobstore/S3BlobStoreContainerTests.java | 2 +- .../bootstrap/EvilBootstrapChecksTests.java | 2 +- .../bootstrap/EvilElasticsearchCliTests.java | 4 +- .../logging/EvilLoggerConfigurationTests.java | 2 +- .../common/logging/EvilLoggerTests.java | 10 +-- .../http/ContextAndHeaderTransportIT.java | 6 +- .../AbstractBulkByScrollRequestTestCase.java | 3 +- .../cluster/routing/TestShardRouting.java | 4 +- .../index/shard/IndexShardTestCase.java | 2 +- .../org/elasticsearch/node/NodeTests.java | 6 +- .../ESBlobStoreRepositoryIntegTestCase.java | 4 +- .../search/RandomSearchRequestGenerator.java | 46 ++++++------- .../test/AbstractQueryTestCase.java | 22 +++---- .../elasticsearch/test/ESIntegTestCase.java | 4 +- .../org/elasticsearch/test/ESTestCase.java | 4 +- .../disruption/NetworkDisruptionTests.java | 24 +++---- .../test/test/ESTestCaseTests.java | 6 +- 335 files changed, 1156 insertions(+), 1222 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java index d39dfaa3e7567..58b7df922727c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java @@ -79,9 +79,9 @@ public void testGet() { } public void testDelete() throws IOException { - String index = randomAsciiOfLengthBetween(3, 10); - String type = randomAsciiOfLengthBetween(3, 10); - String id = randomAsciiOfLengthBetween(3, 10); + String index = randomAlphaOfLengthBetween(3, 10); + String type = randomAlphaOfLengthBetween(3, 10); + String id = randomAlphaOfLengthBetween(3, 10); DeleteRequest deleteRequest = new DeleteRequest(index, type, id); Map expectedParams = new HashMap<>(); @@ -93,12 +93,12 @@ public void testDelete() throws IOException { if (frequently()) { if (randomBoolean()) { - String routing = randomAsciiOfLengthBetween(3, 10); + String routing = randomAlphaOfLengthBetween(3, 10); deleteRequest.routing(routing); expectedParams.put("routing", routing); } if (randomBoolean()) { - String parent = randomAsciiOfLengthBetween(3, 10); + String parent = randomAlphaOfLengthBetween(3, 10); deleteRequest.parent(parent); expectedParams.put("parent", parent); } @@ -116,20 +116,20 @@ public void testExists() { } private static void getAndExistsTest(Function requestConverter, String method) { - String index = randomAsciiOfLengthBetween(3, 10); - String type = randomAsciiOfLengthBetween(3, 10); - String id = randomAsciiOfLengthBetween(3, 10); + String index = randomAlphaOfLengthBetween(3, 10); + String type = randomAlphaOfLengthBetween(3, 10); + String id = randomAlphaOfLengthBetween(3, 10); GetRequest getRequest = new GetRequest(index, type, id); Map expectedParams = new HashMap<>(); if (randomBoolean()) { if (randomBoolean()) { - String preference = randomAsciiOfLengthBetween(3, 10); + String preference = randomAlphaOfLengthBetween(3, 10); getRequest.preference(preference); expectedParams.put("preference", preference); } if (randomBoolean()) { - String routing = randomAsciiOfLengthBetween(3, 10); + String routing = randomAlphaOfLengthBetween(3, 10); getRequest.routing(routing); expectedParams.put("routing", routing); } @@ -166,7 +166,7 @@ private static void getAndExistsTest(Function requestConver String[] storedFields = new String[numStoredFields]; StringBuilder storedFieldsParam = new StringBuilder(); for (int i = 0; i < numStoredFields; i++) { - String storedField = randomAsciiOfLengthBetween(3, 10); + String storedField = randomAlphaOfLengthBetween(3, 10); storedFields[i] = storedField; storedFieldsParam.append(storedField); if (i < numStoredFields - 1) { @@ -188,11 +188,11 @@ private static void getAndExistsTest(Function requestConver } public void testIndex() throws IOException { - String index = randomAsciiOfLengthBetween(3, 10); - String type = randomAsciiOfLengthBetween(3, 10); + String index = randomAlphaOfLengthBetween(3, 10); + String type = randomAlphaOfLengthBetween(3, 10); IndexRequest indexRequest = new IndexRequest(index, type); - String id = randomBoolean() ? randomAsciiOfLengthBetween(3, 10) : null; + String id = randomBoolean() ? randomAlphaOfLengthBetween(3, 10) : null; indexRequest.id(id); Map expectedParams = new HashMap<>(); @@ -219,17 +219,17 @@ public void testIndex() throws IOException { if (frequently()) { if (randomBoolean()) { - String routing = randomAsciiOfLengthBetween(3, 10); + String routing = randomAlphaOfLengthBetween(3, 10); indexRequest.routing(routing); expectedParams.put("routing", routing); } if (randomBoolean()) { - String parent = randomAsciiOfLengthBetween(3, 10); + String parent = randomAlphaOfLengthBetween(3, 10); indexRequest.parent(parent); expectedParams.put("parent", parent); } if (randomBoolean()) { - String pipeline = randomAsciiOfLengthBetween(3, 10); + String pipeline = randomAlphaOfLengthBetween(3, 10); indexRequest.setPipeline(pipeline); expectedParams.put("pipeline", pipeline); } @@ -270,9 +270,9 @@ public void testUpdate() throws IOException { XContentType xContentType = randomFrom(XContentType.values()); Map expectedParams = new HashMap<>(); - String index = randomAsciiOfLengthBetween(3, 10); - String type = randomAsciiOfLengthBetween(3, 10); - String id = randomAsciiOfLengthBetween(3, 10); + String index = randomAlphaOfLengthBetween(3, 10); + String type = randomAlphaOfLengthBetween(3, 10); + String id = randomAlphaOfLengthBetween(3, 10); UpdateRequest updateRequest = new UpdateRequest(index, type, id); updateRequest.detectNoop(randomBoolean()); @@ -295,12 +295,12 @@ public void testUpdate() throws IOException { updateRequest.upsert(new IndexRequest().source(source, xContentType)); } if (randomBoolean()) { - String routing = randomAsciiOfLengthBetween(3, 10); + String routing = randomAlphaOfLengthBetween(3, 10); updateRequest.routing(routing); expectedParams.put("routing", routing); } if (randomBoolean()) { - String parent = randomAsciiOfLengthBetween(3, 10); + String parent = randomAlphaOfLengthBetween(3, 10); updateRequest.parent(parent); expectedParams.put("parent", parent); } @@ -416,9 +416,9 @@ public void testBulk() throws IOException { int nbItems = randomIntBetween(10, 100); for (int i = 0; i < nbItems; i++) { - String index = randomAsciiOfLength(5); - String type = randomAsciiOfLength(5); - String id = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); + String type = randomAlphaOfLength(5); + String id = randomAlphaOfLength(5); BytesReference source = RandomObjects.randomSource(random(), xContentType); DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values()); @@ -428,16 +428,16 @@ public void testBulk() throws IOException { IndexRequest indexRequest = new IndexRequest(index, type, id).source(source, xContentType); docWriteRequest = indexRequest; if (randomBoolean()) { - indexRequest.setPipeline(randomAsciiOfLength(5)); + indexRequest.setPipeline(randomAlphaOfLength(5)); } if (randomBoolean()) { - indexRequest.parent(randomAsciiOfLength(5)); + indexRequest.parent(randomAlphaOfLength(5)); } } else if (opType == DocWriteRequest.OpType.CREATE) { IndexRequest createRequest = new IndexRequest(index, type, id).source(source, xContentType).create(true); docWriteRequest = createRequest; if (randomBoolean()) { - createRequest.parent(randomAsciiOfLength(5)); + createRequest.parent(randomAlphaOfLength(5)); } } else if (opType == DocWriteRequest.OpType.UPDATE) { final UpdateRequest updateRequest = new UpdateRequest(index, type, id).doc(new IndexRequest().source(source, xContentType)); @@ -449,14 +449,14 @@ public void testBulk() throws IOException { randomizeFetchSourceContextParams(updateRequest::fetchSource, new HashMap<>()); } if (randomBoolean()) { - updateRequest.parent(randomAsciiOfLength(5)); + updateRequest.parent(randomAlphaOfLength(5)); } } else if (opType == DocWriteRequest.OpType.DELETE) { docWriteRequest = new DeleteRequest(index, type, id); } if (randomBoolean()) { - docWriteRequest.routing(randomAsciiOfLength(10)); + docWriteRequest.routing(randomAlphaOfLength(10)); } if (randomBoolean()) { docWriteRequest.version(randomNonNegativeLong()); @@ -591,7 +591,7 @@ public void testParams() { Map expectedParams = new HashMap<>(); for (int i = 0; i < nbParams; i++) { String paramName = "p_" + i; - String paramValue = randomAsciiOfLength(5); + String paramValue = randomAlphaOfLength(5); params.putParam(paramName, paramValue); expectedParams.put(paramName, paramValue); } @@ -665,7 +665,7 @@ private static void randomizeFetchSourceContextParams(Consumer randomExceptions() { int nbValues = randomIntBetween(1, 3); for (int j = 0; j < nbValues; j++) { - values.add(frequently() ? randomAsciiOfLength(5) : ""); + values.add(frequently() ? randomAlphaOfLength(5) : ""); } randomHeaders.put("header_" + i, values); } @@ -943,7 +943,7 @@ public static Tuple randomExceptions() { int nbValues = randomIntBetween(1, 3); for (int j = 0; j < nbValues; j++) { - values.add(frequently() ? randomAsciiOfLength(5) : ""); + values.add(frequently() ? randomAlphaOfLength(5) : ""); } randomMetadata.put("es.metadata_" + i, values); } @@ -965,7 +965,7 @@ public static Tuple randomExceptions() { String resourceType = "type_" + i; String[] resourceIds = new String[randomIntBetween(1, 3)]; for (int j = 0; j < resourceIds.length; j++) { - resourceIds[j] = frequently() ? randomAsciiOfLength(5) : ""; + resourceIds[j] = frequently() ? randomAlphaOfLength(5) : ""; } actualException.setResources(resourceType, resourceIds); expected.setResources(resourceType, resourceIds); diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index cca3fb352b83e..c0430001bb830 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -646,8 +646,8 @@ public void testWithRestHeadersException() throws IOException { } public void testNoLongerPrimaryShardException() throws IOException { - ShardId shardId = new ShardId(new Index(randomAsciiOfLength(4), randomAsciiOfLength(4)), randomIntBetween(0, Integer.MAX_VALUE)); - String msg = randomAsciiOfLength(4); + ShardId shardId = new ShardId(new Index(randomAlphaOfLength(4), randomAlphaOfLength(4)), randomIntBetween(0, Integer.MAX_VALUE)); + String msg = randomAlphaOfLength(4); ShardStateAction.NoLongerPrimaryShardException ex = serialize(new ShardStateAction.NoLongerPrimaryShardException(shardId, msg)); assertEquals(shardId, ex.getShardId()); assertEquals(msg, ex.getMessage()); diff --git a/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java b/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java index ceba9278a1627..c82f184eff418 100644 --- a/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java +++ b/core/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java @@ -57,7 +57,7 @@ private static OriginalIndices randomOriginalIndices() { int numIndices = randomInt(10); String[] indices = new String[numIndices]; for (int j = 0; j < indices.length; j++) { - indices[j] = randomAsciiOfLength(randomIntBetween(1, 10)); + indices[j] = randomAlphaOfLength(randomIntBetween(1, 10)); } IndicesOptions indicesOptions = randomFrom(indicesOptionsValues); return new OriginalIndices(indices, indicesOptions); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestTests.java index 4067eb1b1ed8c..0c47caa54665c 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequestTests.java @@ -26,8 +26,8 @@ public class ClusterAllocationExplainRequestTests extends ESTestCase { public void testSerialization() throws Exception { ClusterAllocationExplainRequest request = - new ClusterAllocationExplainRequest(randomAsciiOfLength(4), randomIntBetween(0, Integer.MAX_VALUE), randomBoolean(), - randomBoolean() ? randomAsciiOfLength(5) : null); + new ClusterAllocationExplainRequest(randomAlphaOfLength(4), randomIntBetween(0, Integer.MAX_VALUE), randomBoolean(), + randomBoolean() ? randomAlphaOfLength(5) : null); request.includeYesDecisions(randomBoolean()); request.includeDiskInfo(randomBoolean()); BytesStreamOutput output = new BytesStreamOutput(); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java index d3d156ee2cdfd..0b6b14684f995 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java @@ -290,9 +290,9 @@ private static NodeStats createNodeStats() { new OsStats.Mem(randomLong(), randomLong()), new OsStats.Swap(randomLong(), randomLong()), new OsStats.Cgroup( - randomAsciiOfLength(8), + randomAlphaOfLength(8), randomNonNegativeLong(), - randomAsciiOfLength(8), + randomAlphaOfLength(8), randomNonNegativeLong(), randomNonNegativeLong(), new OsStats.Cgroup.CpuStat(randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()))); @@ -310,14 +310,14 @@ private static NodeStats createNodeStats() { int numMemoryPools = randomIntBetween(0, 10); List memoryPools = new ArrayList<>(numMemoryPools); for (int i = 0; i < numMemoryPools; i++) { - memoryPools.add(new JvmStats.MemoryPool(randomAsciiOfLengthBetween(3, 10), randomNonNegativeLong(), + memoryPools.add(new JvmStats.MemoryPool(randomAlphaOfLengthBetween(3, 10), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong())); } JvmStats.Threads threads = new JvmStats.Threads(randomIntBetween(1, 1000), randomIntBetween(1, 1000)); int numGarbageCollectors = randomIntBetween(0, 10); JvmStats.GarbageCollector[] garbageCollectorsArray = new JvmStats.GarbageCollector[numGarbageCollectors]; for (int i = 0; i < numGarbageCollectors; i++) { - garbageCollectorsArray[i] = new JvmStats.GarbageCollector(randomAsciiOfLengthBetween(3, 10), + garbageCollectorsArray[i] = new JvmStats.GarbageCollector(randomAlphaOfLengthBetween(3, 10), randomNonNegativeLong(), randomNonNegativeLong()); } JvmStats.GarbageCollectors garbageCollectors = new JvmStats.GarbageCollectors(garbageCollectorsArray); @@ -326,7 +326,7 @@ private static NodeStats createNodeStats() { for (int i = 0; i < numBufferPools; i++) { bufferPoolList.add( new JvmStats.BufferPool( - randomAsciiOfLengthBetween(3, 10), + randomAlphaOfLengthBetween(3, 10), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong())); @@ -342,7 +342,7 @@ private static NodeStats createNodeStats() { int numThreadPoolStats = randomIntBetween(0, 10); List threadPoolStatsList = new ArrayList<>(); for (int i = 0; i < numThreadPoolStats; i++) { - threadPoolStatsList.add(new ThreadPoolStats.Stats(randomAsciiOfLengthBetween(3, 10), randomIntBetween(1, 1000), + threadPoolStatsList.add(new ThreadPoolStats.Stats(randomAlphaOfLengthBetween(3, 10), randomIntBetween(1, 1000), randomIntBetween(1, 1000), randomIntBetween(1, 1000), randomNonNegativeLong(), randomIntBetween(1, 1000), randomIntBetween(1, 1000))); } @@ -354,17 +354,17 @@ private static NodeStats createNodeStats() { FsInfo.DeviceStats[] deviceStatsArray = new FsInfo.DeviceStats[numDeviceStats]; for (int i = 0; i < numDeviceStats; i++) { FsInfo.DeviceStats previousDeviceStats = randomBoolean() ? null : - new FsInfo.DeviceStats(randomInt(), randomInt(), randomAsciiOfLengthBetween(3, 10), + new FsInfo.DeviceStats(randomInt(), randomInt(), randomAlphaOfLengthBetween(3, 10), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), null); deviceStatsArray[i] = - new FsInfo.DeviceStats(randomInt(), randomInt(), randomAsciiOfLengthBetween(3, 10), randomNonNegativeLong(), + new FsInfo.DeviceStats(randomInt(), randomInt(), randomAlphaOfLengthBetween(3, 10), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), previousDeviceStats); } FsInfo.IoStats ioStats = new FsInfo.IoStats(deviceStatsArray); int numPaths = randomIntBetween(0, 10); FsInfo.Path[] paths = new FsInfo.Path[numPaths]; for (int i = 0; i < numPaths; i++) { - paths[i] = new FsInfo.Path(randomAsciiOfLengthBetween(3, 10), randomBoolean() ? randomAsciiOfLengthBetween(3, 10) : null, + paths[i] = new FsInfo.Path(randomAlphaOfLengthBetween(3, 10), randomBoolean() ? randomAlphaOfLengthBetween(3, 10) : null, randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()); } fsInfo = new FsInfo(randomNonNegativeLong(), ioStats, paths); @@ -377,7 +377,7 @@ private static NodeStats createNodeStats() { int numCircuitBreakerStats = randomIntBetween(0, 10); CircuitBreakerStats[] circuitBreakerStatsArray = new CircuitBreakerStats[numCircuitBreakerStats]; for (int i = 0; i < numCircuitBreakerStats; i++) { - circuitBreakerStatsArray[i] = new CircuitBreakerStats(randomAsciiOfLengthBetween(3, 10), randomNonNegativeLong(), + circuitBreakerStatsArray[i] = new CircuitBreakerStats(randomAlphaOfLengthBetween(3, 10), randomNonNegativeLong(), randomNonNegativeLong(), randomDouble(), randomNonNegativeLong()); } allCircuitBreakerStats = new AllCircuitBreakerStats(circuitBreakerStatsArray); @@ -393,7 +393,7 @@ private static NodeStats createNodeStats() { int numStatsPerPipeline = randomIntBetween(0, 10); Map statsPerPipeline = new HashMap<>(); for (int i = 0; i < numStatsPerPipeline; i++) { - statsPerPipeline.put(randomAsciiOfLengthBetween(3, 10), new IngestStats.Stats(randomNonNegativeLong(), + statsPerPipeline.put(randomAlphaOfLengthBetween(3, 10), new IngestStats.Stats(randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong())); } ingestStats = new IngestStats(totalStats, statsPerPipeline); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskTests.java index d3f10f2b0385f..c5d8b39c3da39 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskTests.java @@ -30,7 +30,7 @@ public class TaskTests extends ESTestCase { public void testTaskInfoToString() { - String nodeId = randomAsciiOfLength(10); + String nodeId = randomAlphaOfLength(10); long taskId = randomIntBetween(0, 100000); long startTime = randomNonNegativeLong(); long runningTime = randomNonNegativeLong(); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequestTests.java index 4b531267d3ae9..77b5ccc09abad 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequestTests.java @@ -59,16 +59,16 @@ public class ClusterRerouteRequestTests extends ESTestCase { private static final int ROUNDS = 30; private final List> RANDOM_COMMAND_GENERATORS = unmodifiableList( Arrays.> asList( - () -> new AllocateReplicaAllocationCommand(randomAsciiOfLengthBetween(2, 10), between(0, 1000), - randomAsciiOfLengthBetween(2, 10)), - () -> new AllocateEmptyPrimaryAllocationCommand(randomAsciiOfLengthBetween(2, 10), between(0, 1000), - randomAsciiOfLengthBetween(2, 10), randomBoolean()), - () -> new AllocateStalePrimaryAllocationCommand(randomAsciiOfLengthBetween(2, 10), between(0, 1000), - randomAsciiOfLengthBetween(2, 10), randomBoolean()), - () -> new CancelAllocationCommand(randomAsciiOfLengthBetween(2, 10), between(0, 1000), - randomAsciiOfLengthBetween(2, 10), randomBoolean()), - () -> new MoveAllocationCommand(randomAsciiOfLengthBetween(2, 10), between(0, 1000), - randomAsciiOfLengthBetween(2, 10), randomAsciiOfLengthBetween(2, 10)))); + () -> new AllocateReplicaAllocationCommand(randomAlphaOfLengthBetween(2, 10), between(0, 1000), + randomAlphaOfLengthBetween(2, 10)), + () -> new AllocateEmptyPrimaryAllocationCommand(randomAlphaOfLengthBetween(2, 10), between(0, 1000), + randomAlphaOfLengthBetween(2, 10), randomBoolean()), + () -> new AllocateStalePrimaryAllocationCommand(randomAlphaOfLengthBetween(2, 10), between(0, 1000), + randomAlphaOfLengthBetween(2, 10), randomBoolean()), + () -> new CancelAllocationCommand(randomAlphaOfLengthBetween(2, 10), between(0, 1000), + randomAlphaOfLengthBetween(2, 10), randomBoolean()), + () -> new MoveAllocationCommand(randomAlphaOfLengthBetween(2, 10), between(0, 1000), + randomAlphaOfLengthBetween(2, 10), randomAlphaOfLengthBetween(2, 10)))); private final NamedWriteableRegistry namedWriteableRegistry; public ClusterRerouteRequestTests() { diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java index f5fa046f4c2cd..e21635596b9e7 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java @@ -34,7 +34,7 @@ public void testSerialization() throws Exception { int numIndices = randomIntBetween(1, 5); String[] indices = new String[numIndices]; for (int i = 0; i < numIndices; i++) { - indices[i] = randomAsciiOfLengthBetween(3, 10); + indices[i] = randomAlphaOfLengthBetween(3, 10); } request.indices(indices); } @@ -43,13 +43,13 @@ public void testSerialization() throws Exception { IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean())); } if (randomBoolean()) { - request.preference(randomAsciiOfLengthBetween(3, 10)); + request.preference(randomAlphaOfLengthBetween(3, 10)); } if (randomBoolean()) { int numRoutings = randomIntBetween(1, 3); String[] routings = new String[numRoutings]; for (int i = 0; i < numRoutings; i++) { - routings[i] = randomAsciiOfLengthBetween(3, 10); + routings[i] = randomAlphaOfLengthBetween(3, 10); } request.routing(routings); } diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java index 9c5b1ae894438..5181e943c2df4 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java @@ -54,9 +54,9 @@ public void testSerialization() throws Exception { int numShards = randomIntBetween(1, 10); ClusterSearchShardsGroup[] clusterSearchShardsGroups = new ClusterSearchShardsGroup[numShards]; for (int i = 0; i < numShards; i++) { - String index = randomAsciiOfLengthBetween(3, 10); - ShardId shardId = new ShardId(index, randomAsciiOfLength(12), i); - String nodeId = randomAsciiOfLength(10); + String index = randomAlphaOfLengthBetween(3, 10); + ShardId shardId = new ShardId(index, randomAlphaOfLength(12), i); + String nodeId = randomAlphaOfLength(10); ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, nodeId, randomBoolean(), ShardRoutingState.STARTED); clusterSearchShardsGroups[i] = new ClusterSearchShardsGroup(shardId, new ShardRouting[]{shardRouting}); DiscoveryNode node = new DiscoveryNode(shardRouting.currentNodeId(), diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/alias/AliasActionsTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/alias/AliasActionsTests.java index 8cd3f271b7b79..4a4aa736332cf 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/alias/AliasActionsTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/alias/AliasActionsTests.java @@ -47,9 +47,9 @@ public void testValidate() { assertEquals("One of [index] or [indices] is required", e.getMessage()); } else { Exception e = expectThrows(IllegalArgumentException.class, - () -> new AliasActions(type).alias(randomAsciiOfLength(5)).validate()); + () -> new AliasActions(type).alias(randomAlphaOfLength(5)).validate()); assertEquals("One of [index] or [indices] is required", e.getMessage()); - e = expectThrows(IllegalArgumentException.class, () -> new AliasActions(type).index(randomAsciiOfLength(5)).validate()); + e = expectThrows(IllegalArgumentException.class, () -> new AliasActions(type).index(randomAlphaOfLength(5)).validate()); assertEquals("One of [alias] or [aliases] is required", e.getMessage()); } } @@ -156,8 +156,8 @@ public void testParseAdd() throws IOException { } public void testParseAddDefaultRouting() throws IOException { - String index = randomAsciiOfLength(5); - String alias = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); + String alias = randomAlphaOfLength(5); Object searchRouting = randomRouting(); Object indexRouting = randomRouting(); XContentBuilder b = XContentBuilder.builder(randomFrom(XContentType.values()).xContent()); @@ -217,7 +217,7 @@ public void testParseRemove() throws IOException { } public void testParseRemoveIndex() throws IOException { - String[] indices = randomBoolean() ? new String[] {randomAsciiOfLength(5)} : generateRandomStringArray(10, 5, false, false); + String[] indices = randomBoolean() ? new String[] {randomAlphaOfLength(5)} : generateRandomStringArray(10, 5, false, false); XContentBuilder b = XContentBuilder.builder(randomFrom(XContentType.values()).xContent()); b.startObject(); { b.startObject("remove_index"); { @@ -243,9 +243,9 @@ public void testParseIndexAndIndicesThrowsError() throws IOException { XContentBuilder b = XContentBuilder.builder(randomFrom(XContentType.values()).xContent()); b.startObject(); { b.startObject(randomFrom("add", "remove")); { - b.field("index", randomAsciiOfLength(5)); + b.field("index", randomAlphaOfLength(5)); b.array("indices", generateRandomStringArray(10, 5, false, false)); - b.field("alias", randomAsciiOfLength(5)); + b.field("alias", randomAlphaOfLength(5)); } b.endObject(); } @@ -261,8 +261,8 @@ public void testParseAliasAndAliasesThrowsError() throws IOException { XContentBuilder b = XContentBuilder.builder(randomFrom(XContentType.values()).xContent()); b.startObject(); { b.startObject(randomFrom("add", "remove")); { - b.field("index", randomAsciiOfLength(5)); - b.field("alias", randomAsciiOfLength(5)); + b.field("index", randomAlphaOfLength(5)); + b.field("alias", randomAlphaOfLength(5)); b.array("aliases", generateRandomStringArray(10, 5, false, false)); } b.endObject(); @@ -278,27 +278,27 @@ public void testParseAliasAndAliasesThrowsError() throws IOException { public void testRoundTrip() throws IOException { AliasActions action = new AliasActions(randomFrom(AliasActions.Type.values())); if (randomBoolean()) { - action.index(randomAsciiOfLength(5)); + action.index(randomAlphaOfLength(5)); } else { action.indices(generateRandomStringArray(5, 5, false, false)); } if (action.actionType() != AliasActions.Type.REMOVE_INDEX) { if (randomBoolean()) { - action.alias(randomAsciiOfLength(5)); + action.alias(randomAlphaOfLength(5)); } else { action.aliases(generateRandomStringArray(5, 5, false, false)); } } if (action.actionType() == AliasActions.Type.ADD) { if (randomBoolean()) { - action.filter(randomAsciiOfLength(10)); + action.filter(randomAlphaOfLength(10)); } if (randomBoolean()) { if (randomBoolean()) { - action.routing(randomAsciiOfLength(5)); + action.routing(randomAlphaOfLength(5)); } else { - action.searchRouting(randomAsciiOfLength(5)); - action.indexRouting(randomAsciiOfLength(5)); + action.searchRouting(randomAlphaOfLength(5)); + action.indexRouting(randomAlphaOfLength(5)); } } } @@ -322,11 +322,11 @@ private Map randomMap(int maxDepth) { if (maxDepth > 0) { value = randomMap(maxDepth - 1); } else { - value = randomAsciiOfLength(5); + value = randomAlphaOfLength(5); } break; case 1: - value = randomAsciiOfLength(5); + value = randomAlphaOfLength(5); break; case 2: value = randomBoolean(); @@ -337,12 +337,12 @@ private Map randomMap(int maxDepth) { default: throw new UnsupportedOperationException(); } - result.put(randomAsciiOfLength(5), value); + result.put(randomAlphaOfLength(5), value); } return result; } private Object randomRouting() { - return randomBoolean() ? randomAsciiOfLength(5) : randomInt(); + return randomBoolean() ? randomAlphaOfLength(5) : randomInt(); } } diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestTests.java index 213616eec6847..920ba2e9715f0 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequestTests.java @@ -31,7 +31,7 @@ public class RolloverRequestTests extends ESTestCase { public void testConditionsParsing() throws Exception { - final RolloverRequest request = new RolloverRequest(randomAsciiOfLength(10), randomAsciiOfLength(10)); + final RolloverRequest request = new RolloverRequest(randomAlphaOfLength(10), randomAlphaOfLength(10)); final XContentBuilder builder = XContentFactory.jsonBuilder() .startObject() .startObject("conditions") @@ -56,7 +56,7 @@ public void testConditionsParsing() throws Exception { } public void testParsingWithIndexSettings() throws Exception { - final RolloverRequest request = new RolloverRequest(randomAsciiOfLength(10), randomAsciiOfLength(10)); + final RolloverRequest request = new RolloverRequest(randomAlphaOfLength(10), randomAlphaOfLength(10)); final XContentBuilder builder = XContentFactory.jsonBuilder() .startObject() .startObject("conditions") diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java index 9e80e92a281b6..9d62bd825f3d5 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java @@ -34,9 +34,6 @@ import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.test.ESTestCase; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; import java.util.HashSet; import java.util.List; @@ -60,7 +57,7 @@ public void testEvaluateConditions() throws Exception { .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - final IndexMetaData metaData = IndexMetaData.builder(randomAsciiOfLength(10)) + final IndexMetaData metaData = IndexMetaData.builder(randomAlphaOfLength(10)) .creationDate(System.currentTimeMillis() - TimeValue.timeValueHours(3).getMillis()) .settings(settings) .build(); @@ -95,9 +92,9 @@ public void testEvaluateConditions() throws Exception { } public void testCreateUpdateAliasRequest() throws Exception { - String sourceAlias = randomAsciiOfLength(10); - String sourceIndex = randomAsciiOfLength(10); - String targetIndex = randomAsciiOfLength(10); + String sourceAlias = randomAlphaOfLength(10); + String sourceIndex = randomAlphaOfLength(10); + String targetIndex = randomAlphaOfLength(10); final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias, targetIndex); final IndicesAliasesClusterStateUpdateRequest updateRequest = TransportRolloverAction.prepareRolloverAliasesUpdateRequest(sourceIndex, targetIndex, rolloverRequest); @@ -122,10 +119,10 @@ public void testCreateUpdateAliasRequest() throws Exception { } public void testValidation() throws Exception { - String index1 = randomAsciiOfLength(10); - String alias = randomAsciiOfLength(10); - String index2 = randomAsciiOfLength(10); - String aliasWithMultipleIndices = randomAsciiOfLength(10); + String index1 = randomAlphaOfLength(10); + String alias = randomAlphaOfLength(10); + String index2 = randomAlphaOfLength(10); + String aliasWithMultipleIndices = randomAlphaOfLength(10); final Settings settings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) @@ -145,24 +142,24 @@ public void testValidation() throws Exception { expectThrows(IllegalArgumentException.class, () -> TransportRolloverAction.validate(metaData, new RolloverRequest(aliasWithMultipleIndices, - randomAsciiOfLength(10)))); + randomAlphaOfLength(10)))); expectThrows(IllegalArgumentException.class, () -> TransportRolloverAction.validate(metaData, new RolloverRequest(randomFrom(index1, index2), - randomAsciiOfLength(10)))); + randomAlphaOfLength(10)))); expectThrows(IllegalArgumentException.class, () -> - TransportRolloverAction.validate(metaData, new RolloverRequest(randomAsciiOfLength(5), - randomAsciiOfLength(10))) + TransportRolloverAction.validate(metaData, new RolloverRequest(randomAlphaOfLength(5), + randomAlphaOfLength(10))) ); - TransportRolloverAction.validate(metaData, new RolloverRequest(alias, randomAsciiOfLength(10))); + TransportRolloverAction.validate(metaData, new RolloverRequest(alias, randomAlphaOfLength(10))); } public void testGenerateRolloverIndexName() throws Exception { - String invalidIndexName = randomAsciiOfLength(10) + "A"; + String invalidIndexName = randomAlphaOfLength(10) + "A"; IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(Settings.EMPTY); expectThrows(IllegalArgumentException.class, () -> TransportRolloverAction.generateRolloverIndexName(invalidIndexName, indexNameExpressionResolver)); int num = randomIntBetween(0, 100); - final String indexPrefix = randomAsciiOfLength(10); + final String indexPrefix = randomAlphaOfLength(10); String indexEndingInNumbers = indexPrefix + "-" + num; assertThat(TransportRolloverAction.generateRolloverIndexName(indexEndingInNumbers, indexNameExpressionResolver), equalTo(indexPrefix + "-" + String.format(Locale.ROOT, "%06d", num + 1))); @@ -175,9 +172,9 @@ public void testGenerateRolloverIndexName() throws Exception { } public void testCreateIndexRequest() throws Exception { - String alias = randomAsciiOfLength(10); - String rolloverIndex = randomAsciiOfLength(10); - final RolloverRequest rolloverRequest = new RolloverRequest(alias, randomAsciiOfLength(10)); + String alias = randomAlphaOfLength(10); + String rolloverIndex = randomAlphaOfLength(10); + final RolloverRequest rolloverRequest = new RolloverRequest(alias, randomAlphaOfLength(10)); final ActiveShardCount activeShardCount = randomBoolean() ? ActiveShardCount.ALL : ActiveShardCount.ONE; rolloverRequest.setWaitForActiveShards(activeShardCount); final Settings settings = Settings.builder() diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/shrink/TransportShrinkActionTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/shrink/TransportShrinkActionTests.java index 5446d74911d7a..b24c8dca79a58 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/shrink/TransportShrinkActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/shrink/TransportShrinkActionTests.java @@ -110,7 +110,7 @@ public void testErrorCondition() { } public void testShrinkIndexSettings() { - String indexName = randomAsciiOfLength(10); + String indexName = randomAlphaOfLength(10); // create one that won't fail ClusterState clusterState = ClusterState.builder(createClusterState(indexName, randomIntBetween(2, 10), 0, Settings.builder() diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTests.java index b419be0465bdc..0f24a520b84b7 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTests.java @@ -32,7 +32,7 @@ public class IndicesStatsResponseTests extends ESTestCase { public void testInvalidLevel() { final IndicesStatsResponse response = new IndicesStatsResponse(); - final String level = randomAsciiOfLength(16); + final String level = randomAlphaOfLength(16); final ToXContent.Params params = new ToXContent.MapParams(Collections.singletonMap("level", level)); final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> response.toXContent(null, params)); assertThat( diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java index e92f6e40ab38b..f2d51539c6d3b 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java @@ -93,9 +93,9 @@ public void testFailureToAndFromXContent() throws IOException { final XContentType xContentType = randomFrom(XContentType.values()); int itemId = randomIntBetween(0, 100); - String index = randomAsciiOfLength(5); - String type = randomAsciiOfLength(5); - String id = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); + String type = randomAlphaOfLength(5); + String id = randomAlphaOfLength(5); DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values()); final Tuple exceptions = randomExceptions(); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java index 91bdc83bba71c..08622b327eb97 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java @@ -71,9 +71,9 @@ public void testToAndFromXContent() throws IOException { bulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v1()); expectedBulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v2()); } else { - String index = randomAsciiOfLength(5); - String type = randomAsciiOfLength(5); - String id = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); + String type = randomAlphaOfLength(5); + String id = randomAlphaOfLength(5); Tuple failures = randomExceptions(); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java b/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java index ea36597499528..a2cd7e9820a12 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java @@ -59,7 +59,7 @@ public void setUp() throws Exception { // Stash some random headers so we can assert that we preserve them bulkClient.threadPool().getThreadContext().stashContext(); expectedHeaders.clear(); - expectedHeaders.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + expectedHeaders.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); bulkClient.threadPool().getThreadContext().putHeader(expectedHeaders); } diff --git a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollParallelizationHelperTests.java b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollParallelizationHelperTests.java index e9291aa381df4..5a12d54de04ca 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollParallelizationHelperTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollParallelizationHelperTests.java @@ -44,7 +44,7 @@ public void testSliceIntoSubRequests() throws IOException { searchRequest.source().slice(null); } int times = between(2, 100); - String field = randomBoolean() ? UidFieldMapper.NAME : randomAsciiOfLength(5); + String field = randomBoolean() ? UidFieldMapper.NAME : randomAlphaOfLength(5); int currentSliceId = 0; for (SearchRequest slice : sliceIntoSubRequests(searchRequest, field, times)) { assertEquals(field, slice.source().slice().getField()); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollResponseTests.java b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollResponseTests.java index bb5d8bf26f66d..1d2146c1515d1 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollResponseTests.java @@ -64,9 +64,9 @@ private List randomSearchFailures() { Integer shardId = null; String nodeId = null; if (randomBoolean()) { - index = randomAsciiOfLength(5); + index = randomAlphaOfLength(5); shardId = randomInt(); - nodeId = usually() ? randomAsciiOfLength(5) : null; + nodeId = usually() ? randomAlphaOfLength(5) : null; } return singletonList(new SearchFailure(new ElasticsearchException("foo"), index, shardId, nodeId)); } diff --git a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskStatusTests.java b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskStatusTests.java index b621264e7ea52..503fe1db7cd32 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskStatusTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskStatusTests.java @@ -105,7 +105,7 @@ public static BulkByScrollTask.Status randomStatus() { return null; } if (randomBoolean()) { - return new BulkByScrollTask.StatusOrException(new ElasticsearchException(randomAsciiOfLength(5))); + return new BulkByScrollTask.StatusOrException(new ElasticsearchException(randomAlphaOfLength(5))); } return new BulkByScrollTask.StatusOrException(randomWorkingStatus(i)); }) diff --git a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskTests.java b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskTests.java index 0d353e426ec80..ff0eae5552042 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/BulkByScrollTaskTests.java @@ -19,13 +19,11 @@ package org.elasticsearch.action.bulk.byscroll; -import org.elasticsearch.action.bulk.byscroll.BulkByScrollTask; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; import java.io.IOException; import java.util.Arrays; @@ -139,7 +137,7 @@ public void testMergeStatuses() { mergedRequestsPerSecond += requestsPerSecond; mergedThrottledUntil = timeValueNanos(min(mergedThrottledUntil.nanos(), throttledUntil.nanos())); } - String reasonCancelled = randomBoolean() ? randomAsciiOfLength(10) : null; + String reasonCancelled = randomBoolean() ? randomAlphaOfLength(10) : null; BulkByScrollTask.Status merged = new BulkByScrollTask.Status(Arrays.asList(statuses), reasonCancelled); assertEquals(mergedTotal, merged.getTotal()); assertEquals(mergedUpdated, merged.getUpdated()); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/DeleteByQueryRequestTests.java b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/DeleteByQueryRequestTests.java index 474072cc739bd..f5c00f63de9c1 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/byscroll/DeleteByQueryRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/byscroll/DeleteByQueryRequestTests.java @@ -66,7 +66,7 @@ public void testDeleteteByQueryRequestImplementsIndicesRequestReplaceable() { @Override protected DeleteByQueryRequest newRequest() { - return new DeleteByQueryRequest(new SearchRequest(randomAsciiOfLength(5))); + return new DeleteByQueryRequest(new SearchRequest(randomAlphaOfLength(5))); } @Override diff --git a/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java b/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java index 9ff1aabb844ef..cbf514375c22b 100644 --- a/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java @@ -91,11 +91,11 @@ public void testToAndFromXContent() throws IOException { * expected {@link DeleteResponse} after parsing. */ public static Tuple randomDeleteResponse() { - String index = randomAsciiOfLength(5); - String indexUUid = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); + String indexUUid = randomAlphaOfLength(5); int shardId = randomIntBetween(0, 5); - String type = randomAsciiOfLength(5); - String id = randomAsciiOfLength(5); + String type = randomAlphaOfLength(5); + String id = randomAlphaOfLength(5); long seqNo = randomFrom(SequenceNumbersService.UNASSIGNED_SEQ_NO, randomNonNegativeLong(), (long) randomIntBetween(0, 10000)); long version = randomBoolean() ? randomNonNegativeLong() : randomIntBetween(0, 10000); boolean found = randomBoolean(); diff --git a/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestTests.java b/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestTests.java index abc89e356259e..6b68112d5d52f 100644 --- a/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesRequestTests.java @@ -31,7 +31,7 @@ private FieldCapabilitiesRequest randomRequest() { int size = randomIntBetween(1, 20); String[] randomFields = new String[size]; for (int i = 0; i < size; i++) { - randomFields[i] = randomAsciiOfLengthBetween(5, 10); + randomFields[i] = randomAlphaOfLengthBetween(5, 10); } request.fields(randomFields); return request; diff --git a/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java b/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java index 8d64f9a538c56..2eaf1d4832f3f 100644 --- a/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java @@ -32,11 +32,11 @@ private FieldCapabilitiesResponse randomResponse() { Map > fieldMap = new HashMap<> (); int numFields = randomInt(10); for (int i = 0; i < numFields; i++) { - String fieldName = randomAsciiOfLengthBetween(5, 10); + String fieldName = randomAlphaOfLengthBetween(5, 10); int numIndices = randomIntBetween(1, 5); Map indexFieldMap = new HashMap<> (); for (int j = 0; j < numIndices; j++) { - String index = randomAsciiOfLengthBetween(10, 20); + String index = randomAlphaOfLengthBetween(10, 20); indexFieldMap.put(index, FieldCapabilitiesTests.randomFieldCaps()); } fieldMap.put(fieldName, indexFieldMap); diff --git a/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesTests.java b/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesTests.java index a1df6b6529b8a..b485d51bd6a60 100644 --- a/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesTests.java +++ b/core/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesTests.java @@ -85,25 +85,25 @@ static FieldCapabilities randomFieldCaps() { if (randomBoolean()) { indices = new String[randomIntBetween(1, 5)]; for (int i = 0; i < indices.length; i++) { - indices[i] = randomAsciiOfLengthBetween(5, 20); + indices[i] = randomAlphaOfLengthBetween(5, 20); } } String[] nonSearchableIndices = null; if (randomBoolean()) { nonSearchableIndices = new String[randomIntBetween(0, 5)]; for (int i = 0; i < nonSearchableIndices.length; i++) { - nonSearchableIndices[i] = randomAsciiOfLengthBetween(5, 20); + nonSearchableIndices[i] = randomAlphaOfLengthBetween(5, 20); } } String[] nonAggregatableIndices = null; if (randomBoolean()) { nonAggregatableIndices = new String[randomIntBetween(0, 5)]; for (int i = 0; i < nonAggregatableIndices.length; i++) { - nonAggregatableIndices[i] = randomAsciiOfLengthBetween(5, 20); + nonAggregatableIndices[i] = randomAlphaOfLengthBetween(5, 20); } } - return new FieldCapabilities(randomAsciiOfLengthBetween(5, 20), - randomAsciiOfLengthBetween(5, 20), randomBoolean(), randomBoolean(), + return new FieldCapabilities(randomAlphaOfLengthBetween(5, 20), + randomAlphaOfLengthBetween(5, 20), randomBoolean(), randomBoolean(), indices, nonSearchableIndices, nonAggregatableIndices); } } diff --git a/core/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java b/core/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java index 4e539d8582fc3..73c77d0629295 100644 --- a/core/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java @@ -53,8 +53,8 @@ public void testAddWithInvalidKey() throws IOException { final ParsingException e = expectThrows( ParsingException.class, () -> { - final String defaultIndex = randomAsciiOfLength(5); - final String defaultType = randomAsciiOfLength(3); + final String defaultIndex = randomAlphaOfLength(5); + final String defaultType = randomAlphaOfLength(3); final FetchSourceContext fetchSource = FetchSourceContext.FETCH_SOURCE; mgr.add(defaultIndex, defaultType, null, fetchSource, null, parser, true); }); @@ -80,8 +80,8 @@ public void testUnexpectedField() throws IOException { final ParsingException e = expectThrows( ParsingException.class, () -> { - final String defaultIndex = randomAsciiOfLength(5); - final String defaultType = randomAsciiOfLength(3); + final String defaultIndex = randomAlphaOfLength(5); + final String defaultType = randomAlphaOfLength(3); final FetchSourceContext fetchSource = FetchSourceContext.FETCH_SOURCE; mgr.add(defaultIndex, defaultType, null, fetchSource, null, parser, true); }); @@ -105,7 +105,7 @@ public void testAddWithInvalidSourceValueIsRejected() throws Exception { MultiGetRequest multiGetRequest = new MultiGetRequest(); IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> multiGetRequest.add - (randomAsciiOfLength(5), randomAsciiOfLength(3), null, FetchSourceContext.FETCH_SOURCE, null, parser, true)); + (randomAlphaOfLength(5), randomAlphaOfLength(3), null, FetchSourceContext.FETCH_SOURCE, null, parser, true)); assertEquals("Failed to parse value [" + sourceValue + "] as only [true] or [false] are allowed.", ex.getMessage()); } @@ -125,7 +125,7 @@ public void testAddWithValidSourceValueIsAccepted() throws Exception { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add( - randomAsciiOfLength(5), randomAsciiOfLength(3), null, FetchSourceContext.FETCH_SOURCE, null, parser, true); + randomAlphaOfLength(5), randomAlphaOfLength(3), null, FetchSourceContext.FETCH_SOURCE, null, parser, true); assertEquals(2, multiGetRequest.getItems().size()); } diff --git a/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java b/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java index 1d3d2c1b553ae..a130f10d65908 100644 --- a/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java @@ -34,7 +34,7 @@ public class MultiGetShardRequestTests extends ESTestCase { public void testSerialization() throws IOException { MultiGetRequest multiGetRequest = new MultiGetRequest(); if (randomBoolean()) { - multiGetRequest.preference(randomAsciiOfLength(randomIntBetween(1, 10))); + multiGetRequest.preference(randomAlphaOfLength(randomIntBetween(1, 10))); } if (randomBoolean()) { multiGetRequest.realtime(false); @@ -45,12 +45,12 @@ public void testSerialization() throws IOException { MultiGetShardRequest multiGetShardRequest = new MultiGetShardRequest(multiGetRequest, "index", 0); int numItems = iterations(10, 30); for (int i = 0; i < numItems; i++) { - MultiGetRequest.Item item = new MultiGetRequest.Item("alias-" + randomAsciiOfLength(randomIntBetween(1, 10)), "type", "id-" + i); + MultiGetRequest.Item item = new MultiGetRequest.Item("alias-" + randomAlphaOfLength(randomIntBetween(1, 10)), "type", "id-" + i); if (randomBoolean()) { int numFields = randomIntBetween(1, 5); String[] fields = new String[numFields]; for (int j = 0; j < fields.length; j++) { - fields[j] = randomAsciiOfLength(randomIntBetween(1, 10)); + fields[j] = randomAlphaOfLength(randomIntBetween(1, 10)); } item.storedFields(fields); } diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 5b9649a7559c8..b4836496f885f 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -90,19 +90,19 @@ public void testCreateOperationRejectsVersions() { } public void testIndexingRejectsLongIds() { - String id = randomAsciiOfLength(511); + String id = randomAlphaOfLength(511); IndexRequest request = new IndexRequest("index", "type", id); request.source("{}", XContentType.JSON); ActionRequestValidationException validate = request.validate(); assertNull(validate); - id = randomAsciiOfLength(512); + id = randomAlphaOfLength(512); request = new IndexRequest("index", "type", id); request.source("{}", XContentType.JSON); validate = request.validate(); assertNull(validate); - id = randomAsciiOfLength(513); + id = randomAlphaOfLength(513); request = new IndexRequest("index", "type", id); request.source("{}", XContentType.JSON); validate = request.validate(); @@ -130,9 +130,9 @@ public void testAutoGenIdTimestampIsSet() { } public void testIndexResponse() { - ShardId shardId = new ShardId(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomIntBetween(0, 1000)); - String type = randomAsciiOfLengthBetween(3, 10); - String id = randomAsciiOfLengthBetween(3, 10); + ShardId shardId = new ShardId(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), randomIntBetween(0, 1000)); + String type = randomAlphaOfLengthBetween(3, 10); + String id = randomAlphaOfLengthBetween(3, 10); long version = randomLong(); boolean created = randomBoolean(); IndexResponse indexResponse = new IndexResponse(shardId, type, id, SequenceNumbersService.UNASSIGNED_SEQ_NO, version, created); diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java index 24393e56e0219..4afa0f7298c49 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java @@ -104,11 +104,11 @@ public static void assertDocWriteResponse(DocWriteResponse expected, DocWriteRes * expected {@link IndexResponse} after parsing. */ public static Tuple randomIndexResponse() { - String index = randomAsciiOfLength(5); - String indexUUid = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); + String indexUUid = randomAlphaOfLength(5); int shardId = randomIntBetween(0, 5); - String type = randomAsciiOfLength(5); - String id = randomAsciiOfLength(5); + String type = randomAlphaOfLength(5); + String id = randomAlphaOfLength(5); long seqNo = randomFrom(SequenceNumbersService.UNASSIGNED_SEQ_NO, randomNonNegativeLong(), (long) randomIntBetween(0, 10000)); long version = randomBoolean() ? randomNonNegativeLong() : randomIntBetween(0, 10000); boolean created = randomBoolean(); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java index ab5d30c6f9b7e..6f8280277e0fc 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java @@ -71,14 +71,14 @@ public void testParseUsingPipelineStore() throws Exception { requestContent.put(Fields.DOCS, docs); for (int i = 0; i < numDocs; i++) { Map doc = new HashMap<>(); - String index = randomAsciiOfLengthBetween(1, 10); - String type = randomAsciiOfLengthBetween(1, 10); - String id = randomAsciiOfLengthBetween(1, 10); + String index = randomAlphaOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); + String id = randomAlphaOfLengthBetween(1, 10); doc.put(INDEX.getFieldName(), index); doc.put(TYPE.getFieldName(), type); doc.put(ID.getFieldName(), id); - String fieldName = randomAsciiOfLengthBetween(1, 10); - String fieldValue = randomAsciiOfLengthBetween(1, 10); + String fieldName = randomAlphaOfLengthBetween(1, 10); + String fieldValue = randomAlphaOfLengthBetween(1, 10); doc.put(Fields.SOURCE, Collections.singletonMap(fieldName, fieldValue)); docs.add(doc); Map expectedDoc = new HashMap<>(); @@ -116,14 +116,14 @@ public void testParseWithProvidedPipeline() throws Exception { requestContent.put(Fields.DOCS, docs); for (int i = 0; i < numDocs; i++) { Map doc = new HashMap<>(); - String index = randomAsciiOfLengthBetween(1, 10); - String type = randomAsciiOfLengthBetween(1, 10); - String id = randomAsciiOfLengthBetween(1, 10); + String index = randomAlphaOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); + String id = randomAlphaOfLengthBetween(1, 10); doc.put(INDEX.getFieldName(), index); doc.put(TYPE.getFieldName(), type); doc.put(ID.getFieldName(), id); - String fieldName = randomAsciiOfLengthBetween(1, 10); - String fieldValue = randomAsciiOfLengthBetween(1, 10); + String fieldName = randomAlphaOfLengthBetween(1, 10); + String fieldValue = randomAlphaOfLengthBetween(1, 10); doc.put(Fields.SOURCE, Collections.singletonMap(fieldName, fieldValue)); docs.add(doc); Map expectedDoc = new HashMap<>(); @@ -190,7 +190,7 @@ public void testNullPipelineId() { } public void testNonExistentPipelineId() { - String pipelineId = randomAsciiOfLengthBetween(1, 10); + String pipelineId = randomAlphaOfLengthBetween(1, 10); Map requestContent = new HashMap<>(); List> docs = new ArrayList<>(); requestContent.put(Fields.DOCS, docs); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java index 86dc56cdd04c0..e3ca936bb84f2 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java @@ -38,7 +38,7 @@ public void testSerialization() throws IOException { SimulatePipelineRequest request = new SimulatePipelineRequest(new BytesArray(""), XContentType.JSON); // Sometimes we set an id if (randomBoolean()) { - request.setId(randomAsciiOfLengthBetween(1, 10)); + request.setId(randomAlphaOfLengthBetween(1, 10)); } // Sometimes we explicitly set a boolean (with whatever value) diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java index ad308b01bf2c2..be448a09db892 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineResponseTests.java @@ -39,7 +39,7 @@ public class SimulatePipelineResponseTests extends ESTestCase { public void testSerialization() throws IOException { boolean isVerbose = randomBoolean(); - String id = randomBoolean() ? randomAsciiOfLengthBetween(1, 10) : null; + String id = randomBoolean() ? randomAlphaOfLengthBetween(1, 10) : null; int numResults = randomIntBetween(1, 10); List results = new ArrayList<>(numResults); for (int i = 0; i < numResults; i++) { @@ -49,7 +49,7 @@ public void testSerialization() throws IOException { int numProcessors = randomIntBetween(1, 10); List processorResults = new ArrayList<>(numProcessors); for (int j = 0; j < numProcessors; j++) { - String processorTag = randomAsciiOfLengthBetween(1, 10); + String processorTag = randomAlphaOfLengthBetween(1, 10); SimulateProcessorResult processorResult; if (isFailure) { processorResult = new SimulateProcessorResult(processorTag, new IllegalArgumentException("test")); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java index 75d2d5834feb6..3014a1a4ae61d 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulateProcessorResultTests.java @@ -36,7 +36,7 @@ public class SimulateProcessorResultTests extends ESTestCase { public void testSerialization() throws IOException { - String processorTag = randomAsciiOfLengthBetween(1, 10); + String processorTag = randomAlphaOfLengthBetween(1, 10); boolean isSuccessful = randomBoolean(); boolean isIgnoredException = randomBoolean(); SimulateProcessorResult simulateProcessorResult; diff --git a/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java b/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java index d5417526c0cae..c5f67e235061e 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/WriteableIngestDocumentTests.java @@ -45,12 +45,12 @@ public void testEqualsAndHashcode() throws Exception { Map sourceAndMetadata = RandomDocumentPicks.randomSource(random()); int numFields = randomIntBetween(1, IngestDocument.MetaData.values().length); for (int i = 0; i < numFields; i++) { - sourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAsciiOfLengthBetween(5, 10)); + sourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAlphaOfLengthBetween(5, 10)); } Map ingestMetadata = new HashMap<>(); numFields = randomIntBetween(1, 5); for (int i = 0; i < numFields; i++) { - ingestMetadata.put(randomAsciiOfLengthBetween(5, 10), randomAsciiOfLengthBetween(5, 10)); + ingestMetadata.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); } WriteableIngestDocument ingestDocument = new WriteableIngestDocument(new IngestDocument(sourceAndMetadata, ingestMetadata)); @@ -65,7 +65,7 @@ public void testEqualsAndHashcode() throws Exception { if (randomBoolean()) { numFields = randomIntBetween(1, IngestDocument.MetaData.values().length); for (int i = 0; i < numFields; i++) { - otherSourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAsciiOfLengthBetween(5, 10)); + otherSourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAlphaOfLengthBetween(5, 10)); } changed = true; } @@ -75,7 +75,7 @@ public void testEqualsAndHashcode() throws Exception { otherIngestMetadata = new HashMap<>(); numFields = randomIntBetween(1, 5); for (int i = 0; i < numFields; i++) { - otherIngestMetadata.put(randomAsciiOfLengthBetween(5, 10), randomAsciiOfLengthBetween(5, 10)); + otherIngestMetadata.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); } changed = true; } else { @@ -101,12 +101,12 @@ public void testSerialization() throws IOException { Map sourceAndMetadata = RandomDocumentPicks.randomSource(random()); int numFields = randomIntBetween(1, IngestDocument.MetaData.values().length); for (int i = 0; i < numFields; i++) { - sourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAsciiOfLengthBetween(5, 10)); + sourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAlphaOfLengthBetween(5, 10)); } Map ingestMetadata = new HashMap<>(); numFields = randomIntBetween(1, 5); for (int i = 0; i < numFields; i++) { - ingestMetadata.put(randomAsciiOfLengthBetween(5, 10), randomAsciiOfLengthBetween(5, 10)); + ingestMetadata.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); } WriteableIngestDocument writeableIngestDocument = new WriteableIngestDocument(new IngestDocument(sourceAndMetadata, ingestMetadata)); diff --git a/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java b/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java index f673af9d96363..3407007d64707 100644 --- a/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java @@ -54,7 +54,7 @@ public class MainActionTests extends ESTestCase { public void testMainResponseSerialization() throws IOException { final String nodeName = "node1"; final ClusterName clusterName = new ClusterName("cluster1"); - final String clusterUUID = randomAsciiOfLengthBetween(10, 20); + final String clusterUUID = randomAlphaOfLengthBetween(10, 20); final boolean available = randomBoolean(); final Version version = Version.CURRENT; final Build build = Build.CURRENT; @@ -73,7 +73,7 @@ public void testMainResponseSerialization() throws IOException { } public void testMainResponseXContent() throws IOException { - String clusterUUID = randomAsciiOfLengthBetween(10, 20); + String clusterUUID = randomAlphaOfLengthBetween(10, 20); final MainResponse mainResponse = new MainResponse("node1", Version.CURRENT, new ClusterName("cluster1"), clusterUUID, Build.CURRENT, false); final String expected = "{" + diff --git a/core/src/test/java/org/elasticsearch/action/main/MainResponseTests.java b/core/src/test/java/org/elasticsearch/action/main/MainResponseTests.java index 9233ca1530839..429fe5cac7eeb 100644 --- a/core/src/test/java/org/elasticsearch/action/main/MainResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/main/MainResponseTests.java @@ -41,10 +41,10 @@ public class MainResponseTests extends ESTestCase { public static MainResponse createTestItem() { - String clusterUuid = randomAsciiOfLength(10); - ClusterName clusterName = new ClusterName(randomAsciiOfLength(10)); - String nodeName = randomAsciiOfLength(10); - Build build = new Build(randomAsciiOfLength(8), new Date(randomNonNegativeLong()).toString(), randomBoolean()); + String clusterUuid = randomAlphaOfLength(10); + ClusterName clusterName = new ClusterName(randomAlphaOfLength(10)); + String nodeName = randomAlphaOfLength(10); + Build build = new Build(randomAlphaOfLength(8), new Date(randomNonNegativeLong()).toString(), randomBoolean()); Version version = VersionUtils.randomVersion(random()); boolean available = randomBoolean(); return new MainResponse(nodeName, version, clusterName, clusterUuid , build, available); @@ -108,10 +108,10 @@ private static MainResponse mutate(MainResponse o) { ClusterName clusterName = o.getClusterName(); switch (randomIntBetween(0, 5)) { case 0: - clusterUuid = clusterUuid + randomAsciiOfLength(5); + clusterUuid = clusterUuid + randomAlphaOfLength(5); break; case 1: - nodeName = nodeName + randomAsciiOfLength(5); + nodeName = nodeName + randomAlphaOfLength(5); break; case 2: available = !available; @@ -124,7 +124,7 @@ private static MainResponse mutate(MainResponse o) { version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random())); break; case 5: - clusterName = new ClusterName(clusterName + randomAsciiOfLength(5)); + clusterName = new ClusterName(clusterName + randomAlphaOfLength(5)); break; } return new MainResponse(nodeName, version, clusterName, clusterUuid, build, available); diff --git a/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java b/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java index 76541a79bb904..632a160d8eedf 100644 --- a/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java +++ b/core/src/test/java/org/elasticsearch/action/search/SearchPhaseControllerTests.java @@ -70,7 +70,7 @@ public void setup() { public void testSort() throws Exception { List suggestions = new ArrayList<>(); for (int i = 0; i < randomIntBetween(1, 5); i++) { - suggestions.add(new CompletionSuggestion(randomAsciiOfLength(randomIntBetween(1, 5)), randomIntBetween(1, 20))); + suggestions.add(new CompletionSuggestion(randomAlphaOfLength(randomIntBetween(1, 5)), randomIntBetween(1, 20))); } int nShards = randomIntBetween(1, 20); int queryResultSize = randomBoolean() ? 0 : randomIntBetween(1, nShards * 2); @@ -99,7 +99,7 @@ public void testSortIsIdempotent() throws IOException { public void testMerge() throws IOException { List suggestions = new ArrayList<>(); for (int i = 0; i < randomIntBetween(1, 5); i++) { - suggestions.add(new CompletionSuggestion(randomAsciiOfLength(randomIntBetween(1, 5)), randomIntBetween(1, 20))); + suggestions.add(new CompletionSuggestion(randomAlphaOfLength(randomIntBetween(1, 5)), randomIntBetween(1, 20))); } int nShards = randomIntBetween(1, 20); int queryResultSize = randomBoolean() ? 0 : randomIntBetween(1, nShards * 2); diff --git a/core/src/test/java/org/elasticsearch/action/search/SearchScrollRequestTests.java b/core/src/test/java/org/elasticsearch/action/search/SearchScrollRequestTests.java index e483c718ab882..9773d7320d0f2 100644 --- a/core/src/test/java/org/elasticsearch/action/search/SearchScrollRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/search/SearchScrollRequestTests.java @@ -65,7 +65,7 @@ public void testEqualsAndHashcode() { } public static SearchScrollRequest createSearchScrollRequest() { - SearchScrollRequest searchScrollRequest = new SearchScrollRequest(randomAsciiOfLengthBetween(3, 10)); + SearchScrollRequest searchScrollRequest = new SearchScrollRequest(randomAlphaOfLengthBetween(3, 10)); searchScrollRequest.scroll(randomPositiveTimeValue()); return searchScrollRequest; } diff --git a/core/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java b/core/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java index 94a7e1d44bb81..96afbb276d5b9 100644 --- a/core/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java +++ b/core/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java @@ -35,11 +35,11 @@ public class ShardSearchFailureTests extends ESTestCase { public static ShardSearchFailure createTestItem() { - String randomMessage = randomAsciiOfLengthBetween(3, 20); + String randomMessage = randomAlphaOfLengthBetween(3, 20); Exception ex = new ParsingException(0, 0, randomMessage , new IllegalArgumentException("some bad argument")); - String nodeId = randomAsciiOfLengthBetween(5, 10); - String indexName = randomAsciiOfLengthBetween(5, 10); - String indexUuid = randomAsciiOfLengthBetween(5, 10); + String nodeId = randomAlphaOfLengthBetween(5, 10); + String indexName = randomAlphaOfLengthBetween(5, 10); + String indexUuid = randomAlphaOfLengthBetween(5, 10); int shardId = randomInt(); return new ShardSearchFailure(ex, new SearchShardTarget(nodeId, new ShardId(new Index(indexName, indexUuid), shardId))); diff --git a/core/src/test/java/org/elasticsearch/action/support/ActiveShardCountTests.java b/core/src/test/java/org/elasticsearch/action/support/ActiveShardCountTests.java index 598a672fb2d98..4fb03bf393b3c 100644 --- a/core/src/test/java/org/elasticsearch/action/support/ActiveShardCountTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/ActiveShardCountTests.java @@ -62,7 +62,7 @@ public void testParseString() { assertSame(ActiveShardCount.parseString("0"), ActiveShardCount.NONE); int value = randomIntBetween(1, 50); assertEquals(ActiveShardCount.parseString(value + ""), ActiveShardCount.from(value)); - expectThrows(IllegalArgumentException.class, () -> ActiveShardCount.parseString(randomAsciiOfLengthBetween(4, 8))); + expectThrows(IllegalArgumentException.class, () -> ActiveShardCount.parseString(randomAlphaOfLengthBetween(4, 8))); expectThrows(IllegalArgumentException.class, () -> ActiveShardCount.parseString("-1")); // magic numbers not exposed through API expectThrows(IllegalArgumentException.class, () -> ActiveShardCount.parseString("-2")); expectThrows(IllegalArgumentException.class, () -> ActiveShardCount.parseString(randomIntBetween(-10, -3) + "")); @@ -200,7 +200,7 @@ private ClusterState startPrimaries(final ClusterState clusterState, final Strin final IndexShardRoutingTable shardRoutingTable = shardEntry.value; for (ShardRouting shardRouting : shardRoutingTable.getShards()) { if (shardRouting.primary()) { - shardRouting = shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize()) + shardRouting = shardRouting.initialize(randomAlphaOfLength(8), null, shardRouting.getExpectedShardSize()) .moveToStarted(); } newIndexRoutingTable.addShard(shardRouting); @@ -224,7 +224,7 @@ private ClusterState startLessThanWaitOnShards(final ClusterState clusterState, assertTrue(shardRouting.active()); } else { if (numToStart > 0) { - shardRouting = shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize()) + shardRouting = shardRouting.initialize(randomAlphaOfLength(8), null, shardRouting.getExpectedShardSize()) .moveToStarted(); numToStart--; } @@ -250,7 +250,7 @@ private ClusterState startWaitOnShards(final ClusterState clusterState, final St } else { if (shardRouting.active() == false) { if (numToStart > 0) { - shardRouting = shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize()) + shardRouting = shardRouting.initialize(randomAlphaOfLength(8), null, shardRouting.getExpectedShardSize()) .moveToStarted(); numToStart--; } @@ -276,7 +276,7 @@ private ClusterState startAllShards(final ClusterState clusterState, final Strin assertTrue(shardRouting.active()); } else { if (shardRouting.active() == false) { - shardRouting = shardRouting.initialize(randomAsciiOfLength(8), null, shardRouting.getExpectedShardSize()) + shardRouting = shardRouting.initialize(randomAlphaOfLength(8), null, shardRouting.getExpectedShardSize()) .moveToStarted(); } } diff --git a/core/src/test/java/org/elasticsearch/action/support/AutoCreateIndexTests.java b/core/src/test/java/org/elasticsearch/action/support/AutoCreateIndexTests.java index 189fd1de59cfc..159be84de0791 100644 --- a/core/src/test/java/org/elasticsearch/action/support/AutoCreateIndexTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/AutoCreateIndexTests.java @@ -85,24 +85,24 @@ public void testAutoCreationDisabled() { Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), false).build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> - autoCreateIndex.shouldAutoCreate(randomAsciiOfLengthBetween(1, 10), buildClusterState())); + autoCreateIndex.shouldAutoCreate(randomAlphaOfLengthBetween(1, 10), buildClusterState())); assertEquals("no such index and [action.auto_create_index] is [false]", e.getMessage()); } public void testAutoCreationEnabled() { Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), true).build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); - assertThat(autoCreateIndex.shouldAutoCreate(randomAsciiOfLengthBetween(1, 10), buildClusterState()), equalTo(true)); + assertThat(autoCreateIndex.shouldAutoCreate(randomAlphaOfLengthBetween(1, 10), buildClusterState()), equalTo(true)); } public void testDefaultAutoCreation() { AutoCreateIndex autoCreateIndex = newAutoCreateIndex(Settings.EMPTY); - assertThat(autoCreateIndex.shouldAutoCreate(randomAsciiOfLengthBetween(1, 10), buildClusterState()), equalTo(true)); + assertThat(autoCreateIndex.shouldAutoCreate(randomAlphaOfLengthBetween(1, 10), buildClusterState()), equalTo(true)); } public void testExistingIndex() { Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), randomFrom(true, false, - randomAsciiOfLengthBetween(7, 10))).build(); + randomAlphaOfLengthBetween(7, 10))).build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); assertThat(autoCreateIndex.shouldAutoCreate(randomFrom("index1", "index2", "index3"), buildClusterState("index1", "index2", "index3")), equalTo(false)); @@ -110,11 +110,11 @@ public void testExistingIndex() { public void testDynamicMappingDisabled() { Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), randomFrom(true, - randomAsciiOfLengthBetween(1, 10))) + randomAlphaOfLengthBetween(1, 10))) .put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false).build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> - autoCreateIndex.shouldAutoCreate(randomAsciiOfLengthBetween(1, 10), buildClusterState())); + autoCreateIndex.shouldAutoCreate(randomAlphaOfLengthBetween(1, 10), buildClusterState())); assertEquals("no such index and [index.mapper.dynamic] is [false]", e.getMessage()); } @@ -123,18 +123,18 @@ public void testAutoCreationPatternEnabled() { .build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build(); - assertThat(autoCreateIndex.shouldAutoCreate("index" + randomAsciiOfLengthBetween(1, 5), clusterState), equalTo(true)); - expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5)); + assertThat(autoCreateIndex.shouldAutoCreate("index" + randomAlphaOfLengthBetween(1, 5), clusterState), equalTo(true)); + expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAlphaOfLengthBetween(1, 5)); } public void testAutoCreationPatternDisabled() { Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), "-index*").build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build(); - expectForbidden(clusterState, autoCreateIndex, "index" + randomAsciiOfLengthBetween(1, 5), "-index*"); + expectForbidden(clusterState, autoCreateIndex, "index" + randomAlphaOfLengthBetween(1, 5), "-index*"); /* When patterns are specified, even if the are all negative, the default is can't create. So a pure negative pattern is the same * as false, really. */ - expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5)); + expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAlphaOfLengthBetween(1, 5)); } public void testAutoCreationMultiplePatternsWithWildcards() { @@ -142,9 +142,9 @@ public void testAutoCreationMultiplePatternsWithWildcards() { randomFrom("+test*,-index*", "test*,-index*")).build(); AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build(); - expectForbidden(clusterState, autoCreateIndex, "index" + randomAsciiOfLengthBetween(1, 5), "-index*"); - assertThat(autoCreateIndex.shouldAutoCreate("test" + randomAsciiOfLengthBetween(1, 5), clusterState), equalTo(true)); - expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5)); + expectForbidden(clusterState, autoCreateIndex, "index" + randomAlphaOfLengthBetween(1, 5), "-index*"); + assertThat(autoCreateIndex.shouldAutoCreate("test" + randomAlphaOfLengthBetween(1, 5), clusterState), equalTo(true)); + expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAlphaOfLengthBetween(1, 5)); } public void testAutoCreationMultiplePatternsNoWildcards() { @@ -152,9 +152,9 @@ public void testAutoCreationMultiplePatternsNoWildcards() { AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings); ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build(); assertThat(autoCreateIndex.shouldAutoCreate("test1", clusterState), equalTo(true)); - expectNotMatch(clusterState, autoCreateIndex, "index" + randomAsciiOfLengthBetween(1, 5)); - expectNotMatch(clusterState, autoCreateIndex, "test" + randomAsciiOfLengthBetween(2, 5)); - expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5)); + expectNotMatch(clusterState, autoCreateIndex, "index" + randomAlphaOfLengthBetween(1, 5)); + expectNotMatch(clusterState, autoCreateIndex, "test" + randomAlphaOfLengthBetween(2, 5)); + expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAlphaOfLengthBetween(1, 5)); } public void testAutoCreationMultipleIndexNames() { @@ -163,7 +163,7 @@ public void testAutoCreationMultipleIndexNames() { ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build(); assertThat(autoCreateIndex.shouldAutoCreate("test1", clusterState), equalTo(true)); assertThat(autoCreateIndex.shouldAutoCreate("test2", clusterState), equalTo(true)); - expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5)); + expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAlphaOfLengthBetween(1, 5)); } public void testAutoCreationConflictingPatternsFirstWins() { @@ -173,7 +173,7 @@ public void testAutoCreationConflictingPatternsFirstWins() { ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build(); assertThat(autoCreateIndex.shouldAutoCreate("test1", clusterState), equalTo(true)); expectForbidden(clusterState, autoCreateIndex, "test2", "-test2"); - expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5)); + expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAlphaOfLengthBetween(1, 5)); } public void testUpdate() { diff --git a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java index 230812bec880f..aa61c2569d818 100644 --- a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java @@ -41,8 +41,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; -import java.util.stream.IntStream; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; @@ -69,7 +67,7 @@ public void testActionFiltersRequest() throws ExecutionException, InterruptedExc filters.add(new RequestTestFilter(order, randomFrom(RequestOperation.values()))); } - String actionName = randomAsciiOfLength(randomInt(30)); + String actionName = randomAlphaOfLength(randomInt(30)); ActionFilters actionFilters = new ActionFilters(filters); TransportAction transportAction = new TransportAction(Settings.EMPTY, actionName, null, actionFilters, null, new TaskManager(Settings.EMPTY)) { @Override @@ -153,7 +151,7 @@ public void exe Set filters = new HashSet<>(); filters.add(testFilter); - String actionName = randomAsciiOfLength(randomInt(30)); + String actionName = randomAlphaOfLength(randomInt(30)); ActionFilters actionFilters = new ActionFilters(filters); TransportAction transportAction = new TransportAction(Settings.EMPTY, actionName, null, actionFilters, null, new TaskManager(Settings.EMPTY)) { @Override diff --git a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java index de3af56a1203f..c3ca62616fda2 100644 --- a/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java @@ -113,9 +113,9 @@ public void testNewResponse() { nodeResponses.add(new OtherNodeResponse()); List failures = mockList( () -> new FailedNodeException( - randomAsciiOfLength(8), - randomAsciiOfLength(8), - new IllegalStateException(randomAsciiOfLength(8))), + randomAlphaOfLength(8), + randomAlphaOfLength(8), + new IllegalStateException(randomAlphaOfLength(8))), randomIntBetween(0, 2)); List allResponses = new ArrayList<>(expectedNodeResponses); @@ -192,7 +192,7 @@ public void setUp() throws Exception { Map attributes = new HashMap<>(); Set roles = new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values()))); if (frequently()) { - attributes.put("custom", randomBoolean() ? "match" : randomAsciiOfLengthBetween(3, 5)); + attributes.put("custom", randomBoolean() ? "match" : randomAlphaOfLengthBetween(3, 5)); } final DiscoveryNode node = newNode(i, attributes, roles); discoBuilder = discoBuilder.add(node); diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java index 459bafd3af2f1..7447e9fb55994 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java @@ -175,7 +175,7 @@ public void testDemotedPrimary() throws Exception { } // add in-sync allocation id that doesn't have a corresponding routing entry state = ClusterState.builder(state).metaData(MetaData.builder(state.metaData()).put(IndexMetaData.builder(indexMetaData) - .putInSyncAllocationIds(0, Sets.union(indexMetaData.inSyncAllocationIds(0), Sets.newHashSet(randomAsciiOfLength(10)))))) + .putInSyncAllocationIds(0, Sets.union(indexMetaData.inSyncAllocationIds(0), Sets.newHashSet(randomAlphaOfLength(10)))))) .build(); final Set expectedReplicas = getExpectedReplicas(shardId, state); diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java index 1bd943704707d..abe0e9977dd36 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java @@ -64,7 +64,6 @@ import org.elasticsearch.indices.IndexClosedException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.cluster.ClusterStateChanges; -import org.elasticsearch.node.NodeClosedException; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.transport.CapturingTransport; @@ -626,7 +625,7 @@ public void testReplicaProxy() throws InterruptedException, ExecutionException { assertThat(captures, arrayWithSize(1)); if (randomBoolean()) { final TransportReplicationAction.ReplicaResponse response = - new TransportReplicationAction.ReplicaResponse(randomAsciiOfLength(10), randomLong()); + new TransportReplicationAction.ReplicaResponse(randomAlphaOfLength(10), randomLong()); transport.handleResponse(captures[0].requestId, response); assertTrue(listener.isDone()); assertThat(listener.get(), equalTo(response)); diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java index 781059fd85945..3d57c27e373c1 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java @@ -20,14 +20,11 @@ package org.elasticsearch.action.support.replication; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.action.support.WriteResponse; -import org.elasticsearch.action.support.replication.ClusterStateCreationUtils; -import org.elasticsearch.action.support.replication.ReplicationOperation; import org.elasticsearch.action.support.replication.ReplicationOperation.ReplicaResponse; import org.elasticsearch.client.transport.NoNodeAvailableException; import org.elasticsearch.cluster.ClusterState; @@ -56,7 +53,6 @@ import org.elasticsearch.test.transport.CapturingTransport; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportException; import org.elasticsearch.transport.TransportResponse; import org.elasticsearch.transport.TransportService; @@ -290,7 +286,7 @@ public void testReplicaProxy() throws InterruptedException, ExecutionException { assertThat(captures, arrayWithSize(1)); if (randomBoolean()) { final TransportReplicationAction.ReplicaResponse response = - new TransportReplicationAction.ReplicaResponse(randomAsciiOfLength(10), randomLong()); + new TransportReplicationAction.ReplicaResponse(randomAlphaOfLength(10), randomLong()); transport.handleResponse(captures[0].requestId, response); assertTrue(listener.isDone()); assertThat(listener.get(), equalTo(response)); diff --git a/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java b/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java index b75733fcf13c6..4958e1c78aa51 100644 --- a/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java @@ -417,12 +417,12 @@ public void testToAndFromXContent() throws IOException { updateRequest.docAsUpsert(randomBoolean()); } else { ScriptType scriptType = randomFrom(ScriptType.values()); - String scriptLang = (scriptType != ScriptType.STORED) ? randomAsciiOfLength(10) : null; - String scriptIdOrCode = randomAsciiOfLength(10); + String scriptLang = (scriptType != ScriptType.STORED) ? randomAlphaOfLength(10) : null; + String scriptIdOrCode = randomAlphaOfLength(10); int nbScriptParams = randomIntBetween(0, 5); Map scriptParams = new HashMap<>(nbScriptParams); for (int i = 0; i < nbScriptParams; i++) { - scriptParams.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + scriptParams.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } updateRequest.script(new Script(scriptType, scriptLang, scriptIdOrCode, scriptParams)); updateRequest.scriptedUpsert(randomBoolean()); @@ -435,7 +435,7 @@ public void testToAndFromXContent() throws IOException { if (randomBoolean()) { String[] fields = new String[randomIntBetween(0, 5)]; for (int i = 0; i < fields.length; i++) { - fields[i] = randomAsciiOfLength(5); + fields[i] = randomAlphaOfLength(5); } updateRequest.fields(fields); } @@ -445,11 +445,11 @@ public void testToAndFromXContent() throws IOException { } else { String[] includes = new String[randomIntBetween(0, 5)]; for (int i = 0; i < includes.length; i++) { - includes[i] = randomAsciiOfLength(5); + includes[i] = randomAlphaOfLength(5); } String[] excludes = new String[randomIntBetween(0, 5)]; for (int i = 0; i < excludes.length; i++) { - excludes[i] = randomAsciiOfLength(5); + excludes[i] = randomAlphaOfLength(5); } if (randomBoolean()) { updateRequest.fetchSource(includes, excludes); diff --git a/core/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java b/core/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java index 2b73b1964ee3c..bd9e355182151 100644 --- a/core/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java @@ -130,7 +130,7 @@ public static Tuple randomUpdateResponse(XConten String id = actualGetResult.getId(); long version = actualGetResult.getVersion(); DocWriteResponse.Result result = actualGetResult.isExists() ? DocWriteResponse.Result.UPDATED : DocWriteResponse.Result.NOT_FOUND; - String indexUUid = randomAsciiOfLength(5); + String indexUUid = randomAlphaOfLength(5); int shardId = randomIntBetween(0, 5); // We also want small number values (randomNonNegativeLong() tend to generate high numbers) diff --git a/core/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java b/core/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java index 677309531c94e..0b1c04ac5ccdc 100644 --- a/core/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java +++ b/core/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java @@ -488,7 +488,7 @@ String onError() { } }; - final String command = randomAsciiOfLength(16); + final String command = randomAlphaOfLength(16); runMightForkTest( check, isSystemCallFilterInstalled, @@ -516,7 +516,7 @@ String onOutOfMemoryError() { } }; - final String command = randomAsciiOfLength(16); + final String command = randomAlphaOfLength(16); runMightForkTest( check, isSystemCallFilterInstalled, @@ -652,7 +652,7 @@ boolean isJava8() { @Override String jvmVendor() { - return randomAsciiOfLength(8); + return randomAlphaOfLength(8); } }; diff --git a/core/src/test/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandlerTests.java b/core/src/test/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandlerTests.java index e4ff83e9b4057..6e40153b467d9 100644 --- a/core/src/test/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandlerTests.java +++ b/core/src/test/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandlerTests.java @@ -60,7 +60,7 @@ public void testUncaughtError() throws InterruptedException { new IOError(new IOException("fatal")), new Error() {}); final Thread thread = new Thread(() -> { throw error; }); - final String name = randomAsciiOfLength(10); + final String name = randomAlphaOfLength(10); thread.setName(name); final AtomicBoolean halt = new AtomicBoolean(); final AtomicInteger observedStatus = new AtomicInteger(); @@ -103,7 +103,7 @@ void onNonFatalUncaught(String threadName, Throwable t) { public void testUncaughtException() throws InterruptedException { final RuntimeException e = new RuntimeException("boom"); final Thread thread = new Thread(() -> { throw e; }); - final String name = randomAsciiOfLength(10); + final String name = randomAlphaOfLength(10); thread.setName(name); final AtomicReference threadNameReference = new AtomicReference<>(); final AtomicReference throwableReference = new AtomicReference<>(); diff --git a/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java b/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java index d3a0e0b3e4e14..43d866a47b797 100644 --- a/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java +++ b/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java @@ -40,8 +40,6 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; -import org.junit.After; -import org.junit.Before; import java.util.HashMap; import java.util.Map; @@ -122,7 +120,7 @@ public void testActions() { } public void testOverrideHeader() throws Exception { - String key1Val = randomAsciiOfLength(5); + String key1Val = randomAlphaOfLength(5); Map expected = new HashMap<>(); expected.put("key1", key1Val); expected.put("key2", "val 2"); diff --git a/core/src/test/java/org/elasticsearch/client/ParentTaskAssigningClientTests.java b/core/src/test/java/org/elasticsearch/client/ParentTaskAssigningClientTests.java index 35406ef1153f1..ee577d4df2f46 100644 --- a/core/src/test/java/org/elasticsearch/client/ParentTaskAssigningClientTests.java +++ b/core/src/test/java/org/elasticsearch/client/ParentTaskAssigningClientTests.java @@ -33,7 +33,7 @@ public class ParentTaskAssigningClientTests extends ESTestCase { public void testSetsParentId() { - TaskId[] parentTaskId = new TaskId[] {new TaskId(randomAsciiOfLength(3), randomLong())}; + TaskId[] parentTaskId = new TaskId[] {new TaskId(randomAlphaOfLength(3), randomLong())}; // This mock will do nothing but verify that parentTaskId is set on all requests sent to it. NoOpClient mock = new NoOpClient(getTestName()) { diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java index 240add84464bb..b7ea45dd13a3d 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java @@ -529,7 +529,7 @@ private static ClusterState executeIndicesChangesTest(final ClusterState previou default: throw new AssertionError("Unhandled mode [" + deletionQuantity + "]"); } final boolean changeClusterUUID = randomBoolean(); - final List addedIndices = addIndices(numAdd, randomAsciiOfLengthBetween(5, 10)); + final List addedIndices = addIndices(numAdd, randomAlphaOfLengthBetween(5, 10)); List delIndices; if (changeClusterUUID) { delIndices = new ArrayList<>(); diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterInfoTests.java b/core/src/test/java/org/elasticsearch/cluster/ClusterInfoTests.java index 1fcab355d65ac..35a7ea2aab80c 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterInfoTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterInfoTests.java @@ -46,9 +46,9 @@ private static ImmutableOpenMap randomDiskUsage() { int numEntries = randomIntBetween(0, 128); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(numEntries); for (int i = 0; i < numEntries; i++) { - String key = randomAsciiOfLength(32); + String key = randomAlphaOfLength(32); DiskUsage diskUsage = new DiskUsage( - randomAsciiOfLength(4), randomAsciiOfLength(4), randomAsciiOfLength(4), + randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4), randomIntBetween(0, Integer.MAX_VALUE), randomIntBetween(0, Integer.MAX_VALUE) ); builder.put(key, diskUsage); @@ -60,7 +60,7 @@ private static ImmutableOpenMap randomShardSizes() { int numEntries = randomIntBetween(0, 128); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(numEntries); for (int i = 0; i < numEntries; i++) { - String key = randomAsciiOfLength(32); + String key = randomAlphaOfLength(32); long shardSize = randomIntBetween(0, Integer.MAX_VALUE); builder.put(key, shardSize); } @@ -71,9 +71,9 @@ private static ImmutableOpenMap randomRoutingToDataPath() int numEntries = randomIntBetween(0, 128); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(numEntries); for (int i = 0; i < numEntries; i++) { - ShardId shardId = new ShardId(randomAsciiOfLength(32), randomAsciiOfLength(32), randomIntBetween(0, Integer.MAX_VALUE)); + ShardId shardId = new ShardId(randomAlphaOfLength(32), randomAlphaOfLength(32), randomIntBetween(0, Integer.MAX_VALUE)); ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, null, randomBoolean(), ShardRoutingState.UNASSIGNED); - builder.put(shardRouting, randomAsciiOfLength(32)); + builder.put(shardRouting, randomAlphaOfLength(32)); } return builder.build(); } diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 722f9590b56dd..29e3080bfe1ca 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -207,7 +207,7 @@ private ClusterState.Builder randomNodes(ClusterState clusterState) { } int additionalNodeCount = randomIntBetween(1, 20); for (int i = 0; i < additionalNodeCount; i++) { - nodes.add(new DiscoveryNode("node-" + randomAsciiOfLength(10), buildNewFakeTransportAddress(), + nodes.add(new DiscoveryNode("node-" + randomAlphaOfLength(10), buildNewFakeTransportAddress(), emptyMap(), emptySet(), randomVersion(random()))); } return ClusterState.builder(clusterState).nodes(nodes); @@ -250,7 +250,7 @@ private IndexRoutingTable randomIndexRoutingTable(String index, String[] nodeIds for (int j = 0; j < replicaCount; j++) { UnassignedInfo unassignedInfo = null; if (randomInt(5) == 1) { - unassignedInfo = new UnassignedInfo(randomReason(), randomAsciiOfLength(10)); + unassignedInfo = new UnassignedInfo(randomReason(), randomAlphaOfLength(10)); } if (availableNodeIds.isEmpty()) { break; @@ -420,7 +420,7 @@ private Settings randomSettings(Settings settings) { } int settingsCount = randomInt(10); for (int i = 0; i < settingsCount; i++) { - builder.put(randomAsciiOfLength(10), randomAsciiOfLength(10)); + builder.put(randomAlphaOfLength(10), randomAlphaOfLength(10)); } return builder.build(); @@ -541,7 +541,7 @@ public IndexMetaData randomChange(IndexMetaData part) { if (randomBoolean() && part.getAliases().isEmpty() == false) { builder.removeAlias(randomFrom(part.getAliases().keys().toArray(String.class))); } else { - builder.putAlias(AliasMetaData.builder(randomAsciiOfLength(10))); + builder.putAlias(AliasMetaData.builder(randomAlphaOfLength(10))); } break; case 2: @@ -606,7 +606,7 @@ private AliasMetaData randomAlias() { builder.filter(QueryBuilders.termQuery("test", randomRealisticUnicodeOfCodepointLength(10)).toString()); } if (randomBoolean()) { - builder.routing(randomAsciiOfLength(10)); + builder.routing(randomAlphaOfLength(10)); } return builder.build(); } diff --git a/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java b/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java index 229862afa9b7a..f2cd88a27a7c1 100644 --- a/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.LocalClusterUpdateTask; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -366,7 +365,7 @@ private List generateClusterStates(final ClusterState originalClus final Set nodeIds = new HashSet<>(); final int numNodes = randomIntBetween(numberOfReplicas + 1, 10); for (int i = 0; i < numNodes; i++) { - nodeIds.add(randomAsciiOfLength(8)); + nodeIds.add(randomAlphaOfLength(8)); } final List clusterStates = new ArrayList<>(); diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java index e47ca2184f8d6..4f235e52636b3 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java @@ -51,7 +51,7 @@ public void testNormal() throws Exception { int numIndexExpressions = randomIntBetween(1, 9); List indexExpressions = new ArrayList<>(numIndexExpressions); for (int i = 0; i < numIndexExpressions; i++) { - indexExpressions.add(randomAsciiOfLength(10)); + indexExpressions.add(randomAlphaOfLength(10)); } List result = expressionResolver.resolve(context, indexExpressions); assertThat(result.size(), equalTo(indexExpressions.size())); diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/IndexGraveyardTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/IndexGraveyardTests.java index ea5c55d9a0d66..9178d112acade 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/IndexGraveyardTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/IndexGraveyardTests.java @@ -49,7 +49,7 @@ public void testEquals() { final IndexGraveyard graveyard = createRandom(); assertThat(graveyard, equalTo(IndexGraveyard.builder(graveyard).build())); final IndexGraveyard.Builder newGraveyard = IndexGraveyard.builder(graveyard); - newGraveyard.addTombstone(new Index(randomAsciiOfLengthBetween(4, 15), UUIDs.randomBase64UUID())); + newGraveyard.addTombstone(new Index(randomAlphaOfLengthBetween(4, 15), UUIDs.randomBase64UUID())); assertThat(newGraveyard.build(), not(graveyard)); } @@ -140,7 +140,7 @@ public void testContains() { for (final Index index : indices) { assertTrue(indexGraveyard.containsIndex(index)); } - assertFalse(indexGraveyard.containsIndex(new Index(randomAsciiOfLength(6), UUIDs.randomBase64UUID()))); + assertFalse(indexGraveyard.containsIndex(new Index(randomAlphaOfLength(6), UUIDs.randomBase64UUID()))); } public static IndexGraveyard createRandom() { diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java index 5486868040fae..387b66d031b37 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java @@ -152,7 +152,7 @@ public void testValidateShrinkIndex() { } public void testShrinkIndexSettings() { - String indexName = randomAsciiOfLength(10); + String indexName = randomAlphaOfLength(10); List versions = Arrays.asList(VersionUtils.randomVersion(random()), VersionUtils.randomVersion(random()), VersionUtils.randomVersion(random())); versions.sort((l, r) -> Long.compare(l.id, r.id)); diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexServiceTests.java index 0ad36713810ff..d65a35b8c26c6 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexServiceTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexServiceTests.java @@ -55,7 +55,7 @@ public void testDeleteMissing() { } public void testDeleteSnapshotting() { - String index = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); Snapshot snapshot = new Snapshot("doesn't matter", new SnapshotId("snapshot name", "snapshot uuid")); SnapshotsInProgress snaps = new SnapshotsInProgress(new SnapshotsInProgress.Entry(snapshot, true, false, SnapshotsInProgress.State.INIT, singletonList(new IndexId(index, "doesn't matter")), @@ -71,7 +71,7 @@ SnapshotsInProgress.State.INIT, singletonList(new IndexId(index, "doesn't matter public void testDeleteUnassigned() { // Create an unassigned index - String index = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); ClusterState before = clusterState(index); // Mock the built reroute diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java index 3b894eb8d7c3b..e5b52d8cf52bf 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java @@ -60,7 +60,7 @@ public MetaDataIndexAliasesServiceTests() { public void testAddAndRemove() { // Create a state with a single index - String index = randomAsciiOfLength(5); + String index = randomAlphaOfLength(5); ClusterState before = createIndex(ClusterState.builder(ClusterName.DEFAULT).build(), index); // Add an alias to it diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index 4ad1c5fdd08b7..9200e04c7127a 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -22,7 +22,6 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks; import org.elasticsearch.Version; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; import java.util.ArrayList; import java.util.Arrays; @@ -172,7 +171,7 @@ private static List randomNodes(final int numNodes) { for (int i = 0; i < numNodes; i++) { Map attributes = new HashMap<>(); if (frequently()) { - attributes.put("custom", randomBoolean() ? "match" : randomAsciiOfLengthBetween(3, 5)); + attributes.put("custom", randomBoolean() ? "match" : randomAlphaOfLengthBetween(3, 5)); } final DiscoveryNode node = newNode(idGenerator.getAndIncrement(), attributes, new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values())))); diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/OperationRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/OperationRoutingTests.java index c24a86176dcd4..d8cc4c0938677 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/OperationRoutingTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/OperationRoutingTests.java @@ -58,7 +58,7 @@ public void testGenerateShardId() { assertEquals(shardSplits[1], (shardSplits[1] / shardSplits[2]) * shardSplits[2]); IndexMetaData metaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(shardSplits[0]) .numberOfReplicas(1).build(); - String term = randomAsciiOfLength(10); + String term = randomAlphaOfLength(10); final int shard = OperationRouting.generateShardId(metaData, term, null); IndexMetaData shrunk = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(shardSplits[1]) .numberOfReplicas(1) diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/RandomShardRoutingMutator.java b/core/src/test/java/org/elasticsearch/cluster/routing/RandomShardRoutingMutator.java index 69773e9992138..932d24f2da1f7 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/RandomShardRoutingMutator.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/RandomShardRoutingMutator.java @@ -21,7 +21,7 @@ import java.util.Set; -import static org.elasticsearch.test.ESTestCase.randomAsciiOfLength; +import static org.elasticsearch.test.ESTestCase.randomAlphaOfLength; import static org.elasticsearch.test.ESTestCase.randomFrom; import static org.elasticsearch.test.ESTestCase.randomInt; @@ -37,9 +37,9 @@ public static ShardRouting randomChange(ShardRouting shardRouting, Set n switch (randomInt(2)) { case 0: if (shardRouting.unassigned() == false && shardRouting.primary() == false) { - shardRouting = shardRouting.moveToUnassigned(new UnassignedInfo(randomReason(), randomAsciiOfLength(10))); + shardRouting = shardRouting.moveToUnassigned(new UnassignedInfo(randomReason(), randomAlphaOfLength(10))); } else if (shardRouting.unassignedInfo() != null) { - shardRouting = shardRouting.updateUnassigned(new UnassignedInfo(randomReason(), randomAsciiOfLength(10)), + shardRouting = shardRouting.updateUnassigned(new UnassignedInfo(randomReason(), randomAlphaOfLength(10)), shardRouting.recoverySource()); } break; diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/ShardRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/ShardRoutingTests.java index a4c8d0e424717..0b0f6ae273d8e 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/ShardRoutingTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/ShardRoutingTests.java @@ -118,7 +118,7 @@ public void testEqualsIgnoringVersion() { switch (changeId) { case 0: // change index - ShardId shardId = new ShardId(new Index("blubb", randomAsciiOfLength(10)), otherRouting.id()); + ShardId shardId = new ShardId(new Index("blubb", randomAlphaOfLength(10)), otherRouting.id()); otherRouting = new ShardRouting(shardId, otherRouting.currentNodeId(), otherRouting.relocatingNodeId(), otherRouting.primary(), otherRouting.state(), otherRouting.recoverySource(), otherRouting.unassignedInfo(), otherRouting.allocationId(), otherRouting.getExpectedShardSize()); diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java index 4fffcebc79b1c..73ff7544ae2c4 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java @@ -79,9 +79,9 @@ public void testReasonOrdinalOrder() { public void testSerialization() throws Exception { UnassignedInfo.Reason reason = RandomPicks.randomFrom(random(), UnassignedInfo.Reason.values()); UnassignedInfo meta = reason == UnassignedInfo.Reason.ALLOCATION_FAILED ? - new UnassignedInfo(reason, randomBoolean() ? randomAsciiOfLength(4) : null, null, randomIntBetween(1, 100), System.nanoTime(), + new UnassignedInfo(reason, randomBoolean() ? randomAlphaOfLength(4) : null, null, randomIntBetween(1, 100), System.nanoTime(), System.currentTimeMillis(), false, AllocationStatus.NO_ATTEMPT): - new UnassignedInfo(reason, randomBoolean() ? randomAsciiOfLength(4) : null); + new UnassignedInfo(reason, randomBoolean() ? randomAlphaOfLength(4) : null); BytesStreamOutput out = new BytesStreamOutput(); meta.writeTo(out); out.close(); diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocateUnassignedDecisionTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocateUnassignedDecisionTests.java index 0f194a0f912b2..3fcd743a8a1d4 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocateUnassignedDecisionTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocateUnassignedDecisionTests.java @@ -174,7 +174,7 @@ public void testSerialization() throws IOException { randomFrom(Decision.NO, Decision.THROTTLE, Decision.YES), 1)); AllocateUnassignedDecision decision; if (finalDecision == Decision.Type.YES) { - decision = AllocateUnassignedDecision.yes(assignedNode, randomBoolean() ? randomAsciiOfLength(5) : null, + decision = AllocateUnassignedDecision.yes(assignedNode, randomBoolean() ? randomAlphaOfLength(5) : null, nodeDecisions, randomBoolean()); } else { decision = AllocateUnassignedDecision.no(randomFrom( diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalancedSingleShardTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalancedSingleShardTests.java index cb69a5de87ffb..a63447e845b18 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalancedSingleShardTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/BalancedSingleShardTests.java @@ -191,7 +191,7 @@ public void testSingleShardBalanceProducesSameResultsAsBalanceStep() { int excludeNodesSize = randomIntBetween(0, numAddedNodes - 1); final Set excludeNodes = new HashSet<>(); for (int i = 0; i < numAddedNodes; i++) { - DiscoveryNode discoveryNode = newNode(randomAsciiOfLength(7)); + DiscoveryNode discoveryNode = newNode(randomAlphaOfLength(7)); nodesBuilder.add(discoveryNode); if (i < excludeNodesSize) { excludeNodes.add(discoveryNode.getId()); @@ -331,7 +331,7 @@ public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation alloca private ClusterState addNodesToClusterState(ClusterState clusterState, int numNodesToAdd) { DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(clusterState.nodes()); for (int i = 0; i < numNodesToAdd; i++) { - DiscoveryNode discoveryNode = newNode(randomAsciiOfLength(7)); + DiscoveryNode discoveryNode = newNode(randomAlphaOfLength(7)); nodesBuilder.add(discoveryNode); } return ClusterState.builder(clusterState).nodes(nodesBuilder).build(); @@ -352,7 +352,7 @@ public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation alloca ClusterState clusterState = ClusterStateCreationUtils.state("idx", 2, numShards); // add a new node so shards can be rebalanced there DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(clusterState.nodes()); - nodesBuilder.add(newNode(randomAsciiOfLength(7))); + nodesBuilder.add(newNode(randomAlphaOfLength(7))); clusterState = ClusterState.builder(clusterState).nodes(nodesBuilder).build(); ShardRouting shard = clusterState.routingTable().index("idx").shard(0).primaryShard(); RoutingAllocation routingAllocation = newRoutingAllocation( diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResultTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResultTests.java index 0461528fe065a..4b846c849f0fc 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResultTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResultTests.java @@ -61,7 +61,7 @@ public void testShardStore() throws IOException { assertFalse(explanation.getShardStoreInfo().isInSync()); assertFalse(explanation.getShardStoreInfo().hasMatchingSyncId()); - String allocId = randomAsciiOfLength(5); + String allocId = randomAlphaOfLength(5); boolean inSync = randomBoolean(); shardStoreInfo = new ShardStoreInfo(allocId, inSync, randomBoolean() ? new Exception("bad stuff") : null); explanation = new NodeAllocationResult(node, shardStoreInfo, decision); diff --git a/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java b/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java index c2f27beb04ee2..71fe7b262a699 100644 --- a/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java +++ b/core/src/test/java/org/elasticsearch/common/cache/CacheTests.java @@ -712,7 +712,7 @@ public void testExceptionThrownDuringConcurrentComputeIfAbsent() throws BrokenBa CyclicBarrier barrier = new CyclicBarrier(1 + numberOfThreads); - final String key = randomAsciiOfLengthBetween(2, 32); + final String key = randomAlphaOfLengthBetween(2, 32); for (int i = 0; i < numberOfThreads; i++) { Thread thread = new Thread(() -> { try { diff --git a/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java b/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java index 4a02a1f345bb7..a8b065343c974 100644 --- a/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java +++ b/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java @@ -339,8 +339,8 @@ public void testNamedWriteable() throws IOException { try (BytesStreamOutput out = new BytesStreamOutput()) { NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.singletonList( new NamedWriteableRegistry.Entry(BaseNamedWriteable.class, TestNamedWriteable.NAME, TestNamedWriteable::new))); - TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAsciiOfLengthBetween(1, 10), - randomAsciiOfLengthBetween(1, 10)); + TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAlphaOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10)); out.writeNamedWriteable(namedWriteableIn); byte[] bytes = BytesReference.toBytes(out.bytes()); @@ -360,7 +360,7 @@ public void testNamedWriteableList() throws IOException { int size = between(0, 100); List expected = new ArrayList<>(size); for (int i = 0; i < size; i++) { - expected.add(new TestNamedWriteable(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10))); + expected.add(new TestNamedWriteable(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10))); } try (BytesStreamOutput out = new BytesStreamOutput()) { @@ -386,8 +386,8 @@ public void testNamedWriteableReaderReturnsNull() throws IOException { try (BytesStreamOutput out = new BytesStreamOutput()) { NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.singletonList( new NamedWriteableRegistry.Entry(BaseNamedWriteable.class, TestNamedWriteable.NAME, (StreamInput in) -> null))); - TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAsciiOfLengthBetween(1, 10), - randomAsciiOfLengthBetween(1, 10)); + TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAlphaOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10)); out.writeNamedWriteable(namedWriteableIn); byte[] bytes = BytesReference.toBytes(out.bytes()); try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(bytes), namedWriteableRegistry)) { @@ -400,7 +400,7 @@ public void testNamedWriteableReaderReturnsNull() throws IOException { public void testOptionalWriteableReaderReturnsNull() throws IOException { try (BytesStreamOutput out = new BytesStreamOutput()) { - out.writeOptionalWriteable(new TestNamedWriteable(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10))); + out.writeOptionalWriteable(new TestNamedWriteable(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10))); StreamInput in = StreamInput.wrap(BytesReference.toBytes(out.bytes())); IOException e = expectThrows(IOException.class, () -> in.readOptionalWriteable((StreamInput ignored) -> null)); assertThat(e.getMessage(), endsWith("] returned null which is not allowed and probably means it screwed up the stream.")); @@ -417,8 +417,8 @@ public String getWriteableName() { return "intentionally-broken"; } }))); - TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAsciiOfLengthBetween(1, 10), - randomAsciiOfLengthBetween(1, 10)); + TestNamedWriteable namedWriteableIn = new TestNamedWriteable(randomAlphaOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10)); out.writeNamedWriteable(namedWriteableIn); byte[] bytes = BytesReference.toBytes(out.bytes()); try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(bytes), namedWriteableRegistry)) { @@ -461,7 +461,7 @@ public void testWriteMap() throws IOException { final int size = randomIntBetween(0, 100); final Map expected = new HashMap<>(randomIntBetween(0, 100)); for (int i = 0; i < size; ++i) { - expected.put(randomAsciiOfLength(2), randomAsciiOfLength(5)); + expected.put(randomAlphaOfLength(2), randomAlphaOfLength(5)); } final BytesStreamOutput out = new BytesStreamOutput(); @@ -482,10 +482,10 @@ public void testWriteMapOfLists() throws IOException { List list = new ArrayList<>(listSize); for (int j = 0; j < listSize; ++j) { - list.add(randomAsciiOfLength(5)); + list.add(randomAlphaOfLength(5)); } - expected.put(randomAsciiOfLength(2), list); + expected.put(randomAlphaOfLength(2), list); } final BytesStreamOutput out = new BytesStreamOutput(); @@ -633,8 +633,8 @@ public void writeTo(StreamOutput out) throws IOException { public void testWriteMapWithConsistentOrder() throws IOException { Map map = randomMap(new TreeMap<>(), randomIntBetween(2, 20), - () -> randomAsciiOfLength(5), - () -> randomAsciiOfLength(5)); + () -> randomAlphaOfLength(5), + () -> randomAlphaOfLength(5)); Map reverseMap = new TreeMap<>(Collections.reverseOrder()); reverseMap.putAll(map); @@ -655,8 +655,8 @@ public void testWriteMapWithConsistentOrder() throws IOException { public void testReadMapByUsingWriteMapWithConsistentOrder() throws IOException { Map streamOutMap = randomMap(new HashMap<>(), randomIntBetween(2, 20), - () -> randomAsciiOfLength(5), - () -> randomAsciiOfLength(5)); + () -> randomAlphaOfLength(5), + () -> randomAlphaOfLength(5)); try (BytesStreamOutput streamOut = new BytesStreamOutput()) { streamOut.writeMapWithConsistentOrder(streamOutMap); StreamInput in = StreamInput.wrap(BytesReference.toBytes(streamOut.bytes())); diff --git a/core/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java b/core/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java index f957752c71830..3f2274321a249 100644 --- a/core/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java +++ b/core/src/test/java/org/elasticsearch/common/logging/DeprecationLoggerTests.java @@ -58,7 +58,7 @@ public void testAddsHeaderWithThreadContext() throws IOException { try (ThreadContext threadContext = new ThreadContext(Settings.EMPTY)) { final Set threadContexts = Collections.singleton(threadContext); - final String param = randomAsciiOfLengthBetween(1, 5); + final String param = randomAlphaOfLengthBetween(1, 5); logger.deprecated(threadContexts, "A simple message [{}]", param); final Map> responseHeaders = threadContext.getResponseHeaders(); @@ -75,9 +75,9 @@ public void testAddsCombinedHeaderWithThreadContext() throws IOException { try (ThreadContext threadContext = new ThreadContext(Settings.EMPTY)) { final Set threadContexts = Collections.singleton(threadContext); - final String param = randomAsciiOfLengthBetween(1, 5); + final String param = randomAlphaOfLengthBetween(1, 5); logger.deprecated(threadContexts, "A simple message [{}]", param); - final String second = randomAsciiOfLengthBetween(1, 10); + final String second = randomAlphaOfLengthBetween(1, 10); logger.deprecated(threadContexts, second); final Map> responseHeaders = threadContext.getResponseHeaders(); @@ -167,7 +167,7 @@ public void testFailsWhenRemovingUnknownThreadContext() throws IOException { } public void testWarningValueFromWarningHeader() throws InterruptedException { - final String s = randomAsciiOfLength(16); + final String s = randomAlphaOfLength(16); final String first = DeprecationLogger.formatWarning(s); assertThat(DeprecationLogger.extractWarningValueFromWarningHeader(first), equalTo(s)); } diff --git a/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java b/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java index d9fe806e53b39..7c2a2f52b6017 100644 --- a/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java +++ b/core/src/test/java/org/elasticsearch/common/lucene/index/FreqTermsEnumTests.java @@ -88,7 +88,7 @@ public void setUp() throws Exception { iw = new IndexWriter(dir, conf); terms = new String[scaledRandomIntBetween(10, 300)]; for (int i = 0; i < terms.length; i++) { - terms[i] = randomAsciiOfLength(5); + terms[i] = randomAlphaOfLength(5); } int numberOfDocs = scaledRandomIntBetween(30, 300); diff --git a/core/src/test/java/org/elasticsearch/common/settings/SecureStringTests.java b/core/src/test/java/org/elasticsearch/common/settings/SecureStringTests.java index 4f9ed8ed4b9ac..50bdab1d4f9bd 100644 --- a/core/src/test/java/org/elasticsearch/common/settings/SecureStringTests.java +++ b/core/src/test/java/org/elasticsearch/common/settings/SecureStringTests.java @@ -30,7 +30,7 @@ public class SecureStringTests extends ESTestCase { public void testCloseableCharsDoesNotModifySecureString() { - final char[] password = randomAsciiOfLengthBetween(1, 32).toCharArray(); + final char[] password = randomAlphaOfLengthBetween(1, 32).toCharArray(); SecureString secureString = new SecureString(password); assertSecureStringEqualToChars(password, secureString); try (SecureString copy = secureString.clone()) { @@ -41,7 +41,7 @@ public void testCloseableCharsDoesNotModifySecureString() { } public void testClosingSecureStringDoesNotModifyCloseableChars() { - final char[] password = randomAsciiOfLengthBetween(1, 32).toCharArray(); + final char[] password = randomAlphaOfLengthBetween(1, 32).toCharArray(); SecureString secureString = new SecureString(password); assertSecureStringEqualToChars(password, secureString); SecureString copy = secureString.clone(); @@ -55,7 +55,7 @@ public void testClosingSecureStringDoesNotModifyCloseableChars() { } public void testClosingChars() { - final char[] password = randomAsciiOfLengthBetween(1, 32).toCharArray(); + final char[] password = randomAlphaOfLengthBetween(1, 32).toCharArray(); SecureString secureString = new SecureString(password); assertSecureStringEqualToChars(password, secureString); SecureString copy = secureString.clone(); @@ -71,7 +71,7 @@ public void testClosingChars() { } public void testGetCloseableCharsAfterSecureStringClosed() { - final char[] password = randomAsciiOfLengthBetween(1, 32).toCharArray(); + final char[] password = randomAlphaOfLengthBetween(1, 32).toCharArray(); SecureString secureString = new SecureString(password); assertSecureStringEqualToChars(password, secureString); secureString.close(); diff --git a/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java b/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java index 5deb774c2dfe5..f747a20e46871 100644 --- a/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java +++ b/core/src/test/java/org/elasticsearch/common/settings/SettingsTests.java @@ -69,7 +69,7 @@ public void testReplacePropertiesPlaceholderSystemVariablesHaveNoEffect() { } public void testReplacePropertiesPlaceholderByEnvironmentVariables() { - final String hostname = randomAsciiOfLength(16); + final String hostname = randomAlphaOfLength(16); final Settings implicitEnvSettings = Settings.builder() .put("setting1", "${HOSTNAME}") .replacePropertyPlaceholders(name -> "HOSTNAME".equals(name) ? hostname : null) diff --git a/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java index cbfd98aa3b74a..02394df3867e8 100644 --- a/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java +++ b/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java @@ -138,7 +138,7 @@ public void testRoundTrip() { private static final String FRACTIONAL_TIME_VALUES_ARE_NOT_SUPPORTED = "fractional time values are not supported"; public void testNonFractionalTimeValues() { - final String s = randomAsciiOfLength(10) + randomTimeUnit(); + final String s = randomAlphaOfLength(10) + randomTimeUnit(); final ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> TimeValue.parseTimeValue(s, null, "test")); assertThat(e, hasToString(containsString("failed to parse [" + s + "]"))); diff --git a/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java b/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java index 9f90fcf151d84..78abed0b32050 100644 --- a/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/BytesRefHashTests.java @@ -63,7 +63,7 @@ public void testDuell() { final int len = randomIntBetween(1, 100000); final BytesRef[] values = new BytesRef[len]; for (int i = 0; i < values.length; ++i) { - values[i] = new BytesRef(randomAsciiOfLength(5)); + values[i] = new BytesRef(randomAlphaOfLength(5)); } final ObjectLongMap valueToId = new ObjectLongHashMap<>(); final BytesRef[] idToValue = new BytesRef[values.length]; diff --git a/core/src/test/java/org/elasticsearch/common/util/IndexFolderUpgraderTests.java b/core/src/test/java/org/elasticsearch/common/util/IndexFolderUpgraderTests.java index 581d58d896dc1..bf10c117b1336 100644 --- a/core/src/test/java/org/elasticsearch/common/util/IndexFolderUpgraderTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/IndexFolderUpgraderTests.java @@ -71,7 +71,7 @@ public void testUpgradeCustomDataPath() throws IOException { .put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()) .put(Environment.PATH_SHARED_DATA_SETTING.getKey(), customPath.toAbsolutePath().toString()).build(); try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) { - final Index index = new Index(randomAsciiOfLength(10), UUIDs.randomBase64UUID()); + final Index index = new Index(randomAlphaOfLength(10), UUIDs.randomBase64UUID()); Settings settings = Settings.builder() .put(nodeSettings) .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()) @@ -100,7 +100,7 @@ public void testPartialUpgradeCustomDataPath() throws IOException { .put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()) .put(Environment.PATH_SHARED_DATA_SETTING.getKey(), customPath.toAbsolutePath().toString()).build(); try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) { - final Index index = new Index(randomAsciiOfLength(10), UUIDs.randomBase64UUID()); + final Index index = new Index(randomAlphaOfLength(10), UUIDs.randomBase64UUID()); Settings settings = Settings.builder() .put(nodeSettings) .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()) @@ -139,7 +139,7 @@ public void testUpgrade() throws IOException { final Settings nodeSettings = Settings.builder() .put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()).build(); try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) { - final Index index = new Index(randomAsciiOfLength(10), UUIDs.randomBase64UUID()); + final Index index = new Index(randomAlphaOfLength(10), UUIDs.randomBase64UUID()); Settings settings = Settings.builder() .put(nodeSettings) .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()) @@ -164,7 +164,7 @@ public void testUpgradeIndices() throws IOException { try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) { Map> indexSettingsMap = new HashMap<>(); for (int i = 0; i < randomIntBetween(2, 5); i++) { - final Index index = new Index(randomAsciiOfLength(10), UUIDs.randomBase64UUID()); + final Index index = new Index(randomAlphaOfLength(10), UUIDs.randomBase64UUID()); Settings settings = Settings.builder() .put(nodeSettings) .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()) diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java index 0e11e630ea9ba..32ffb33b694cf 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java @@ -66,12 +66,12 @@ public void testNullDeclares() { * Builds the object in random order and parses it. */ public void testRandomOrder() throws Exception { - HasCtorArguments expected = new HasCtorArguments(randomAsciiOfLength(5), randomInt()); + HasCtorArguments expected = new HasCtorArguments(randomAlphaOfLength(5), randomInt()); expected.setMineral(randomInt()); expected.setFruit(randomInt()); - expected.setA(randomBoolean() ? null : randomAsciiOfLength(5)); - expected.setB(randomBoolean() ? null : randomAsciiOfLength(5)); - expected.setC(randomBoolean() ? null : randomAsciiOfLength(5)); + expected.setA(randomBoolean() ? null : randomAlphaOfLength(5)); + expected.setB(randomBoolean() ? null : randomAlphaOfLength(5)); + expected.setC(randomBoolean() ? null : randomAlphaOfLength(5)); expected.setD(randomBoolean()); XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint(); expected.toXContent(builder, ToXContent.EMPTY_PARAMS); diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/UnknownNamedObjectExceptionTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/UnknownNamedObjectExceptionTests.java index 5ed3b0cf8c2a9..4fcc16416b56f 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/UnknownNamedObjectExceptionTests.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/UnknownNamedObjectExceptionTests.java @@ -31,7 +31,7 @@ public class UnknownNamedObjectExceptionTests extends ESTestCase { public void testRoundTrip() throws IOException { XContentLocation location = new XContentLocation(between(1, 1000), between(1, 1000)); UnknownNamedObjectException created = new UnknownNamedObjectException(location, UnknownNamedObjectExceptionTests.class, - randomAsciiOfLength(5)); + randomAlphaOfLength(5)); UnknownNamedObjectException roundTripped; try (BytesStreamOutput out = new BytesStreamOutput()) { @@ -50,7 +50,7 @@ public void testRoundTrip() throws IOException { public void testStatusCode() { XContentLocation location = new XContentLocation(between(1, 1000), between(1, 1000)); UnknownNamedObjectException e = new UnknownNamedObjectException(location, UnknownNamedObjectExceptionTests.class, - randomAsciiOfLength(5)); + randomAlphaOfLength(5)); assertEquals(RestStatus.BAD_REQUEST, e.status()); } } diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/FilterPathTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/FilterPathTests.java index 4eec46d9b274e..e151ac67a332f 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/FilterPathTests.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/support/filtering/FilterPathTests.java @@ -202,7 +202,7 @@ public void testSimpleWildcardFilterPath() { assertThat(filterPath.isSimpleWildcard(), is(true)); assertThat(filterPath.getSegment(), equalTo("*")); - FilterPath next = filterPath.matchProperty(randomAsciiOfLength(2)); + FilterPath next = filterPath.matchProperty(randomAlphaOfLength(2)); assertNotNull(next); assertSame(next, FilterPath.EMPTY); } @@ -246,7 +246,7 @@ public void testDoubleWildcardFilterPath() { assertThat(filterPath.isDoubleWildcard(), is(true)); assertThat(filterPath.getSegment(), equalTo("**")); - FilterPath next = filterPath.matchProperty(randomAsciiOfLength(2)); + FilterPath next = filterPath.matchProperty(randomAlphaOfLength(2)); assertNotNull(next); assertSame(next, FilterPath.EMPTY); } @@ -263,7 +263,7 @@ public void testStartsWithDoubleWildcardFilterPath() { assertThat(filterPath.matches(), is(false)); assertThat(filterPath.getSegment(), equalTo("**")); - FilterPath next = filterPath.matchProperty(randomAsciiOfLength(2)); + FilterPath next = filterPath.matchProperty(randomAlphaOfLength(2)); assertNotNull(next); assertThat(next.matches(), is(false)); assertThat(next.getSegment(), equalTo("bar")); diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java index 837c74a3c61b5..59fe5872911e1 100644 --- a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java @@ -234,7 +234,7 @@ public void onNodeFailure(DiscoveryNode node, String reason) { public void testMasterFaultDetectionConnectOnDisconnect() throws InterruptedException { Settings.Builder settings = Settings.builder(); boolean shouldRetry = randomBoolean(); - ClusterName clusterName = new ClusterName(randomAsciiOfLengthBetween(3, 20)); + ClusterName clusterName = new ClusterName(randomAlphaOfLengthBetween(3, 20)); // make sure we don't ping settings.put(FaultDetection.CONNECT_ON_NETWORK_DISCONNECT_SETTING.getKey(), shouldRetry) @@ -272,7 +272,7 @@ public void testMasterFaultDetectionConnectOnDisconnect() throws InterruptedExce public void testMasterFaultDetectionNotSizeLimited() throws InterruptedException { boolean shouldRetry = randomBoolean(); - ClusterName clusterName = new ClusterName(randomAsciiOfLengthBetween(3, 20)); + ClusterName clusterName = new ClusterName(randomAlphaOfLengthBetween(3, 20)); final Settings settings = Settings.builder() .put(FaultDetection.CONNECT_ON_NETWORK_DISCONNECT_SETTING.getKey(), shouldRetry) .put(FaultDetection.PING_INTERVAL_SETTING.getKey(), "1s") diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java index 2cf623b702ac9..3e90f414760dd 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java @@ -613,7 +613,7 @@ public void testIncomingClusterStateValidation() throws Exception { logger.info("--> testing acceptances of any master when having no master"); ClusterState state = ClusterState.builder(node.clusterState) - .nodes(DiscoveryNodes.builder(node.nodes()).masterNodeId(randomAsciiOfLength(10))).incrementVersion().build(); + .nodes(DiscoveryNodes.builder(node.nodes()).masterNodeId(randomAlphaOfLength(10))).incrementVersion().build(); node.action.validateIncomingState(state, null); // now set a master node @@ -634,7 +634,7 @@ public void testIncomingClusterStateValidation() throws Exception { logger.info("--> testing rejection of another cluster name"); try { - node.action.validateIncomingState(ClusterState.builder(new ClusterName(randomAsciiOfLength(10))) + node.action.validateIncomingState(ClusterState.builder(new ClusterName(randomAlphaOfLength(10))) .nodes(node.nodes()).build(), node.clusterState); fail("node accepted state with another cluster name"); } catch (IllegalStateException OK) { diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java index 2beac7eef2ff6..5df6bd214f318 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java @@ -504,7 +504,7 @@ public BoundTransportAddress boundAddress() { public void testUnknownHost() throws InterruptedException { final Logger logger = mock(Logger.class); final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList()); - final String hostname = randomAsciiOfLength(8); + final String hostname = randomAlphaOfLength(8); final UnknownHostException unknownHostException = new UnknownHostException(hostname); final Transport transport = new MockTcpTransport( Settings.EMPTY, diff --git a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java index d514cce222347..a396f4bfa6b8f 100644 --- a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java +++ b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java @@ -649,7 +649,7 @@ public static FieldStats randomFieldStats(boolean withNullMinMax) throws Unknown } else { return new FieldStats.Text(randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), randomBoolean(), randomBoolean(), - new BytesRef(randomAsciiOfLength(10)), new BytesRef(randomAsciiOfLength(20))); + new BytesRef(randomAlphaOfLength(10)), new BytesRef(randomAlphaOfLength(20))); } case 4: if (withNullMinMax && randomBoolean()) { diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java b/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java index bbf9579533794..7b5530bba1061 100644 --- a/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/GatewayMetaStateTests.java @@ -35,7 +35,6 @@ import org.elasticsearch.plugins.MetaDataUpgrader; import org.elasticsearch.cluster.ESAllocationTestCase; import org.elasticsearch.test.TestCustomMetaData; -import org.junit.Before; import java.util.Arrays; import java.util.Collections; @@ -438,7 +437,7 @@ private static MetaData randomMetaData(TestCustomMetaData... customMetaDatas) { } for (int i = 0; i < randomIntBetween(1, 5); i++) { builder.put( - IndexMetaData.builder(randomAsciiOfLength(10)) + IndexMetaData.builder(randomAlphaOfLength(10)) .settings(settings(Version.CURRENT)) .numberOfReplicas(randomIntBetween(0, 3)) .numberOfShards(randomIntBetween(1, 5)) diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java index 5cb6b2d9f986a..1b443a33da589 100644 --- a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java @@ -327,12 +327,12 @@ private MetaData randomMeta() throws IOException { MetaData.Builder mdBuilder = MetaData.builder(); mdBuilder.generateClusterUuidIfNeeded(); for (int i = 0; i < numIndices; i++) { - mdBuilder.put(indexBuilder(randomAsciiOfLength(10) + "idx-"+i)); + mdBuilder.put(indexBuilder(randomAlphaOfLength(10) + "idx-"+i)); } int numDelIndices = randomIntBetween(0, 5); final IndexGraveyard.Builder graveyard = IndexGraveyard.builder(); for (int i = 0; i < numDelIndices; i++) { - graveyard.addTombstone(new Index(randomAsciiOfLength(10) + "del-idx-" + i, UUIDs.randomBase64UUID())); + graveyard.addTombstone(new Index(randomAlphaOfLength(10) + "del-idx-" + i, UUIDs.randomBase64UUID())); } mdBuilder.indexGraveyard(graveyard.build()); return mdBuilder.build(); diff --git a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java index e618d44db5cb4..ca330d9d9df13 100644 --- a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java @@ -176,8 +176,8 @@ public void testShardLockObtainFailedException() { * select the second node as target */ public void testShardLockObtainFailedExceptionPreferOtherValidCopies() { - String allocId1 = randomAsciiOfLength(10); - String allocId2 = randomAsciiOfLength(10); + String allocId1 = randomAlphaOfLength(10); + String allocId2 = randomAlphaOfLength(10); final RoutingAllocation allocation = routingAllocationWithOnePrimaryNoReplicas(yesAllocationDeciders(), CLUSTER_RECOVERED, allocId1, allocId2);; testAllocator.addData(node1, allocId1, randomBoolean(), diff --git a/core/src/test/java/org/elasticsearch/index/IndexTests.java b/core/src/test/java/org/elasticsearch/index/IndexTests.java index d55630b1357bf..c39a43e849060 100644 --- a/core/src/test/java/org/elasticsearch/index/IndexTests.java +++ b/core/src/test/java/org/elasticsearch/index/IndexTests.java @@ -50,7 +50,7 @@ public void testToString() { } public void testXContent() throws IOException { - final String name = randomAsciiOfLengthBetween(4, 15); + final String name = randomAlphaOfLengthBetween(4, 15); final String uuid = UUIDs.randomBase64UUID(); final Index original = new Index(name, uuid); final XContentBuilder builder = JsonXContent.contentBuilder(); diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 6c7d2dd810fe9..65bebc40933b1 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -3248,7 +3248,7 @@ public long generateSeqNo() { }; noOpEngine = createEngine(defaultSettings, store, primaryTranslogDir, newMergePolicy(), null, () -> seqNoService); final long primaryTerm = randomNonNegativeLong(); - final String reason = randomAsciiOfLength(16); + final String reason = randomAlphaOfLength(16); noOpEngine.noOp( new Engine.NoOp( null, diff --git a/core/src/test/java/org/elasticsearch/index/get/GetFieldTests.java b/core/src/test/java/org/elasticsearch/index/get/GetFieldTests.java index 3fd6ca87e9bf3..d2968b6d8aea3 100644 --- a/core/src/test/java/org/elasticsearch/index/get/GetFieldTests.java +++ b/core/src/test/java/org/elasticsearch/index/get/GetFieldTests.java @@ -89,10 +89,10 @@ private static GetField mutateGetField(GetField getField) { public static Tuple randomGetField(XContentType xContentType) { if (randomBoolean()) { String fieldName = randomFrom(ParentFieldMapper.NAME, RoutingFieldMapper.NAME, UidFieldMapper.NAME); - GetField getField = new GetField(fieldName, Collections.singletonList(randomAsciiOfLengthBetween(3, 10))); + GetField getField = new GetField(fieldName, Collections.singletonList(randomAlphaOfLengthBetween(3, 10))); return Tuple.tuple(getField, getField); } - String fieldName = randomAsciiOfLengthBetween(3, 10); + String fieldName = randomAlphaOfLengthBetween(3, 10); Tuple, List> tuple = RandomObjects.randomStoredFieldValues(random(), xContentType); GetField input = new GetField(fieldName, tuple.v1()); GetField expected = new GetField(fieldName, tuple.v2()); diff --git a/core/src/test/java/org/elasticsearch/index/get/GetResultTests.java b/core/src/test/java/org/elasticsearch/index/get/GetResultTests.java index 4e5b94d9c9877..93ba260ee4daa 100644 --- a/core/src/test/java/org/elasticsearch/index/get/GetResultTests.java +++ b/core/src/test/java/org/elasticsearch/index/get/GetResultTests.java @@ -173,9 +173,9 @@ public static GetResult mutateGetResult(GetResult getResult) { } public static Tuple randomGetResult(XContentType xContentType) { - final String index = randomAsciiOfLengthBetween(3, 10); - final String type = randomAsciiOfLengthBetween(3, 10); - final String id = randomAsciiOfLengthBetween(3, 10); + final String index = randomAlphaOfLengthBetween(3, 10); + final String type = randomAlphaOfLengthBetween(3, 10); + final String id = randomAlphaOfLengthBetween(3, 10); final long version; final boolean exists; BytesReference source = null; diff --git a/core/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java b/core/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java index e66e0532737c4..f1a2e97f0bf7d 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/MultiFieldTests.java @@ -30,15 +30,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.mapper.DateFieldMapper; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.DocumentMapperParser; -import org.elasticsearch.index.mapper.KeywordFieldMapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.RootObjectMapper; -import org.elasticsearch.index.mapper.TextFieldMapper; -import org.elasticsearch.index.mapper.TokenCountFieldMapper; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -174,7 +165,7 @@ public void testBuildThenParse() throws Exception { public void testMultiFieldsInConsistentOrder() throws Exception { String[] multiFieldNames = new String[randomIntBetween(2, 10)]; for (int i = 0; i < multiFieldNames.length; i++) { - multiFieldNames[i] = randomAsciiOfLength(4); + multiFieldNames[i] = randomAlphaOfLength(4); } XContentBuilder builder = jsonBuilder().startObject().startObject("type").startObject("properties") diff --git a/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java index ce6f7246ff527..b3d7db23c3826 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java @@ -73,7 +73,7 @@ protected RangeFieldMapper.RangeFieldType createDefaultFieldType() { public void testRangeQuery() throws Exception { Settings indexSettings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAsciiOfLengthBetween(1, 10), indexSettings); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); QueryShardContext context = new QueryShardContext(0, idxSettings, null, null, null, null, null, xContentRegistry(), null, null, () -> nowInMillis); RangeFieldMapper.RangeFieldType ft = new RangeFieldMapper.RangeFieldType(type); diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java index 60ba7aa3f7bf5..1f58e7852192b 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractTermQueryTestCase.java @@ -30,7 +30,7 @@ public abstract class AbstractTermQueryTestCase createQueryBuilder(null, term)); assertEquals("field name is null or empty", e.getMessage()); e = expectThrows(IllegalArgumentException.class, () -> createQueryBuilder("", term)); diff --git a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java index a7245826a2d30..66c36e0418ada 100644 --- a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryBuilderTests.java @@ -44,13 +44,13 @@ protected CommonTermsQueryBuilder doCreateTestQueryBuilder() { int numberOfTerms = randomIntBetween(0, 10); StringBuilder text = new StringBuilder(""); for (int i = 0; i < numberOfTerms; i++) { - text.append(randomAsciiOfLengthBetween(1, 10)).append(" "); + text.append(randomAlphaOfLengthBetween(1, 10)).append(" "); } // mapped or unmapped field if (randomBoolean()) { query = new CommonTermsQueryBuilder(STRING_FIELD_NAME, text.toString()); } else { - query = new CommonTermsQueryBuilder(randomAsciiOfLengthBetween(1, 10), text.toString()); + query = new CommonTermsQueryBuilder(randomAlphaOfLengthBetween(1, 10), text.toString()); } if (randomBoolean()) { @@ -88,8 +88,8 @@ protected CommonTermsQueryBuilder doCreateTestQueryBuilder() { @Override protected Map getAlternateVersions() { Map alternateVersions = new HashMap<>(); - CommonTermsQueryBuilder commonTermsQuery = new CommonTermsQueryBuilder(randomAsciiOfLengthBetween(1, 10), - randomAsciiOfLengthBetween(1, 10)); + CommonTermsQueryBuilder commonTermsQuery = new CommonTermsQueryBuilder(randomAlphaOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10)); String contentString = "{\n" + " \"common\" : {\n" + " \"" + commonTermsQuery.fieldName() + "\" : \"" + commonTermsQuery.value() + "\"\n" + diff --git a/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java index 95720e5e32521..cfc2d78942050 100644 --- a/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/ExistsQueryBuilderTests.java @@ -43,7 +43,7 @@ protected ExistsQueryBuilder doCreateTestQueryBuilder() { if (randomBoolean()) { fieldPattern = randomFrom(MAPPED_FIELD_NAMES); } else { - fieldPattern = randomAsciiOfLengthBetween(1, 10); + fieldPattern = randomAlphaOfLengthBetween(1, 10); } // also sometimes test wildcard patterns if (randomBoolean()) { diff --git a/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java index 924e6724062a6..d7fe00e730c91 100644 --- a/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java @@ -37,7 +37,7 @@ protected FieldMaskingSpanQueryBuilder doCreateTestQueryBuilder() { if (randomBoolean()) { fieldName = randomFrom(MAPPED_FIELD_NAMES); } else { - fieldName = randomAsciiOfLengthBetween(1, 10); + fieldName = randomAlphaOfLengthBetween(1, 10); } SpanTermQueryBuilder innerQuery = new SpanTermQueryBuilderTests().createTestQueryBuilder(); return new FieldMaskingSpanQueryBuilder(innerQuery, fieldName); diff --git a/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java index 39612c6d37c6b..58c70fcfcb39b 100644 --- a/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java @@ -62,7 +62,7 @@ protected FuzzyQueryBuilder doCreateTestQueryBuilder() { @Override protected Map getAlternateVersions() { Map alternateVersions = new HashMap<>(); - FuzzyQueryBuilder fuzzyQuery = new FuzzyQueryBuilder(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10)); + FuzzyQueryBuilder fuzzyQuery = new FuzzyQueryBuilder(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10)); String contentString = "{\n" + " \"fuzzy\" : {\n" + " \"" + fuzzyQuery.fieldName() + "\" : \"" + fuzzyQuery.value() + "\"\n" + diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java index 6ce958927695f..ddc4810b871a7 100644 --- a/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java @@ -70,15 +70,15 @@ protected GeoShapeQueryBuilder doCreateTestQueryBuilder() { builder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, shape); } else { indexedShapeToReturn = shape; - indexedShapeId = randomAsciiOfLengthBetween(3, 20); - indexedShapeType = randomAsciiOfLengthBetween(3, 20); + indexedShapeId = randomAlphaOfLengthBetween(3, 20); + indexedShapeType = randomAlphaOfLengthBetween(3, 20); builder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, indexedShapeId, indexedShapeType); if (randomBoolean()) { - indexedShapeIndex = randomAsciiOfLengthBetween(3, 20); + indexedShapeIndex = randomAlphaOfLengthBetween(3, 20); builder.indexedShapeIndex(indexedShapeIndex); } if (randomBoolean()) { - indexedShapePath = randomAsciiOfLengthBetween(3, 20); + indexedShapePath = randomAlphaOfLengthBetween(3, 20); builder.indexedShapePath(indexedShapePath); } } diff --git a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java index e21e157bcf77b..49523fe923d7b 100644 --- a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java @@ -109,7 +109,7 @@ protected HasChildQueryBuilder doCreateTestQueryBuilder() { hqb.ignoreUnmapped(randomBoolean()); if (randomBoolean()) { hqb.innerHit(new InnerHitBuilder() - .setName(randomAsciiOfLengthBetween(1, 10)) + .setName(randomAlphaOfLengthBetween(1, 10)) .setSize(randomIntBetween(0, 100)) .addSort(new FieldSortBuilder(STRING_FIELD_NAME_2).order(SortOrder.ASC)), hqb.ignoreUnmapped()); } diff --git a/core/src/test/java/org/elasticsearch/index/query/HasParentQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/HasParentQueryBuilderTests.java index 7e0fc30aa753b..22ea2cc9c4442 100644 --- a/core/src/test/java/org/elasticsearch/index/query/HasParentQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/HasParentQueryBuilderTests.java @@ -88,7 +88,7 @@ protected HasParentQueryBuilder doCreateTestQueryBuilder() { hqb.ignoreUnmapped(randomBoolean()); if (randomBoolean()) { hqb.innerHit(new InnerHitBuilder() - .setName(randomAsciiOfLengthBetween(1, 10)) + .setName(randomAlphaOfLengthBetween(1, 10)) .setSize(randomIntBetween(0, 100)) .addSort(new FieldSortBuilder(STRING_FIELD_NAME_2).order(SortOrder.ASC)), hqb.ignoreUnmapped()); } diff --git a/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java index 429f43aaee573..9c4758b52bfe5 100644 --- a/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/IdsQueryBuilderTests.java @@ -45,7 +45,7 @@ protected IdsQueryBuilder doCreateTestQueryBuilder() { if (frequently()) { types[i] = randomFrom(getCurrentTypes()); } else { - types[i] = randomAsciiOfLengthBetween(1, 10); + types[i] = randomAlphaOfLengthBetween(1, 10); } } } else { @@ -58,7 +58,7 @@ protected IdsQueryBuilder doCreateTestQueryBuilder() { int numberOfIds = randomIntBetween(0, 10); String[] ids = new String[numberOfIds]; for (int i = 0; i < numberOfIds; i++) { - ids[i] = randomAsciiOfLengthBetween(1, 10); + ids[i] = randomAlphaOfLengthBetween(1, 10); } IdsQueryBuilder query; if (types.length > 0 || randomBoolean()) { diff --git a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java index b46f3f3aa1916..99deef9cde721 100644 --- a/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/InnerHitBuilderTests.java @@ -297,16 +297,16 @@ public static InnerHitBuilder randomInnerHits() { public static InnerHitBuilder randomInnerHits(boolean recursive, boolean includeQueryTypeOrPath) { InnerHitBuilder innerHits = new InnerHitBuilder(); - innerHits.setName(randomAsciiOfLengthBetween(1, 16)); + innerHits.setName(randomAlphaOfLengthBetween(1, 16)); innerHits.setFrom(randomIntBetween(0, 128)); innerHits.setSize(randomIntBetween(0, 128)); innerHits.setExplain(randomBoolean()); innerHits.setVersion(randomBoolean()); innerHits.setTrackScores(randomBoolean()); if (randomBoolean()) { - innerHits.setStoredFieldNames(randomListStuff(16, () -> randomAsciiOfLengthBetween(1, 16))); + innerHits.setStoredFieldNames(randomListStuff(16, () -> randomAlphaOfLengthBetween(1, 16))); } - innerHits.setDocValueFields(randomListStuff(16, () -> randomAsciiOfLengthBetween(1, 16))); + innerHits.setDocValueFields(randomListStuff(16, () -> randomAlphaOfLengthBetween(1, 16))); // Random script fields deduped on their field name. Map scriptFields = new HashMap<>(); for (SearchSourceBuilder.ScriptField field: randomListStuff(16, InnerHitBuilderTests::randomScript)) { @@ -325,7 +325,7 @@ public static InnerHitBuilder randomInnerHits(boolean recursive, boolean include innerHits.setFetchSourceContext(randomFetchSourceContext); if (randomBoolean()) { innerHits.setSorts(randomListStuff(16, - () -> SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))) + () -> SortBuilders.fieldSort(randomAlphaOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))) ); } innerHits.setHighlightBuilder(HighlightBuilderTests.randomHighlighterBuilder()); @@ -337,11 +337,11 @@ public static InnerHitBuilder randomInnerHits(boolean recursive, boolean include } if (includeQueryTypeOrPath) { - QueryBuilder query = new MatchQueryBuilder(randomAsciiOfLengthBetween(1, 16), randomAsciiOfLengthBetween(1, 16)); + QueryBuilder query = new MatchQueryBuilder(randomAlphaOfLengthBetween(1, 16), randomAlphaOfLengthBetween(1, 16)); if (randomBoolean()) { - return new InnerHitBuilder(innerHits, randomAsciiOfLength(8), query, randomBoolean()); + return new InnerHitBuilder(innerHits, randomAlphaOfLength(8), query, randomBoolean()); } else { - return new InnerHitBuilder(innerHits, query, randomAsciiOfLength(8), randomBoolean()); + return new InnerHitBuilder(innerHits, query, randomAlphaOfLength(8), randomBoolean()); } } else { return innerHits; @@ -366,14 +366,14 @@ static InnerHitBuilder mutate(InnerHitBuilder original) throws IOException { modifiers.add(() -> copy.setExplain(!copy.isExplain())); modifiers.add(() -> copy.setVersion(!copy.isVersion())); modifiers.add(() -> copy.setTrackScores(!copy.isTrackScores())); - modifiers.add(() -> copy.setName(randomValueOtherThan(copy.getName(), () -> randomAsciiOfLengthBetween(1, 16)))); + modifiers.add(() -> copy.setName(randomValueOtherThan(copy.getName(), () -> randomAlphaOfLengthBetween(1, 16)))); modifiers.add(() -> { if (randomBoolean()) { copy.setDocValueFields(randomValueOtherThan(copy.getDocValueFields(), () -> { - return randomListStuff(16, () -> randomAsciiOfLengthBetween(1, 16)); + return randomListStuff(16, () -> randomAlphaOfLengthBetween(1, 16)); })); } else { - copy.addDocValueField(randomAsciiOfLengthBetween(1, 16)); + copy.addDocValueField(randomAlphaOfLengthBetween(1, 16)); } }); modifiers.add(() -> { @@ -400,12 +400,12 @@ static InnerHitBuilder mutate(InnerHitBuilder original) throws IOException { if (randomBoolean()) { final List> sortBuilders = randomValueOtherThan(copy.getSorts(), () -> { List> builders = randomListStuff(16, - () -> SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); + () -> SortBuilders.fieldSort(randomAlphaOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); return builders; }); copy.setSorts(sortBuilders); } else { - copy.addSort(SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20))); + copy.addSort(SortBuilders.fieldSort(randomAlphaOfLengthBetween(5, 20))); } }); modifiers.add(() -> copy @@ -415,10 +415,10 @@ static InnerHitBuilder mutate(InnerHitBuilder original) throws IOException { List previous = copy.getStoredFieldsContext() == null ? Collections.emptyList() : copy.getStoredFieldsContext().fieldNames(); List newValues = randomValueOtherThan(previous, - () -> randomListStuff(1, 16, () -> randomAsciiOfLengthBetween(1, 16))); + () -> randomListStuff(1, 16, () -> randomAlphaOfLengthBetween(1, 16))); copy.setStoredFieldNames(newValues); } else { - copy.getStoredFieldsContext().addFieldName(randomAsciiOfLengthBetween(1, 16)); + copy.getStoredFieldsContext().addFieldName(randomAlphaOfLengthBetween(1, 16)); } }); randomFrom(modifiers).run(); @@ -431,12 +431,12 @@ static SearchSourceBuilder.ScriptField randomScript() { if (randomBoolean()) { int numEntries = randomIntBetween(0, 32); for (int i = 0; i < numEntries; i++) { - randomMap.put(String.valueOf(i), randomAsciiOfLength(16)); + randomMap.put(String.valueOf(i), randomAlphaOfLength(16)); } } - Script script = new Script(randomScriptType, randomScriptType == ScriptType.STORED ? null : randomAsciiOfLengthBetween(1, 4), - randomAsciiOfLength(128), randomMap); - return new SearchSourceBuilder.ScriptField(randomAsciiOfLengthBetween(1, 32), script, randomBoolean()); + Script script = new Script(randomScriptType, randomScriptType == ScriptType.STORED ? null : randomAlphaOfLengthBetween(1, 4), + randomAlphaOfLength(128), randomMap); + return new SearchSourceBuilder.ScriptField(randomAlphaOfLengthBetween(1, 32), script, randomBoolean()); } static List randomListStuff(int maxSize, Supplier valueSupplier) { diff --git a/core/src/test/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilderTests.java index 0d654940e0962..b4d5f98fe0b47 100644 --- a/core/src/test/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/MatchPhrasePrefixQueryBuilderTests.java @@ -52,7 +52,7 @@ protected MatchPhrasePrefixQueryBuilder doCreateTestQueryBuilder() { int terms = randomIntBetween(0, 3); StringBuilder builder = new StringBuilder(); for (int i = 0; i < terms; i++) { - builder.append(randomAsciiOfLengthBetween(1, 10)).append(" "); + builder.append(randomAlphaOfLengthBetween(1, 10)).append(" "); } value = builder.toString().trim(); } else { @@ -78,8 +78,8 @@ protected MatchPhrasePrefixQueryBuilder doCreateTestQueryBuilder() { @Override protected Map getAlternateVersions() { Map alternateVersions = new HashMap<>(); - MatchPhrasePrefixQueryBuilder matchPhrasePrefixQuery = new MatchPhrasePrefixQueryBuilder(randomAsciiOfLengthBetween(1, 10), - randomAsciiOfLengthBetween(1, 10)); + MatchPhrasePrefixQueryBuilder matchPhrasePrefixQuery = new MatchPhrasePrefixQueryBuilder(randomAlphaOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10)); String contentString = "{\n" + " \"match_phrase_prefix\" : {\n" + " \"" + matchPhrasePrefixQuery.fieldName() + "\" : \"" + matchPhrasePrefixQuery.value() + "\"\n" + diff --git a/core/src/test/java/org/elasticsearch/index/query/MatchPhraseQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MatchPhraseQueryBuilderTests.java index 2b295dd11413b..d37d6eeb88fdf 100644 --- a/core/src/test/java/org/elasticsearch/index/query/MatchPhraseQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/MatchPhraseQueryBuilderTests.java @@ -52,7 +52,7 @@ protected MatchPhraseQueryBuilder doCreateTestQueryBuilder() { int terms = randomIntBetween(0, 3); StringBuilder builder = new StringBuilder(); for (int i = 0; i < terms; i++) { - builder.append(randomAsciiOfLengthBetween(1, 10)).append(" "); + builder.append(randomAlphaOfLengthBetween(1, 10)).append(" "); } value = builder.toString().trim(); } else { @@ -74,8 +74,8 @@ protected MatchPhraseQueryBuilder doCreateTestQueryBuilder() { @Override protected Map getAlternateVersions() { Map alternateVersions = new HashMap<>(); - MatchPhraseQueryBuilder matchPhraseQuery = new MatchPhraseQueryBuilder(randomAsciiOfLengthBetween(1, 10), - randomAsciiOfLengthBetween(1, 10)); + MatchPhraseQueryBuilder matchPhraseQuery = new MatchPhraseQueryBuilder(randomAlphaOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10)); String contentString = "{\n" + " \"match_phrase\" : {\n" + " \"" + matchPhraseQuery.fieldName() + "\" : \"" + matchPhraseQuery.value() + "\"\n" + diff --git a/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java index 08c0f47feb1b5..40ebb0e4a15a6 100644 --- a/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java @@ -70,7 +70,7 @@ protected MatchQueryBuilder doCreateTestQueryBuilder() { int terms = randomIntBetween(0, 3); StringBuilder builder = new StringBuilder(); for (int i = 0; i < terms; i++) { - builder.append(randomAsciiOfLengthBetween(1, 10)).append(" "); + builder.append(randomAlphaOfLengthBetween(1, 10)).append(" "); } value = builder.toString().trim(); } else { @@ -130,7 +130,7 @@ protected MatchQueryBuilder doCreateTestQueryBuilder() { @Override protected Map getAlternateVersions() { Map alternateVersions = new HashMap<>(); - MatchQueryBuilder matchQuery = new MatchQueryBuilder(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10)); + MatchQueryBuilder matchQuery = new MatchQueryBuilder(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10)); String contentString = "{\n" + " \"match\" : {\n" + " \"" + matchQuery.fieldName() + "\" : \"" + matchQuery.value() + "\"\n" + diff --git a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java index ee1265eca656f..f2d66409e9e42 100644 --- a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java @@ -96,7 +96,7 @@ private Item generateRandomItem() { // indexed item or artificial document Item item; if (randomBoolean()) { - item = new Item(index, type, randomAsciiOfLength(10)); + item = new Item(index, type, randomAlphaOfLength(10)); } else { item = new Item(index, type, randomArtificialDoc()); } @@ -109,7 +109,7 @@ private Item generateRandomItem() { item.perFieldAnalyzer(randomPerFieldAnalyzer()); } if (randomBoolean()) { - item.routing(randomAsciiOfLength(10)); + item.routing(randomAlphaOfLength(10)); } if (randomBoolean()) { item.version(randomInt(5)); @@ -125,7 +125,7 @@ private XContentBuilder randomArtificialDoc() { try { doc = XContentFactory.jsonBuilder().startObject(); for (String field : randomFields) { - doc.field(field, randomAsciiOfLength(10)); + doc.field(field, randomAlphaOfLength(10)); } doc.endObject(); } catch (IOException e) { diff --git a/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java index f6f8fde7a49ce..d8cdf221ca14f 100644 --- a/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/NestedQueryBuilderTests.java @@ -23,7 +23,6 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.join.ScoreMode; -import org.apache.lucene.search.join.ToParentBlockJoinQuery; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.index.mapper.MapperService; @@ -76,7 +75,7 @@ protected NestedQueryBuilder doCreateTestQueryBuilder() { nqb.ignoreUnmapped(randomBoolean()); if (randomBoolean()) { nqb.innerHit(new InnerHitBuilder() - .setName(randomAsciiOfLengthBetween(1, 10)) + .setName(randomAlphaOfLengthBetween(1, 10)) .setSize(randomIntBetween(0, 100)) .addSort(new FieldSortBuilder(INT_FIELD_NAME).order(SortOrder.ASC)), nqb.ignoreUnmapped()); } diff --git a/core/src/test/java/org/elasticsearch/index/query/ParentIdQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ParentIdQueryBuilderTests.java index 893222243b68f..dc220df2d0329 100644 --- a/core/src/test/java/org/elasticsearch/index/query/ParentIdQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/ParentIdQueryBuilderTests.java @@ -66,7 +66,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws @Override protected ParentIdQueryBuilder doCreateTestQueryBuilder() { - return new ParentIdQueryBuilder(CHILD_TYPE, randomAsciiOfLength(4)).ignoreUnmapped(randomBoolean()); + return new ParentIdQueryBuilder(CHILD_TYPE, randomAlphaOfLength(4)).ignoreUnmapped(randomBoolean()); } @Override diff --git a/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java index 42e2dc7d8d8dc..11cf639974557 100644 --- a/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/PrefixQueryBuilderTests.java @@ -60,8 +60,8 @@ protected Map getAlternateVersions() { } private static PrefixQueryBuilder randomPrefixQuery() { - String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAsciiOfLengthBetween(1, 10); - String value = randomAsciiOfLengthBetween(1, 10); + String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10); + String value = randomAlphaOfLengthBetween(1, 10); return new PrefixQueryBuilder(fieldName, value); } diff --git a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java index 617e89531cc49..38e23bd5d502c 100644 --- a/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java @@ -79,17 +79,17 @@ protected QueryStringQueryBuilder doCreateTestQueryBuilder() { String query = ""; for (int i = 0; i < numTerms; i++) { //min length 4 makes sure that the text is not an operator (AND/OR) so toQuery won't break - query += (randomBoolean() ? STRING_FIELD_NAME + ":" : "") + randomAsciiOfLengthBetween(4, 10) + " "; + query += (randomBoolean() ? STRING_FIELD_NAME + ":" : "") + randomAlphaOfLengthBetween(4, 10) + " "; } QueryStringQueryBuilder queryStringQueryBuilder = new QueryStringQueryBuilder(query); if (randomBoolean()) { queryStringQueryBuilder.defaultField(randomBoolean() ? - STRING_FIELD_NAME : randomAsciiOfLengthBetween(1, 10)); + STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10)); } if (randomBoolean()) { int numFields = randomIntBetween(1, 5); for (int i = 0; i < numFields; i++) { - String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAsciiOfLengthBetween(1, 10); + String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10); if (randomBoolean()) { queryStringQueryBuilder.field(fieldName); } else { @@ -144,7 +144,7 @@ protected QueryStringQueryBuilder doCreateTestQueryBuilder() { queryStringQueryBuilder.rewrite(getRandomRewriteMethod()); } if (randomBoolean()) { - queryStringQueryBuilder.quoteFieldSuffix(randomAsciiOfLengthBetween(1, 3)); + queryStringQueryBuilder.quoteFieldSuffix(randomAlphaOfLengthBetween(1, 3)); } if (randomBoolean()) { queryStringQueryBuilder.tieBreaker(randomFloat()); diff --git a/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java index 52b84349c200e..1d3180ce49702 100644 --- a/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTests.java @@ -86,8 +86,8 @@ protected RangeQueryBuilder doCreateTestQueryBuilder() { case 2: default: query = new RangeQueryBuilder(STRING_FIELD_NAME); - query.from("a" + randomAsciiOfLengthBetween(1, 10)); - query.to("z" + randomAsciiOfLengthBetween(1, 10)); + query.from("a" + randomAlphaOfLengthBetween(1, 10)); + query.to("z" + randomAlphaOfLengthBetween(1, 10)); break; } query.includeLower(randomBoolean()).includeUpper(randomBoolean()); @@ -407,7 +407,7 @@ public void testNamedQueryParsing() throws IOException { } public void testRewriteDateToMatchAll() throws IOException { - String fieldName = randomAsciiOfLengthBetween(1, 20); + String fieldName = randomAlphaOfLengthBetween(1, 20); RangeQueryBuilder query = new RangeQueryBuilder(fieldName) { @Override protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException { @@ -428,7 +428,7 @@ protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteC } public void testRewriteDateToMatchAllWithTimezoneAndFormat() throws IOException { - String fieldName = randomAsciiOfLengthBetween(1, 20); + String fieldName = randomAlphaOfLengthBetween(1, 20); RangeQueryBuilder query = new RangeQueryBuilder(fieldName) { @Override protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException { @@ -453,7 +453,7 @@ protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteC } public void testRewriteDateToMatchNone() throws IOException { - String fieldName = randomAsciiOfLengthBetween(1, 20); + String fieldName = randomAlphaOfLengthBetween(1, 20); RangeQueryBuilder query = new RangeQueryBuilder(fieldName) { @Override protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException { @@ -470,7 +470,7 @@ protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteC } public void testRewriteDateToSame() throws IOException { - String fieldName = randomAsciiOfLengthBetween(1, 20); + String fieldName = randomAlphaOfLengthBetween(1, 20); RangeQueryBuilder query = new RangeQueryBuilder(fieldName) { @Override protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException { @@ -487,7 +487,7 @@ protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteC } public void testRewriteOpenBoundsToSame() throws IOException { - String fieldName = randomAsciiOfLengthBetween(1, 20); + String fieldName = randomAlphaOfLengthBetween(1, 20); RangeQueryBuilder query = new RangeQueryBuilder(fieldName) { @Override protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException { diff --git a/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java index b8363cfa06d00..efbb84c3239dd 100644 --- a/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java @@ -71,8 +71,8 @@ protected Map getAlternateVersions() { private static RegexpQueryBuilder randomRegexpQuery() { // mapped or unmapped fields - String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAsciiOfLengthBetween(1, 10); - String value = randomAsciiOfLengthBetween(1, 10); + String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10); + String value = randomAlphaOfLengthBetween(1, 10); return new RegexpQueryBuilder(fieldName, value); } diff --git a/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java index 417032493f694..5e221748e2bb7 100644 --- a/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/SimpleQueryStringBuilderTests.java @@ -56,7 +56,7 @@ public class SimpleQueryStringBuilderTests extends AbstractQueryTestCase fields = new HashMap<>(); for (int i = 0; i < fieldCount; i++) { if (randomBoolean()) { - fields.put(randomAsciiOfLengthBetween(1, 10), AbstractQueryBuilder.DEFAULT_BOOST); + fields.put(randomAlphaOfLengthBetween(1, 10), AbstractQueryBuilder.DEFAULT_BOOST); } else { - fields.put(randomBoolean() ? STRING_FIELD_NAME : randomAsciiOfLengthBetween(1, 10), 2.0f / randomIntBetween(1, 20)); + fields.put(randomBoolean() ? STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10), 2.0f / randomIntBetween(1, 20)); } } result.fields(fields); @@ -197,7 +197,7 @@ public void testFieldsCannotBeSetToNull() { } public void testDefaultFieldParsing() throws IOException { - String query = randomAsciiOfLengthBetween(1, 10).toLowerCase(Locale.ROOT); + String query = randomAlphaOfLengthBetween(1, 10).toLowerCase(Locale.ROOT); String contentString = "{\n" + " \"simple_query_string\" : {\n" + " \"query\" : \"" + query + "\"" + diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanTermQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanTermQueryBuilderTests.java index c3c81b7c25edc..7739620534da7 100644 --- a/core/src/test/java/org/elasticsearch/index/query/SpanTermQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/SpanTermQueryBuilderTests.java @@ -45,7 +45,7 @@ protected SpanTermQueryBuilder doCreateTestQueryBuilder() { fieldName = STRING_FIELD_NAME; } if (frequently()) { - value = randomAsciiOfLengthBetween(1, 10); + value = randomAlphaOfLengthBetween(1, 10); } else { // generate unicode string in 10% of cases JsonStringEncoder encoder = JsonStringEncoder.getInstance(); @@ -53,7 +53,7 @@ protected SpanTermQueryBuilder doCreateTestQueryBuilder() { } if (fieldName == null) { - fieldName = randomAsciiOfLengthBetween(1, 10); + fieldName = randomAlphaOfLengthBetween(1, 10); } return createQueryBuilder(fieldName, value); } @@ -92,7 +92,7 @@ public SpanTermQueryBuilder[] createSpanTermQueryBuilders(int amount) { spanTermQuery.boost(2.0f / randomIntBetween(1, 20)); } if (randomBoolean()) { - spanTermQuery.queryName(randomAsciiOfLengthBetween(1, 10)); + spanTermQuery.queryName(randomAlphaOfLengthBetween(1, 10)); } clauses[i] = spanTermQuery; } diff --git a/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java index 9038998087552..45cbd43864f90 100644 --- a/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java @@ -53,7 +53,7 @@ protected TermQueryBuilder doCreateTestQueryBuilder() { fieldName = STRING_FIELD_NAME; } if (frequently()) { - value = randomAsciiOfLengthBetween(1, 10); + value = randomAlphaOfLengthBetween(1, 10); } else { // generate unicode string in 10% of cases JsonStringEncoder encoder = JsonStringEncoder.getInstance(); @@ -77,7 +77,7 @@ protected TermQueryBuilder doCreateTestQueryBuilder() { } if (fieldName == null) { - fieldName = randomAsciiOfLengthBetween(1, 10); + fieldName = randomAlphaOfLengthBetween(1, 10); } return createQueryBuilder(fieldName, value); } diff --git a/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java index 442075de306bc..6f31c1eaf1ed1 100644 --- a/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java @@ -45,12 +45,10 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.function.Predicate; import java.util.stream.Collectors; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.either; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; public class TermsQueryBuilderTests extends AbstractQueryTestCase { @@ -68,7 +66,7 @@ public void randomTerms() { } } this.randomTerms = randomTerms; - termsPath = randomAsciiOfLength(10).replace('.', '_'); + termsPath = randomAlphaOfLength(10).replace('.', '_'); } @Override @@ -89,14 +87,14 @@ protected TermsQueryBuilder doCreateTestQueryBuilder() { query = new TermsQueryBuilder(fieldName, values); } else { // right now the mock service returns us a list of strings - query = new TermsQueryBuilder(randomBoolean() ? randomAsciiOfLengthBetween(1,10) : STRING_FIELD_NAME, randomTermsLookup()); + query = new TermsQueryBuilder(randomBoolean() ? randomAlphaOfLengthBetween(1,10) : STRING_FIELD_NAME, randomTermsLookup()); } return query; } private TermsLookup randomTermsLookup() { - return new TermsLookup(randomBoolean() ? randomAsciiOfLength(10) : null, randomAsciiOfLength(10), randomAsciiOfLength(10), - termsPath).routing(randomBoolean() ? randomAsciiOfLength(10) : null); + return new TermsLookup(randomBoolean() ? randomAlphaOfLength(10) : null, randomAlphaOfLength(10), randomAlphaOfLength(10), + termsPath).routing(randomBoolean() ? randomAlphaOfLength(10) : null); } @Override diff --git a/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java index e272accd5e6e7..05264cc8ebfb6 100644 --- a/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/WildcardQueryBuilderTests.java @@ -59,11 +59,11 @@ protected Map getAlternateVersions() { private static WildcardQueryBuilder randomWildcardQuery() { // mapped or unmapped field - String text = randomAsciiOfLengthBetween(1, 10); + String text = randomAlphaOfLengthBetween(1, 10); if (randomBoolean()) { return new WildcardQueryBuilder(STRING_FIELD_NAME, text); } else { - return new WildcardQueryBuilder(randomAsciiOfLengthBetween(1, 10), text); + return new WildcardQueryBuilder(randomAlphaOfLengthBetween(1, 10), text); } } diff --git a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java index 20f4475ec76da..702e8b6091797 100644 --- a/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java @@ -180,7 +180,7 @@ private static ScoreFunctionBuilder randomScoreFunction() { } else if (randomBoolean()) { randomScoreFunctionBuilder.seed(randomInt()); } else { - randomScoreFunctionBuilder.seed(randomAsciiOfLengthBetween(1, 10)); + randomScoreFunctionBuilder.seed(randomAlphaOfLengthBetween(1, 10)); } } functionBuilder = randomScoreFunctionBuilder; diff --git a/core/src/test/java/org/elasticsearch/index/seqno/GlobalCheckpointTests.java b/core/src/test/java/org/elasticsearch/index/seqno/GlobalCheckpointTests.java index 7d6dd25403b65..58f66dc62e773 100644 --- a/core/src/test/java/org/elasticsearch/index/seqno/GlobalCheckpointTests.java +++ b/core/src/test/java/org/elasticsearch/index/seqno/GlobalCheckpointTests.java @@ -115,7 +115,7 @@ public void testGlobalCheckpointUpdate() { allocations.keySet().forEach(aId -> tracker.updateLocalCheckpoint(aId, allocations.get(aId))); // now insert an unknown active/insync id , the checkpoint shouldn't change but a refresh should be requested. - final String extraId = "extra_" + randomAsciiOfLength(5); + final String extraId = "extra_" + randomAlphaOfLength(5); // first check that adding it without the master blessing doesn't change anything. tracker.updateLocalCheckpoint(extraId, maxLocalCheckpoint + 1 + randomInt(4)); diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java index 3313736ffcfe3..d203832fb15ec 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java @@ -213,7 +213,7 @@ public void testUpdatePriority() { public void testIndexDirIsDeletedWhenShardRemoved() throws Exception { Environment env = getInstanceFromNode(Environment.class); - Path idxPath = env.sharedDataFile().resolve(randomAsciiOfLength(10)); + Path idxPath = env.sharedDataFile().resolve(randomAlphaOfLength(10)); logger.info("--> idxPath: [{}]", idxPath); Settings idxSettings = Settings.builder() .put(IndexMetaData.SETTING_DATA_PATH, idxPath) @@ -246,10 +246,10 @@ public void testExpectedShardSizeIsPresent() throws InterruptedException { public void testIndexCanChangeCustomDataPath() throws Exception { Environment env = getInstanceFromNode(Environment.class); - Path idxPath = env.sharedDataFile().resolve(randomAsciiOfLength(10)); + Path idxPath = env.sharedDataFile().resolve(randomAlphaOfLength(10)); final String INDEX = "idx"; - Path startDir = idxPath.resolve("start-" + randomAsciiOfLength(10)); - Path endDir = idxPath.resolve("end-" + randomAsciiOfLength(10)); + Path startDir = idxPath.resolve("start-" + randomAlphaOfLength(10)); + Path endDir = idxPath.resolve("end-" + randomAlphaOfLength(10)); logger.info("--> start dir: [{}]", startDir.toAbsolutePath().toString()); logger.info("--> end dir: [{}]", endDir.toAbsolutePath().toString()); // temp dirs are automatically created, but the end dir is what diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java index 2eb91a16d8093..88d8a075e1b3e 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java @@ -44,7 +44,7 @@ public void testListenersAreExecuted() { AtomicInteger preDelete = new AtomicInteger(); AtomicInteger postDelete = new AtomicInteger(); AtomicInteger postDeleteException = new AtomicInteger(); - ShardId randomShardId = new ShardId(new Index(randomAsciiOfLength(10), randomAsciiOfLength(10)), randomIntBetween(1, 10)); + ShardId randomShardId = new ShardId(new Index(randomAlphaOfLength(10), randomAlphaOfLength(10)), randomIntBetween(1, 10)); IndexingOperationListener listener = new IndexingOperationListener() { @Override public Engine.Index preIndex(ShardId shardId, Engine.Index operation) { diff --git a/core/src/test/java/org/elasticsearch/index/shard/ShardIdTests.java b/core/src/test/java/org/elasticsearch/index/shard/ShardIdTests.java index dd05c10af9665..d7f6d14760471 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/ShardIdTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/ShardIdTests.java @@ -25,7 +25,7 @@ public class ShardIdTests extends ESTestCase { public void testShardIdFromString() { - String indexName = randomAsciiOfLengthBetween(3,50); + String indexName = randomAlphaOfLengthBetween(3,50); int shardId = randomInt(); ShardId id = ShardId.fromString("["+indexName+"]["+shardId+"]"); assertEquals(indexName, id.getIndexName()); diff --git a/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java b/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java index 2733d80e36a96..5f1578488cf1e 100644 --- a/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java +++ b/core/src/test/java/org/elasticsearch/index/snapshots/blobstore/FileInfoTests.java @@ -48,7 +48,7 @@ public void testToFromXContent() throws IOException { for (int i = 0; i < hash.length; i++) { hash.bytes[i] = randomByte(); } - StoreFileMetaData meta = new StoreFileMetaData("foobar", Math.abs(randomLong()), randomAsciiOfLengthBetween(1, 10), Version.LATEST, hash); + StoreFileMetaData meta = new StoreFileMetaData("foobar", Math.abs(randomLong()), randomAlphaOfLengthBetween(1, 10), Version.LATEST, hash); ByteSizeValue size = new ByteSizeValue(Math.abs(randomLong())); BlobStoreIndexShardSnapshot.FileInfo info = new BlobStoreIndexShardSnapshot.FileInfo("_foobar", meta, size); XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint(); diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java index 36401deed4bc2..6b2aa5e59215e 100644 --- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java +++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java @@ -258,7 +258,7 @@ public void testSimpleOperations() throws IOException { final long seqNo = randomNonNegativeLong(); final long primaryTerm = randomNonNegativeLong(); - final String reason = randomAsciiOfLength(16); + final String reason = randomAlphaOfLength(16); addToTranslogAndList(translog, ops, new Translog.NoOp(seqNo, primaryTerm, reason)); snapshot = translog.newSnapshot(); @@ -338,7 +338,7 @@ public void testStats() throws IOException { final long seqNo = 1; final long primaryTerm = 1; - translog.add(new Translog.NoOp(seqNo, primaryTerm, randomAsciiOfLength(16))); + translog.add(new Translog.NoOp(seqNo, primaryTerm, randomAlphaOfLength(16))); { final TranslogStats stats = stats(); assertThat(stats.estimatedNumberOfOperations(), equalTo(4L)); @@ -563,7 +563,7 @@ public void testTranslogChecksums() throws Exception { int translogOperations = randomIntBetween(10, 100); for (int op = 0; op < translogOperations; op++) { - String ascii = randomAsciiOfLengthBetween(1, 50); + String ascii = randomAlphaOfLengthBetween(1, 50); locations.add(translog.add(new Translog.Index("test", "" + op, ascii.getBytes("UTF-8")))); } translog.sync(); @@ -589,7 +589,7 @@ public void testTruncatedTranslogs() throws Exception { int translogOperations = randomIntBetween(10, 100); for (int op = 0; op < translogOperations; op++) { - String ascii = randomAsciiOfLengthBetween(1, 50); + String ascii = randomAlphaOfLengthBetween(1, 50); locations.add(translog.add(new Translog.Index("test", "" + op, ascii.getBytes("UTF-8")))); } translog.sync(); @@ -1406,7 +1406,7 @@ public void run() { randomFrom(VersionType.values())); break; case NO_OP: - op = new Translog.NoOp(randomNonNegativeLong(), randomNonNegativeLong(), randomAsciiOfLength(16)); + op = new Translog.NoOp(randomNonNegativeLong(), randomNonNegativeLong(), randomAlphaOfLength(16)); break; default: throw new AssertionError("unsupported operation type [" + type + "]"); diff --git a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java index 9b5cb7a138d3b..63f889179a27c 100644 --- a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java +++ b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java @@ -195,7 +195,7 @@ public void testCreateIndexWithLongName() { int min = MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES + 1; int max = MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES * 2; try { - createIndex(randomAsciiOfLengthBetween(min, max).toLowerCase(Locale.ROOT)); + createIndex(randomAlphaOfLengthBetween(min, max).toLowerCase(Locale.ROOT)); fail("exception should have been thrown on too-long index name"); } catch (InvalidIndexNameException e) { assertThat("exception contains message about index name too long: " + e.getMessage(), @@ -203,7 +203,7 @@ public void testCreateIndexWithLongName() { } try { - client().prepareIndex(randomAsciiOfLengthBetween(min, max).toLowerCase(Locale.ROOT), "mytype").setSource("foo", "bar").get(); + client().prepareIndex(randomAlphaOfLengthBetween(min, max).toLowerCase(Locale.ROOT), "mytype").setSource("foo", "bar").get(); fail("exception should have been thrown on too-long index name"); } catch (InvalidIndexNameException e) { assertThat("exception contains message about index name too long: " + e.getMessage(), @@ -212,7 +212,7 @@ public void testCreateIndexWithLongName() { try { // Catch chars that are more than a single byte - client().prepareIndex(randomAsciiOfLength(MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES - 1).toLowerCase(Locale.ROOT) + + client().prepareIndex(randomAlphaOfLength(MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES - 1).toLowerCase(Locale.ROOT) + "Ïž".toLowerCase(Locale.ROOT), "mytype").setSource("foo", "bar").get(); fail("exception should have been thrown on too-long index name"); @@ -222,7 +222,7 @@ public void testCreateIndexWithLongName() { } // we can create an index of max length - createIndex(randomAsciiOfLength(MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES).toLowerCase(Locale.ROOT)); + createIndex(randomAlphaOfLength(MetaDataCreateIndexService.MAX_INDEX_NAME_BYTES).toLowerCase(Locale.ROOT)); } public void testInvalidIndexName() { diff --git a/core/src/test/java/org/elasticsearch/indices/NodeIndicesStatsTests.java b/core/src/test/java/org/elasticsearch/indices/NodeIndicesStatsTests.java index f712a5ba8434a..b8ae55a44d28e 100644 --- a/core/src/test/java/org/elasticsearch/indices/NodeIndicesStatsTests.java +++ b/core/src/test/java/org/elasticsearch/indices/NodeIndicesStatsTests.java @@ -31,7 +31,7 @@ public class NodeIndicesStatsTests extends ESTestCase { public void testInvalidLevel() { final NodeIndicesStats stats = new NodeIndicesStats(); - final String level = randomAsciiOfLength(16); + final String level = randomAlphaOfLength(16); final ToXContent.Params params = new ToXContent.MapParams(Collections.singletonMap("level", level)); final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> stats.toXContent(null, params)); assertThat( diff --git a/core/src/test/java/org/elasticsearch/indices/TermsLookupTests.java b/core/src/test/java/org/elasticsearch/indices/TermsLookupTests.java index fea69133377f0..07fe5e00a2482 100644 --- a/core/src/test/java/org/elasticsearch/indices/TermsLookupTests.java +++ b/core/src/test/java/org/elasticsearch/indices/TermsLookupTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.indices.TermsLookup; import org.elasticsearch.test.ESTestCase; import java.io.IOException; @@ -30,11 +29,11 @@ public class TermsLookupTests extends ESTestCase { public void testTermsLookup() { - String index = randomAsciiOfLengthBetween(1, 10); - String type = randomAsciiOfLengthBetween(1, 10); - String id = randomAsciiOfLengthBetween(1, 10); - String path = randomAsciiOfLengthBetween(1, 10); - String routing = randomAsciiOfLengthBetween(1, 10); + String index = randomAlphaOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); + String id = randomAlphaOfLengthBetween(1, 10); + String path = randomAlphaOfLengthBetween(1, 10); + String routing = randomAlphaOfLengthBetween(1, 10); TermsLookup termsLookup = new TermsLookup(index, type, id, path); termsLookup.routing(routing); assertEquals(index, termsLookup.index()); @@ -45,9 +44,9 @@ public void testTermsLookup() { } public void testIllegalArguments() { - String type = randomAsciiOfLength(5); - String id = randomAsciiOfLength(5); - String path = randomAsciiOfLength(5); + String type = randomAlphaOfLength(5); + String id = randomAlphaOfLength(5); + String path = randomAlphaOfLength(5); switch (randomIntBetween(0, 2)) { case 0: type = null; @@ -81,10 +80,10 @@ public void testSerialization() throws IOException { public static TermsLookup randomTermsLookup() { return new TermsLookup( - randomBoolean() ? randomAsciiOfLength(10) : null, - randomAsciiOfLength(10), - randomAsciiOfLength(10), - randomAsciiOfLength(10).replace('.', '_') - ).routing(randomBoolean() ? randomAsciiOfLength(10) : null); + randomBoolean() ? randomAlphaOfLength(10) : null, + randomAlphaOfLength(10), + randomAlphaOfLength(10), + randomAlphaOfLength(10).replace('.', '_') + ).routing(randomBoolean() ? randomAlphaOfLength(10) : null); } } diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java index 5186480d5cd1c..d6e93ce559e11 100644 --- a/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/analysis/PreBuiltAnalyzerIntegrationIT.java @@ -54,7 +54,7 @@ public void testThatPreBuiltAnalyzersAreNotClosedOnIndexClose() throws Exception List indexNames = new ArrayList<>(); final int numIndices = scaledRandomIntBetween(2, 4); for (int i = 0; i < numIndices; i++) { - String indexName = randomAsciiOfLength(10).toLowerCase(Locale.ROOT); + String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); indexNames.add(indexName); int randomInt = randomInt(PreBuiltAnalyzers.values().length-1); @@ -91,7 +91,7 @@ public void testThatPreBuiltAnalyzersAreNotClosedOnIndexClose() throws Exception String randomId = randomInt() + ""; Map data = new HashMap<>(); - data.put("foo", randomAsciiOfLength(scaledRandomIntBetween(5, 50))); + data.put("foo", randomAlphaOfLength(scaledRandomIntBetween(5, 50))); index(randomIndex, "type", randomId, data); } diff --git a/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java b/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java index 37f6c989229fb..064e9d78b511c 100644 --- a/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java +++ b/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java @@ -159,7 +159,7 @@ public void testRandomClusterStateUpdates() { */ public void testJoiningNewClusterOnlyRemovesInMemoryIndexStructures() { // a cluster state derived from the initial state that includes a created index - String name = "index_" + randomAsciiOfLength(8).toLowerCase(Locale.ROOT); + String name = "index_" + randomAlphaOfLength(8).toLowerCase(Locale.ROOT); ShardRoutingState[] replicaStates = new ShardRoutingState[randomIntBetween(0, 3)]; Arrays.fill(replicaStates, ShardRoutingState.INITIALIZING); ClusterState stateWithIndex = ClusterStateCreationUtils.state(name, randomBoolean(), ShardRoutingState.INITIALIZING, replicaStates); @@ -245,7 +245,7 @@ public ClusterState randomlyUpdateClusterState(ClusterState state, if (state.metaData().indices().size() > 200) { break; } - String name = "index_" + randomAsciiOfLength(15).toLowerCase(Locale.ROOT); + String name = "index_" + randomAlphaOfLength(15).toLowerCase(Locale.ROOT); Settings.Builder settingsBuilder = Settings.builder() .put(SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 3)) .put(SETTING_NUMBER_OF_REPLICAS, randomInt(2)); diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 48c8c2e5f28da..a21f7757eac24 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -531,7 +531,7 @@ private IndicesStatsResponse createAndPopulateIndex(String name, int nodeCount, for (int i = 0; i < numDocs; i++) { docs[i] = client().prepareIndex(name, INDEX_TYPE). setSource("foo-int", randomInt(), - "foo-string", randomAsciiOfLength(32), + "foo-string", randomAlphaOfLength(32), "foo-float", randomFloat()); } diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java index 1245725e05590..4f893c946ecb4 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java @@ -521,7 +521,7 @@ Index createObj() { @Override public void run() { for (int i = 0; i < 1000; i++) { - index.addFileDetail(randomAsciiOfLength(10), 100, true); + index.addFileDetail(randomAlphaOfLength(10), 100, true); } stop.set(true); } diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java index 7f0e93504889f..1c091d6b015cb 100644 --- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java +++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreTests.java @@ -20,38 +20,22 @@ package org.elasticsearch.indices.store; import org.elasticsearch.Version; -import org.elasticsearch.cluster.ClusterName; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.IndexShardRoutingTable; import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.TestShardRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.threadpool.TestThreadPool; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import java.util.concurrent.TimeUnit; import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; -import static org.elasticsearch.Version.CURRENT; import static org.elasticsearch.test.ClusterServiceUtils.createClusterService; -import static org.elasticsearch.test.VersionUtils.randomVersion; public class IndicesStoreTests extends ESTestCase { private static final ShardRoutingState[] NOT_STARTED_STATES; @@ -94,8 +78,8 @@ public void testShardCanBeDeletedNoShardStarted() throws Exception { if (state == ShardRoutingState.UNASSIGNED) { unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, null); } - String relocatingNodeId = state == ShardRoutingState.RELOCATING ? randomAsciiOfLength(10) : null; - routingTable.addShard(TestShardRouting.newShardRouting("test", i, randomAsciiOfLength(10), relocatingNodeId, j == 0, state, unassignedInfo)); + String relocatingNodeId = state == ShardRoutingState.RELOCATING ? randomAlphaOfLength(10) : null; + routingTable.addShard(TestShardRouting.newShardRouting("test", i, randomAlphaOfLength(10), relocatingNodeId, j == 0, state, unassignedInfo)); } } @@ -111,10 +95,10 @@ public void testShardCanBeDeletedShardExistsLocally() throws Exception { for (int i = 0; i < numShards; i++) { int localNodeIndex = randomInt(numReplicas); boolean primaryOnLocalNode = i == localShardId && localNodeIndex == numReplicas; - routingTable.addShard(TestShardRouting.newShardRouting("test", i, primaryOnLocalNode ? localNode.getId() : randomAsciiOfLength(10), true, ShardRoutingState.STARTED)); + routingTable.addShard(TestShardRouting.newShardRouting("test", i, primaryOnLocalNode ? localNode.getId() : randomAlphaOfLength(10), true, ShardRoutingState.STARTED)); for (int j = 0; j < numReplicas; j++) { boolean replicaOnLocalNode = i == localShardId && localNodeIndex == j; - routingTable.addShard(TestShardRouting.newShardRouting("test", i, replicaOnLocalNode ? localNode.getId() : randomAsciiOfLength(10), false, ShardRoutingState.STARTED)); + routingTable.addShard(TestShardRouting.newShardRouting("test", i, replicaOnLocalNode ? localNode.getId() : randomAlphaOfLength(10), false, ShardRoutingState.STARTED)); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java b/core/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java index 1bd5676f47425..e1ec12e29b692 100644 --- a/core/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java @@ -912,12 +912,12 @@ public void testEqualsAndHashcode() throws Exception { Map sourceAndMetadata = RandomDocumentPicks.randomSource(random()); int numFields = randomIntBetween(1, IngestDocument.MetaData.values().length); for (int i = 0; i < numFields; i++) { - sourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAsciiOfLengthBetween(5, 10)); + sourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAlphaOfLengthBetween(5, 10)); } Map ingestMetadata = new HashMap<>(); numFields = randomIntBetween(1, 5); for (int i = 0; i < numFields; i++) { - ingestMetadata.put(randomAsciiOfLengthBetween(5, 10), randomAsciiOfLengthBetween(5, 10)); + ingestMetadata.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); } IngestDocument ingestDocument = new IngestDocument(sourceAndMetadata, ingestMetadata); @@ -932,7 +932,7 @@ public void testEqualsAndHashcode() throws Exception { if (randomBoolean()) { numFields = randomIntBetween(1, IngestDocument.MetaData.values().length); for (int i = 0; i < numFields; i++) { - otherSourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAsciiOfLengthBetween(5, 10)); + otherSourceAndMetadata.put(randomFrom(IngestDocument.MetaData.values()).getFieldName(), randomAlphaOfLengthBetween(5, 10)); } changed = true; } @@ -942,7 +942,7 @@ public void testEqualsAndHashcode() throws Exception { otherIngestMetadata = new HashMap<>(); numFields = randomIntBetween(1, 5); for (int i = 0; i < numFields; i++) { - otherIngestMetadata.put(randomAsciiOfLengthBetween(5, 10), randomAsciiOfLengthBetween(5, 10)); + otherIngestMetadata.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)); } changed = true; } else { diff --git a/core/src/test/java/org/elasticsearch/monitor/fs/DeviceStatsTests.java b/core/src/test/java/org/elasticsearch/monitor/fs/DeviceStatsTests.java index 758f67ff563f3..85aeed9485f9c 100644 --- a/core/src/test/java/org/elasticsearch/monitor/fs/DeviceStatsTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/fs/DeviceStatsTests.java @@ -28,7 +28,7 @@ public class DeviceStatsTests extends ESTestCase { public void testDeviceStats() { final int majorDeviceNumber = randomIntBetween(1, 1 << 8); final int minorDeviceNumber = randomIntBetween(0, 1 << 5); - final String deviceName = randomAsciiOfLength(3); + final String deviceName = randomAlphaOfLength(3); final int readsCompleted = randomIntBetween(1, 1 << 16); final int sectorsRead = randomIntBetween(8 * readsCompleted, 16 * readsCompleted); final int writesCompleted = randomIntBetween(1, 1 << 16); diff --git a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java index dc374f133391c..48817e52d562e 100644 --- a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java @@ -55,7 +55,7 @@ public void testDisabledSetting() throws InterruptedException { } public void testNegativeSetting() throws InterruptedException { - String collector = randomAsciiOfLength(5); + String collector = randomAlphaOfLength(5); Settings settings = Settings.builder().put("monitor.jvm.gc.collector." + collector + ".warn", "-" + randomTimeValue()).build(); execute(settings, (command, interval, name) -> null, e -> { assertThat(e, instanceOf(IllegalArgumentException.class)); @@ -64,7 +64,7 @@ public void testNegativeSetting() throws InterruptedException { } public void testMissingSetting() throws InterruptedException { - String collector = randomAsciiOfLength(5); + String collector = randomAlphaOfLength(5); Set> entries = new HashSet<>(); entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".warn", randomPositiveTimeValue())); entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".info", randomPositiveTimeValue())); diff --git a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceTests.java b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceTests.java index ca3a1d7070d55..711988d5a826b 100644 --- a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceTests.java @@ -37,7 +37,7 @@ public void testSlowGcLogging() { when(logger.isInfoEnabled()).thenReturn(true); when(logger.isDebugEnabled()).thenReturn(true); final JvmGcMonitorService.JvmMonitor.Threshold threshold = randomFrom(JvmGcMonitorService.JvmMonitor.Threshold.values()); - final String name = randomAsciiOfLength(16); + final String name = randomAlphaOfLength(16); final long seq = randomIntBetween(1, 1 << 30); final int elapsedValue = randomIntBetween(1, 1 << 10); final long totalCollectionCount = randomIntBetween(1, 16); diff --git a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java index 4cceddb6a9652..71305c41f56d7 100644 --- a/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/os/OsProbeTests.java @@ -148,7 +148,7 @@ public void testCgroupProbe() { assumeTrue("test runs on Linux only", Constants.LINUX); final boolean areCgroupStatsAvailable = randomBoolean(); - final String hierarchy = randomAsciiOfLength(16); + final String hierarchy = randomAlphaOfLength(16); final OsProbe probe = new OsProbe() { diff --git a/core/src/test/java/org/elasticsearch/monitor/os/OsStatsTests.java b/core/src/test/java/org/elasticsearch/monitor/os/OsStatsTests.java index 9f8b60a55a9d7..f1e2371db5cb7 100644 --- a/core/src/test/java/org/elasticsearch/monitor/os/OsStatsTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/os/OsStatsTests.java @@ -37,9 +37,9 @@ public void testSerialization() throws IOException { OsStats.Mem mem = new OsStats.Mem(randomLong(), randomLong()); OsStats.Swap swap = new OsStats.Swap(randomLong(), randomLong()); OsStats.Cgroup cgroup = new OsStats.Cgroup( - randomAsciiOfLength(8), + randomAlphaOfLength(8), randomNonNegativeLong(), - randomAsciiOfLength(8), + randomAlphaOfLength(8), randomNonNegativeLong(), randomNonNegativeLong(), new OsStats.Cgroup.CpuStat(randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong())); diff --git a/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java b/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java index 51aad14227883..f830e8b62727a 100644 --- a/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java +++ b/core/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java @@ -113,9 +113,9 @@ private static NodeInfo createNodeInfo() { int availableProcessors = randomIntBetween(1, 64); int allocatedProcessors = randomIntBetween(1, availableProcessors); long refreshInterval = randomBoolean() ? -1 : randomNonNegativeLong(); - String name = randomAsciiOfLengthBetween(3, 10); - String arch = randomAsciiOfLengthBetween(3, 10); - String version = randomAsciiOfLengthBetween(3, 10); + String name = randomAlphaOfLengthBetween(3, 10); + String arch = randomAlphaOfLengthBetween(3, 10); + String version = randomAlphaOfLengthBetween(3, 10); osInfo = new OsInfo(refreshInterval, availableProcessors, allocatedProcessors, name, arch, version); } ProcessInfo process = randomBoolean() ? null : new ProcessInfo(randomInt(), randomBoolean(), randomNonNegativeLong()); @@ -125,7 +125,7 @@ private static NodeInfo createNodeInfo() { int numThreadPools = randomIntBetween(1, 10); List threadPoolInfos = new ArrayList<>(numThreadPools); for (int i = 0; i < numThreadPools; i++) { - threadPoolInfos.add(new ThreadPool.Info(randomAsciiOfLengthBetween(3, 10), + threadPoolInfos.add(new ThreadPool.Info(randomAlphaOfLengthBetween(3, 10), randomFrom(ThreadPool.ThreadPoolType.values()), randomInt())); } threadPoolInfo = new ThreadPoolInfo(threadPoolInfos); @@ -142,14 +142,14 @@ private static NodeInfo createNodeInfo() { int numPlugins = randomIntBetween(0, 5); List plugins = new ArrayList<>(); for (int i = 0; i < numPlugins; i++) { - plugins.add(new PluginInfo(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), - randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomBoolean())); + plugins.add(new PluginInfo(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), + randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), randomBoolean())); } int numModules = randomIntBetween(0, 5); List modules = new ArrayList<>(); for (int i = 0; i < numModules; i++) { - modules.add(new PluginInfo(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), - randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomBoolean())); + modules.add(new PluginInfo(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), + randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), randomBoolean())); } pluginsAndModules = new PluginsAndModules(plugins, modules); } @@ -159,7 +159,7 @@ private static NodeInfo createNodeInfo() { int numProcessors = randomIntBetween(0, 5); List processors = new ArrayList<>(numProcessors); for (int i = 0; i < numProcessors; i++) { - processors.add(new ProcessorInfo(randomAsciiOfLengthBetween(3, 10))); + processors.add(new ProcessorInfo(randomAlphaOfLengthBetween(3, 10))); } ingestInfo = new IngestInfo(processors); } diff --git a/core/src/test/java/org/elasticsearch/repositories/IndexIdTests.java b/core/src/test/java/org/elasticsearch/repositories/IndexIdTests.java index 9c39061419c26..51167d862fdfd 100644 --- a/core/src/test/java/org/elasticsearch/repositories/IndexIdTests.java +++ b/core/src/test/java/org/elasticsearch/repositories/IndexIdTests.java @@ -36,7 +36,7 @@ public class IndexIdTests extends ESTestCase { public void testEqualsAndHashCode() { // assert equals and hashcode - String name = randomAsciiOfLength(8); + String name = randomAlphaOfLength(8); String id = UUIDs.randomBase64UUID(); IndexId indexId1 = new IndexId(name, id); IndexId indexId2 = new IndexId(name, id); @@ -49,7 +49,7 @@ public void testEqualsAndHashCode() { assertEquals(indexId1, indexId2); assertEquals(indexId1.hashCode(), indexId2.hashCode()); //assert not equals when name or id differ - indexId2 = new IndexId(randomAsciiOfLength(8), id); + indexId2 = new IndexId(randomAlphaOfLength(8), id); assertNotEquals(indexId1, indexId2); assertNotEquals(indexId1.hashCode(), indexId2.hashCode()); indexId2 = new IndexId(name, UUIDs.randomBase64UUID()); @@ -58,14 +58,14 @@ public void testEqualsAndHashCode() { } public void testSerialization() throws IOException { - IndexId indexId = new IndexId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()); + IndexId indexId = new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); BytesStreamOutput out = new BytesStreamOutput(); indexId.writeTo(out); assertEquals(indexId, new IndexId(out.bytes().streamInput())); } public void testXContent() throws IOException { - IndexId indexId = new IndexId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()); + IndexId indexId = new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); XContentBuilder builder = JsonXContent.contentBuilder(); indexId.toXContent(builder, ToXContent.EMPTY_PARAMS); XContentParser parser = createParser(JsonXContent.jsonXContent, builder.bytes()); diff --git a/core/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java b/core/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java index f9c620e3b9e00..6c548a38cb356 100644 --- a/core/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java +++ b/core/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java @@ -68,12 +68,12 @@ public void testAddSnapshots() { // test that adding the same snapshot id to the repository data throws an exception Map indexIdMap = repositoryData.getIndices(); // test that adding a snapshot and its indices works - SnapshotId newSnapshot = new SnapshotId(randomAsciiOfLength(7), UUIDs.randomBase64UUID()); + SnapshotId newSnapshot = new SnapshotId(randomAlphaOfLength(7), UUIDs.randomBase64UUID()); List indices = new ArrayList<>(); Set newIndices = new HashSet<>(); int numNew = randomIntBetween(1, 10); for (int i = 0; i < numNew; i++) { - IndexId indexId = new IndexId(randomAsciiOfLength(7), UUIDs.randomBase64UUID()); + IndexId indexId = new IndexId(randomAlphaOfLength(7), UUIDs.randomBase64UUID()); newIndices.add(indexId); indices.add(indexId); } @@ -99,7 +99,7 @@ public void testInitIndices() { final int numSnapshots = randomIntBetween(1, 30); final List snapshotIds = new ArrayList<>(numSnapshots); for (int i = 0; i < numSnapshots; i++) { - snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID())); + snapshotIds.add(new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())); } RepositoryData repositoryData = new RepositoryData(EMPTY_REPO_GEN, snapshotIds, Collections.emptyMap(), Collections.emptyList()); // test that initializing indices works @@ -131,7 +131,7 @@ public void testResolveIndexId() { String indexName = indexNames.iterator().next(); IndexId indexId = indices.get(indexName); assertEquals(indexId, repositoryData.resolveIndexId(indexName)); - String notInRepoData = randomAsciiOfLength(5); + String notInRepoData = randomAlphaOfLength(5); assertFalse(indexName.contains(notInRepoData)); assertEquals(new IndexId(notInRepoData, notInRepoData), repositoryData.resolveIndexId(notInRepoData)); } @@ -149,7 +149,7 @@ private static List randomSnapshots(final List origSnaps final int numSnapshots = randomIntBetween(1, 30); final List snapshotIds = new ArrayList<>(origSnapshotIds); for (int i = 0; i < numSnapshots; i++) { - snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID())); + snapshotIds.add(new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())); } return snapshotIds; } @@ -159,7 +159,7 @@ private static Map> randomIndices(final List> indices = new HashMap<>(numIndices); for (int i = 0; i < numIndices; i++) { - final IndexId indexId = new IndexId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()); + final IndexId indexId = new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); final Set indexSnapshots = new LinkedHashSet<>(); final int numIndicesForSnapshot = randomIntBetween(1, numIndices); for (int j = 0; j < numIndicesForSnapshot; j++) { diff --git a/core/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java b/core/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java index 6e538e721a420..4b57fa43cfe32 100644 --- a/core/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java +++ b/core/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java @@ -179,7 +179,7 @@ public void testReadAndWriteIncompatibleSnapshots() throws Exception { final int numSnapshots = randomIntBetween(1, 20); final List snapshotIds = new ArrayList<>(numSnapshots); for (int i = 0; i < numSnapshots; i++) { - snapshotIds.add(new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID())); + snapshotIds.add(new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())); } RepositoryData repositoryData = new RepositoryData(readData.getGenId(), Collections.emptyList(), Collections.emptyMap(), snapshotIds); @@ -210,11 +210,11 @@ private BlobStoreRepository setupRepo() { private RepositoryData addRandomSnapshotsToRepoData(RepositoryData repoData, boolean inclIndices) { int numSnapshots = randomIntBetween(1, 20); for (int i = 0; i < numSnapshots; i++) { - SnapshotId snapshotId = new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID()); + SnapshotId snapshotId = new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); int numIndices = inclIndices ? randomIntBetween(0, 20) : 0; List indexIds = new ArrayList<>(numIndices); for (int j = 0; j < numIndices; j++) { - indexIds.add(new IndexId(randomAsciiOfLength(8), UUIDs.randomBase64UUID())); + indexIds.add(new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())); } repoData = repoData.addSnapshot(snapshotId, indexIds); } diff --git a/core/src/test/java/org/elasticsearch/rest/BaseRestHandlerTests.java b/core/src/test/java/org/elasticsearch/rest/BaseRestHandlerTests.java index 80ee4dd6d0de8..732614112bd99 100644 --- a/core/src/test/java/org/elasticsearch/rest/BaseRestHandlerTests.java +++ b/core/src/test/java/org/elasticsearch/rest/BaseRestHandlerTests.java @@ -50,8 +50,8 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli }; final HashMap params = new HashMap<>(); - params.put("consumed", randomAsciiOfLength(8)); - params.put("unconsumed", randomAsciiOfLength(8)); + params.put("consumed", randomAlphaOfLength(8)); + params.put("unconsumed", randomAlphaOfLength(8)); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build(); RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); final IllegalArgumentException e = @@ -71,9 +71,9 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli }; final HashMap params = new HashMap<>(); - params.put("consumed", randomAsciiOfLength(8)); - params.put("unconsumed-first", randomAsciiOfLength(8)); - params.put("unconsumed-second", randomAsciiOfLength(8)); + params.put("consumed", randomAlphaOfLength(8)); + params.put("unconsumed-first", randomAlphaOfLength(8)); + params.put("unconsumed-second", randomAlphaOfLength(8)); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build(); RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); final IllegalArgumentException e = @@ -102,12 +102,12 @@ protected Set responseParams() { }; final HashMap params = new HashMap<>(); - params.put("consumed", randomAsciiOfLength(8)); - params.put("flied", randomAsciiOfLength(8)); - params.put("respones_param", randomAsciiOfLength(8)); - params.put("tokenzier", randomAsciiOfLength(8)); - params.put("very_close_to_parametre", randomAsciiOfLength(8)); - params.put("very_far_from_every_consumed_parameter", randomAsciiOfLength(8)); + params.put("consumed", randomAlphaOfLength(8)); + params.put("flied", randomAlphaOfLength(8)); + params.put("respones_param", randomAlphaOfLength(8)); + params.put("tokenzier", randomAlphaOfLength(8)); + params.put("very_close_to_parametre", randomAlphaOfLength(8)); + params.put("very_far_from_every_consumed_parameter", randomAlphaOfLength(8)); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build(); RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); final IllegalArgumentException e = @@ -140,8 +140,8 @@ protected Set responseParams() { }; final HashMap params = new HashMap<>(); - params.put("consumed", randomAsciiOfLength(8)); - params.put("response_param", randomAsciiOfLength(8)); + params.put("consumed", randomAlphaOfLength(8)); + params.put("response_param", randomAlphaOfLength(8)); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build(); RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); handler.handleRequest(request, channel, mock(NodeClient.class)); @@ -158,8 +158,8 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli }; final HashMap params = new HashMap<>(); - params.put("format", randomAsciiOfLength(8)); - params.put("filter_path", randomAsciiOfLength(8)); + params.put("format", randomAlphaOfLength(8)); + params.put("filter_path", randomAlphaOfLength(8)); params.put("pretty", randomFrom("true", "false", "", null)); params.put("human", null); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build(); @@ -188,14 +188,14 @@ protected Table getTableWithHeader(RestRequest request) { }; final HashMap params = new HashMap<>(); - params.put("format", randomAsciiOfLength(8)); - params.put("h", randomAsciiOfLength(8)); - params.put("v", randomAsciiOfLength(8)); - params.put("ts", randomAsciiOfLength(8)); - params.put("pri", randomAsciiOfLength(8)); - params.put("bytes", randomAsciiOfLength(8)); - params.put("size", randomAsciiOfLength(8)); - params.put("time", randomAsciiOfLength(8)); + params.put("format", randomAlphaOfLength(8)); + params.put("h", randomAlphaOfLength(8)); + params.put("v", randomAlphaOfLength(8)); + params.put("ts", randomAlphaOfLength(8)); + params.put("pri", randomAlphaOfLength(8)); + params.put("bytes", randomAlphaOfLength(8)); + params.put("size", randomAlphaOfLength(8)); + params.put("time", randomAlphaOfLength(8)); RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build(); RestChannel channel = new FakeRestChannel(request, randomBoolean(), 1); handler.handleRequest(request, channel, mock(NodeClient.class)); diff --git a/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java b/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java index 431bc152bd9eb..37bed74f7939e 100644 --- a/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java +++ b/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java @@ -302,8 +302,8 @@ public void testErrorToAndFromXContent() throws IOException { expected.addMetadata("es.metadata_0", "0"); } if (randomBoolean()) { - String resourceType = randomAsciiOfLength(5); - String resourceId = randomAsciiOfLength(5); + String resourceType = randomAlphaOfLength(5); + String resourceId = randomAlphaOfLength(5); originalException.setResources(resourceType, resourceId); expected.setResources(resourceType, resourceId); } diff --git a/core/src/test/java/org/elasticsearch/rest/DeprecationRestHandlerTests.java b/core/src/test/java/org/elasticsearch/rest/DeprecationRestHandlerTests.java index 3c31b5b7f4d79..0a8ace71d8860 100644 --- a/core/src/test/java/org/elasticsearch/rest/DeprecationRestHandlerTests.java +++ b/core/src/test/java/org/elasticsearch/rest/DeprecationRestHandlerTests.java @@ -38,7 +38,7 @@ public class DeprecationRestHandlerTests extends ESTestCase { /** * Note: Headers should only use US ASCII (and this inevitably becomes one!). */ - private final String deprecationMessage = randomAsciiOfLengthBetween(1, 30); + private final String deprecationMessage = randomAlphaOfLengthBetween(1, 30); private final DeprecationLogger deprecationLogger = mock(DeprecationLogger.class); public void testNullHandler() { diff --git a/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java b/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java index 1e279a75218b0..102cfe5e3ac53 100644 --- a/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java +++ b/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java @@ -130,9 +130,9 @@ public void testRegisterAsDeprecatedHandler() { RestController controller = mock(RestController.class); RestRequest.Method method = randomFrom(RestRequest.Method.values()); - String path = "/_" + randomAsciiOfLengthBetween(1, 6); + String path = "/_" + randomAlphaOfLengthBetween(1, 6); RestHandler handler = mock(RestHandler.class); - String deprecationMessage = randomAsciiOfLengthBetween(1, 10); + String deprecationMessage = randomAlphaOfLengthBetween(1, 10); DeprecationLogger logger = mock(DeprecationLogger.class); // don't want to test everything -- just that it actually wraps the handler @@ -147,10 +147,10 @@ public void testRegisterWithDeprecatedHandler() { final RestController controller = mock(RestController.class); final RestRequest.Method method = randomFrom(RestRequest.Method.values()); - final String path = "/_" + randomAsciiOfLengthBetween(1, 6); + final String path = "/_" + randomAlphaOfLengthBetween(1, 6); final RestHandler handler = mock(RestHandler.class); final RestRequest.Method deprecatedMethod = randomFrom(RestRequest.Method.values()); - final String deprecatedPath = "/_" + randomAsciiOfLengthBetween(1, 6); + final String deprecatedPath = "/_" + randomAlphaOfLengthBetween(1, 6); final DeprecationLogger logger = mock(DeprecationLogger.class); final String deprecationMessage = "[" + deprecatedMethod.name() + " " + deprecatedPath + "] is deprecated! Use [" + @@ -206,7 +206,7 @@ public boolean canTripCircuitBreaker() { public void testDispatchRequestAddsAndFreesBytesOnSuccess() { int contentLength = BREAKER_LIMIT.bytesAsInt(); - String content = randomAsciiOfLength(contentLength); + String content = randomAlphaOfLength(contentLength); TestRestRequest request = new TestRestRequest("/", content, XContentType.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.OK); @@ -218,7 +218,7 @@ public void testDispatchRequestAddsAndFreesBytesOnSuccess() { public void testDispatchRequestAddsAndFreesBytesOnError() { int contentLength = BREAKER_LIMIT.bytesAsInt(); - String content = randomAsciiOfLength(contentLength); + String content = randomAlphaOfLength(contentLength); TestRestRequest request = new TestRestRequest("/error", content, XContentType.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.BAD_REQUEST); @@ -230,7 +230,7 @@ public void testDispatchRequestAddsAndFreesBytesOnError() { public void testDispatchRequestAddsAndFreesBytesOnlyOnceOnError() { int contentLength = BREAKER_LIMIT.bytesAsInt(); - String content = randomAsciiOfLength(contentLength); + String content = randomAlphaOfLength(contentLength); // we will produce an error in the rest handler and one more when sending the error response TestRestRequest request = new TestRestRequest("/error", content, XContentType.JSON); ExceptionThrowingChannel channel = new ExceptionThrowingChannel(request, true); @@ -243,7 +243,7 @@ public void testDispatchRequestAddsAndFreesBytesOnlyOnceOnError() { public void testDispatchRequestLimitsBytes() { int contentLength = BREAKER_LIMIT.bytesAsInt() + 1; - String content = randomAsciiOfLength(contentLength); + String content = randomAlphaOfLength(contentLength); TestRestRequest request = new TestRestRequest("/", content, XContentType.JSON); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.SERVICE_UNAVAILABLE); @@ -254,7 +254,7 @@ public void testDispatchRequestLimitsBytes() { } public void testDispatchRequiresContentTypeForRequestsWithContent() { - String content = randomAsciiOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); + String content = randomAlphaOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); TestRestRequest request = new TestRestRequest("/", content, null); AssertingChannel channel = new AssertingChannel(request, true, RestStatus.NOT_ACCEPTABLE); restController = new RestController( @@ -279,7 +279,7 @@ public void testDispatchDoesNotRequireContentTypeForRequestsWithoutContent() { } public void testDispatchFailsWithPlainText() { - String content = randomAsciiOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); + String content = randomAlphaOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY) .withContent(new BytesArray(content), null).withPath("/foo") .withHeaders(Collections.singletonMap("Content-Type", Collections.singletonList("text/plain"))).build(); @@ -309,7 +309,7 @@ public void testDispatchUnsupportedContentType() { public void testDispatchWorksWithNewlineDelimitedJson() { final String mimeType = "application/x-ndjson"; - String content = randomAsciiOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); + String content = randomAlphaOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY) .withContent(new BytesArray(content), null).withPath("/foo") .withHeaders(Collections.singletonMap("Content-Type", Collections.singletonList(mimeType))).build(); @@ -333,7 +333,7 @@ public boolean supportsContentStream() { public void testDispatchWithContentStream() { final String mimeType = randomFrom("application/json", "application/smile"); - String content = randomAsciiOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); + String content = randomAlphaOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt()); FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY) .withContent(new BytesArray(content), null).withPath("/foo") .withHeaders(Collections.singletonMap("Content-Type", Collections.singletonList(mimeType))).build(); diff --git a/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java b/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java index fa5b25e4549c6..14eb413de083b 100644 --- a/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java +++ b/core/src/test/java/org/elasticsearch/rest/RestRequestTests.java @@ -113,7 +113,7 @@ public void testContentTypeParsing() { } public void testPlainTextSupport() { - ContentRestRequest restRequest = new ContentRestRequest(randomAsciiOfLengthBetween(1, 30), Collections.emptyMap(), + ContentRestRequest restRequest = new ContentRestRequest(randomAlphaOfLengthBetween(1, 30), Collections.emptyMap(), Collections.singletonMap("Content-Type", Collections.singletonList(randomFrom("text/plain", "text/plain; charset=utf-8", "text/plain;charset=utf-8")))); assertNull(restRequest.getXContentType()); @@ -132,7 +132,7 @@ public void testNoContentTypeHeader() { } public void testMultipleContentTypeHeaders() { - List headers = new ArrayList<>(randomUnique(() -> randomAsciiOfLengthBetween(1, 16), randomIntBetween(2, 10))); + List headers = new ArrayList<>(randomUnique(() -> randomAlphaOfLengthBetween(1, 16), randomIntBetween(2, 10))); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new ContentRestRequest("", Collections.emptyMap(), Collections.singletonMap("Content-Type", headers))); assertEquals("only one Content-Type header should be provided", e.getMessage()); diff --git a/core/src/test/java/org/elasticsearch/rest/action/RestMainActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/RestMainActionTests.java index 8a78cce825947..13e6de063e81e 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/RestMainActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/RestMainActionTests.java @@ -43,7 +43,7 @@ public class RestMainActionTests extends ESTestCase { public void testHeadResponse() throws Exception { final String nodeName = "node1"; final ClusterName clusterName = new ClusterName("cluster1"); - final String clusterUUID = randomAsciiOfLengthBetween(10, 20); + final String clusterUUID = randomAlphaOfLengthBetween(10, 20); final boolean available = randomBoolean(); final RestStatus expectedStatus = available ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE; final Version version = Version.CURRENT; @@ -69,7 +69,7 @@ public Method method() { public void testGetResponse() throws Exception { final String nodeName = "node1"; final ClusterName clusterName = new ClusterName("cluster1"); - final String clusterUUID = randomAsciiOfLengthBetween(10, 20); + final String clusterUUID = randomAlphaOfLengthBetween(10, 20); final boolean available = randomBoolean(); final RestStatus expectedStatus = available ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE; final Version version = Version.CURRENT; diff --git a/core/src/test/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsActionTests.java index ba478331ca051..7ece6934a21a0 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsActionTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.test.ESTestCase; @@ -49,7 +48,7 @@ public void setUp() throws Exception { public void testUnrecognizedMetric() throws IOException { final HashMap params = new HashMap<>(); - final String metric = randomAsciiOfLength(64); + final String metric = randomAlphaOfLength(64); params.put("metric", metric); final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_nodes/stats").withParams(params).build(); final IllegalArgumentException e = expectThrows( @@ -86,7 +85,7 @@ public void testAllRequestWithOtherMetrics() throws IOException { public void testUnrecognizedIndexMetric() { final HashMap params = new HashMap<>(); params.put("metric", "indices"); - final String indexMetric = randomAsciiOfLength(64); + final String indexMetric = randomAlphaOfLength(64); params.put("index_metric", indexMetric); final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_nodes/stats").withParams(params).build(); final IllegalArgumentException e = expectThrows( diff --git a/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsActionTests.java index 0aa6e497836c4..12fcdaa2f55bb 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsActionTests.java @@ -46,7 +46,7 @@ public void setUp() throws Exception { public void testUnrecognizedMetric() throws IOException { final HashMap params = new HashMap<>(); - final String metric = randomAsciiOfLength(64); + final String metric = randomAlphaOfLength(64); params.put("metric", metric); final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_stats").withParams(params).build(); final IllegalArgumentException e = expectThrows( diff --git a/core/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java index ae66664b45669..7ee15adae3316 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java @@ -81,7 +81,7 @@ public void testBuildTable() { final int numIndices = randomIntBetween(0, 5); Index[] indices = new Index[numIndices]; for (int i = 0; i < numIndices; i++) { - indices[i] = new Index(randomAsciiOfLength(5), UUIDs.randomBase64UUID()); + indices[i] = new Index(randomAlphaOfLength(5), UUIDs.randomBase64UUID()); } final MetaData.Builder metaDataBuilder = MetaData.builder(); diff --git a/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java index 232d5ec3d32d7..6fce7219d67c2 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java @@ -69,11 +69,11 @@ public void testRestRecoveryAction() { when(state.getStage()).thenReturn(randomFrom(RecoveryState.Stage.values())); final DiscoveryNode sourceNode = randomBoolean() ? mock(DiscoveryNode.class) : null; if (sourceNode != null) { - when(sourceNode.getHostName()).thenReturn(randomAsciiOfLength(8)); + when(sourceNode.getHostName()).thenReturn(randomAlphaOfLength(8)); } when(state.getSourceNode()).thenReturn(sourceNode); final DiscoveryNode targetNode = mock(DiscoveryNode.class); - when(targetNode.getHostName()).thenReturn(randomAsciiOfLength(8)); + when(targetNode.getHostName()).thenReturn(randomAlphaOfLength(8)); when(state.getTargetNode()).thenReturn(targetNode); RecoveryState.Index index = mock(RecoveryState.Index.class); diff --git a/core/src/test/java/org/elasticsearch/script/ScriptMetaDataTests.java b/core/src/test/java/org/elasticsearch/script/ScriptMetaDataTests.java index 5a02ea1e96a4b..fb1e0885a5f9a 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptMetaDataTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptMetaDataTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.cluster.DiffableUtils; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -103,10 +102,10 @@ private ScriptMetaData randomScriptMetaData(XContentType sourceContentType) thro ScriptMetaData.Builder builder = new ScriptMetaData.Builder(null); int numScripts = scaledRandomIntBetween(0, 32); for (int i = 0; i < numScripts; i++) { - String lang = randomAsciiOfLength(4); + String lang = randomAlphaOfLength(4); XContentBuilder sourceBuilder = XContentBuilder.builder(sourceContentType.xContent()); - sourceBuilder.startObject().field("script", randomAsciiOfLength(4)).endObject(); - builder.storeScript(randomAsciiOfLength(i + 1), + sourceBuilder.startObject().field("script", randomAlphaOfLength(4)).endObject(); + builder.storeScript(randomAlphaOfLength(i + 1), StoredScriptSource.parse(lang, sourceBuilder.bytes(), sourceBuilder.contentType())); } return builder.build(); diff --git a/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java b/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java index f6a02ae920630..2289e040f57d7 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptModesTests.java @@ -56,8 +56,8 @@ public void setupScriptEngines() { //prevent duplicates using map Map contexts = new HashMap<>(); for (int i = 0; i < randomInt; i++) { - String plugin = randomAsciiOfLength(randomIntBetween(1, 10)); - String operation = randomAsciiOfLength(randomIntBetween(1, 30)); + String plugin = randomAlphaOfLength(randomIntBetween(1, 10)); + String operation = randomAlphaOfLength(randomIntBetween(1, 30)); String context = plugin + "-" + operation; contexts.put(context, new ScriptContext.Plugin(plugin, operation)); } diff --git a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java index 3482dc8bb348b..da205a9292eb0 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java @@ -95,11 +95,11 @@ public void setup() throws IOException { for (int i = 0; i < randomInt; i++) { String plugin; do { - plugin = randomAsciiOfLength(randomIntBetween(1, 10)); + plugin = randomAlphaOfLength(randomIntBetween(1, 10)); } while (ScriptContextRegistry.RESERVED_SCRIPT_CONTEXTS.contains(plugin)); String operation; do { - operation = randomAsciiOfLength(randomIntBetween(1, 30)); + operation = randomAlphaOfLength(randomIntBetween(1, 30)); } while (ScriptContextRegistry.RESERVED_SCRIPT_CONTEXTS.contains(operation)); String context = plugin + "_" + operation; contexts.put(context, new ScriptContext.Plugin(plugin, operation)); @@ -324,8 +324,8 @@ public void testCompileNonRegisteredContext() throws IOException { String pluginName; String unknownContext; do { - pluginName = randomAsciiOfLength(randomIntBetween(1, 10)); - unknownContext = randomAsciiOfLength(randomIntBetween(1, 30)); + pluginName = randomAlphaOfLength(randomIntBetween(1, 10)); + unknownContext = randomAlphaOfLength(randomIntBetween(1, 30)); } while(scriptContextRegistry.isSupportedContext(new ScriptContext.Plugin(pluginName, unknownContext))); String type = scriptEngineService.getType(); diff --git a/core/src/test/java/org/elasticsearch/script/ScriptTests.java b/core/src/test/java/org/elasticsearch/script/ScriptTests.java index 70c5af00f89c5..9584bf01a5c83 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptTests.java @@ -67,12 +67,12 @@ private Script createScript() throws IOException { if (scriptType == ScriptType.INLINE) { try (XContentBuilder builder = XContentFactory.jsonBuilder()) { builder.startObject(); - builder.field("field", randomAsciiOfLengthBetween(1, 5)); + builder.field("field", randomAlphaOfLengthBetween(1, 5)); builder.endObject(); script = builder.string(); } } else { - script = randomAsciiOfLengthBetween(1, 5); + script = randomAlphaOfLengthBetween(1, 5); } return new Script( scriptType, diff --git a/core/src/test/java/org/elasticsearch/script/StoredScriptTests.java b/core/src/test/java/org/elasticsearch/script/StoredScriptTests.java index 5f000f28cbcf1..96a9a417bbec5 100644 --- a/core/src/test/java/org/elasticsearch/script/StoredScriptTests.java +++ b/core/src/test/java/org/elasticsearch/script/StoredScriptTests.java @@ -343,8 +343,8 @@ public void testSourceParsingErrors() throws Exception { @Override protected StoredScriptSource createTestInstance() { return new StoredScriptSource( - randomAsciiOfLength(randomIntBetween(4, 32)), - randomAsciiOfLength(randomIntBetween(4, 16383)), + randomAlphaOfLength(randomIntBetween(4, 32)), + randomAlphaOfLength(randomIntBetween(4, 16383)), Collections.emptyMap()); } diff --git a/core/src/test/java/org/elasticsearch/script/StoredScriptsIT.java b/core/src/test/java/org/elasticsearch/script/StoredScriptsIT.java index f5c70edb0246f..63945cd03a681 100644 --- a/core/src/test/java/org/elasticsearch/script/StoredScriptsIT.java +++ b/core/src/test/java/org/elasticsearch/script/StoredScriptsIT.java @@ -79,7 +79,7 @@ public void testMaxScriptSize() { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> client().admin().cluster().preparePutStoredScript() .setLang(LANG) .setId("foobar") - .setContent(new BytesArray(randomAsciiOfLength(SCRIPT_MAX_SIZE_IN_BYTES + 1)), XContentType.JSON) + .setContent(new BytesArray(randomAlphaOfLength(SCRIPT_MAX_SIZE_IN_BYTES + 1)), XContentType.JSON) .get() ); assertEquals("exceeded max allowed stored script size in bytes [64] with size [65] for script [foobar]", e.getMessage()); diff --git a/core/src/test/java/org/elasticsearch/search/AbstractSearchTestCase.java b/core/src/test/java/org/elasticsearch/search/AbstractSearchTestCase.java index ba4c794a09015..5fe9d9d75fbab 100644 --- a/core/src/test/java/org/elasticsearch/search/AbstractSearchTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/AbstractSearchTestCase.java @@ -83,7 +83,7 @@ protected SearchSourceBuilder createSearchSourceBuilder() { } List searchExtBuilders = new ArrayList<>(); for (String elementName : elementNames) { - searchExtBuilders.add(searchExtPlugin.getSupportedElements().get(elementName).apply(randomAsciiOfLengthBetween(3, 10))); + searchExtBuilders.add(searchExtPlugin.getSupportedElements().get(elementName).apply(randomAlphaOfLengthBetween(3, 10))); } return searchExtBuilders; }; diff --git a/core/src/test/java/org/elasticsearch/search/NestedIdentityTests.java b/core/src/test/java/org/elasticsearch/search/NestedIdentityTests.java index b062ace0f23b4..3e5943951aec2 100644 --- a/core/src/test/java/org/elasticsearch/search/NestedIdentityTests.java +++ b/core/src/test/java/org/elasticsearch/search/NestedIdentityTests.java @@ -40,7 +40,7 @@ public class NestedIdentityTests extends ESTestCase { public static NestedIdentity createTestItem(int depth) { - String field = frequently() ? randomAsciiOfLengthBetween(1, 20) : randomRealisticUnicodeOfCodepointLengthBetween(1, 20); + String field = frequently() ? randomAlphaOfLengthBetween(1, 20) : randomRealisticUnicodeOfCodepointLengthBetween(1, 20); int offset = randomInt(10); NestedIdentity child = null; if (depth > 0) { diff --git a/core/src/test/java/org/elasticsearch/search/SearchHitTests.java b/core/src/test/java/org/elasticsearch/search/SearchHitTests.java index f03190203b281..84d40f0b9b347 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchHitTests.java +++ b/core/src/test/java/org/elasticsearch/search/SearchHitTests.java @@ -61,8 +61,8 @@ public class SearchHitTests extends ESTestCase { public static SearchHit createTestItem(boolean withOptionalInnerHits) { int internalId = randomInt(); - String uid = randomAsciiOfLength(10); - Text type = new Text(randomAsciiOfLengthBetween(5, 10)); + String uid = randomAlphaOfLength(10); + Text type = new Text(randomAlphaOfLengthBetween(5, 10)); NestedIdentity nestedIdentity = null; if (randomBoolean()) { nestedIdentity = NestedIdentityTests.createTestItem(randomIntBetween(0, 2)); @@ -77,7 +77,7 @@ public static SearchHit createTestItem(boolean withOptionalInnerHits) { String metaField = randomFrom(META_FIELDS); fields.put(metaField, new SearchHitField(metaField, values.v1())); } else { - String fieldName = randomAsciiOfLengthBetween(5, 10); + String fieldName = randomAlphaOfLengthBetween(5, 10); fields.put(fieldName, new SearchHitField(fieldName, values.v1())); } } @@ -103,7 +103,7 @@ public static SearchHit createTestItem(boolean withOptionalInnerHits) { int size = randomIntBetween(0, 5); Map highlightFields = new HashMap<>(size); for (int i = 0; i < size; i++) { - highlightFields.put(randomAsciiOfLength(5), HighlightFieldTests.createTestItem()); + highlightFields.put(randomAlphaOfLength(5), HighlightFieldTests.createTestItem()); } hit.highlightFields(highlightFields); } @@ -111,7 +111,7 @@ public static SearchHit createTestItem(boolean withOptionalInnerHits) { int size = randomIntBetween(0, 5); String[] matchedQueries = new String[size]; for (int i = 0; i < size; i++) { - matchedQueries[i] = randomAsciiOfLength(5); + matchedQueries[i] = randomAlphaOfLength(5); } hit.matchedQueries(matchedQueries); } @@ -122,13 +122,13 @@ public static SearchHit createTestItem(boolean withOptionalInnerHits) { int innerHitsSize = randomIntBetween(0, 3); Map innerHits = new HashMap<>(innerHitsSize); for (int i = 0; i < innerHitsSize; i++) { - innerHits.put(randomAsciiOfLength(5), SearchHitsTests.createTestItem()); + innerHits.put(randomAlphaOfLength(5), SearchHitsTests.createTestItem()); } hit.setInnerHits(innerHits); } if (randomBoolean()) { - hit.shard(new SearchShardTarget(randomAsciiOfLengthBetween(5, 10), - new ShardId(new Index(randomAsciiOfLengthBetween(5, 10), randomAsciiOfLengthBetween(5, 10)), randomInt()))); + hit.shard(new SearchShardTarget(randomAlphaOfLengthBetween(5, 10), + new ShardId(new Index(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(5, 10)), randomInt()))); } return hit; } @@ -234,7 +234,7 @@ public void testHasSource() { } private static Explanation createExplanation(int depth) { - String description = randomAsciiOfLengthBetween(5, 20); + String description = randomAlphaOfLengthBetween(5, 20); float value = randomFloat(); List details = new ArrayList<>(); if (depth > 0) { diff --git a/core/src/test/java/org/elasticsearch/search/SearchRequestTests.java b/core/src/test/java/org/elasticsearch/search/SearchRequestTests.java index 9e58bf26744d0..47fc61fb6a697 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchRequestTests.java +++ b/core/src/test/java/org/elasticsearch/search/SearchRequestTests.java @@ -87,12 +87,12 @@ public void testEqualsAndHashcode() throws IOException { private SearchRequest mutate(SearchRequest searchRequest) throws IOException { SearchRequest mutation = copyRequest(searchRequest); List mutators = new ArrayList<>(); - mutators.add(() -> mutation.indices(ArrayUtils.concat(searchRequest.indices(), new String[] { randomAsciiOfLength(10) }))); + mutators.add(() -> mutation.indices(ArrayUtils.concat(searchRequest.indices(), new String[] { randomAlphaOfLength(10) }))); mutators.add(() -> mutation.indicesOptions(randomValueOtherThan(searchRequest.indicesOptions(), () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean())))); - mutators.add(() -> mutation.types(ArrayUtils.concat(searchRequest.types(), new String[] { randomAsciiOfLength(10) }))); - mutators.add(() -> mutation.preference(randomValueOtherThan(searchRequest.preference(), () -> randomAsciiOfLengthBetween(3, 10)))); - mutators.add(() -> mutation.routing(randomValueOtherThan(searchRequest.routing(), () -> randomAsciiOfLengthBetween(3, 10)))); + mutators.add(() -> mutation.types(ArrayUtils.concat(searchRequest.types(), new String[] { randomAlphaOfLength(10) }))); + mutators.add(() -> mutation.preference(randomValueOtherThan(searchRequest.preference(), () -> randomAlphaOfLengthBetween(3, 10)))); + mutators.add(() -> mutation.routing(randomValueOtherThan(searchRequest.routing(), () -> randomAlphaOfLengthBetween(3, 10)))); mutators.add(() -> mutation.requestCache((randomValueOtherThan(searchRequest.requestCache(), () -> randomBoolean())))); mutators.add(() -> mutation .scroll(randomValueOtherThan(searchRequest.scroll(), () -> new Scroll(new TimeValue(randomNonNegativeLong() % 100000))))); diff --git a/core/src/test/java/org/elasticsearch/search/SearchSortValuesTests.java b/core/src/test/java/org/elasticsearch/search/SearchSortValuesTests.java index 96733a2ac6dc8..654b3c986158d 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchSortValuesTests.java +++ b/core/src/test/java/org/elasticsearch/search/SearchSortValuesTests.java @@ -52,7 +52,7 @@ public static SearchSortValues createTestItem() { valueSuppliers.add(() -> randomByte()); valueSuppliers.add(() -> randomShort()); valueSuppliers.add(() -> randomBoolean()); - valueSuppliers.add(() -> frequently() ? randomAsciiOfLengthBetween(1, 30) : randomRealisticUnicodeOfCodepointLength(30)); + valueSuppliers.add(() -> frequently() ? randomAlphaOfLengthBetween(1, 30) : randomRealisticUnicodeOfCodepointLength(30)); int size = randomIntBetween(1, 20); Object[] values = new Object[size]; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorFactoriesTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorFactoriesTests.java index 2aba0ed59eeff..180e639eb345f 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorFactoriesTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregatorFactoriesTests.java @@ -58,7 +58,7 @@ public void setUp() throws Exception { // stick around for all of the subclasses currentTypes = new String[randomIntBetween(0, 5)]; for (int i = 0; i < currentTypes.length; i++) { - String type = randomAsciiOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); currentTypes[i] = type; } xContentRegistry = new NamedXContentRegistry(new SearchModule(settings, false, emptyList()).getNamedXContents()); @@ -174,7 +174,7 @@ public void testInvalidAggregationName() throws Exception { public void testSameAggregationName() throws Exception { assumeFalse("Test only makes sense if XContent parser doesn't have strict duplicate checks enabled", XContent.isStrictDuplicateDetectionEnabled()); - final String name = randomAsciiOfLengthBetween(1, 10); + final String name = randomAlphaOfLengthBetween(1, 10); XContentBuilder source = JsonXContent.contentBuilder() .startObject() .startObject(name) diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java index 162b7bcd1b6c8..651c261aa819a 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/BaseAggregationTestCase.java @@ -85,7 +85,7 @@ public void setUp() throws Exception { //create some random type with some default field, those types will stick around for all of the subclasses currentTypes = new String[randomIntBetween(0, 5)]; for (int i = 0; i < currentTypes.length; i++) { - String type = randomAsciiOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); currentTypes[i] = type; } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java index 41bbdaae66022..0a738ec022beb 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/BasePipelineAggregationTestCase.java @@ -87,7 +87,7 @@ public void setUp() throws Exception { //create some random type with some default field, those types will stick around for all of the subclasses currentTypes = new String[randomIntBetween(0, 5)]; for (int i = 0; i < currentTypes.length; i++) { - String type = randomAsciiOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); currentTypes[i] = type; } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java index 48f48951c474a..f899fde087c3b 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/InternalAggregationTestCase.java @@ -51,7 +51,7 @@ protected T createUnmappedInstance(String name, } public void testReduceRandom() { - String name = randomAsciiOfLength(5); + String name = randomAlphaOfLength(5); List inputs = new ArrayList<>(); List toReduce = new ArrayList<>(); int toReduceSize = between(1, 200); @@ -92,7 +92,7 @@ protected ScriptService mockScriptService() { @Override protected final T createTestInstance() { - return createTestInstance(randomAsciiOfLength(5)); + return createTestInstance(randomAlphaOfLength(5)); } private T createTestInstance(String name) { @@ -101,7 +101,7 @@ private T createTestInstance(String name) { Map metaData = new HashMap<>(); int metaDataCount = randomBoolean() ? 0 : between(1, 10); while (metaData.size() < metaDataCount) { - metaData.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + metaData.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } return createTestInstance(name, pipelineAggregators, metaData); } @@ -113,7 +113,7 @@ protected final T createUnmappedInstance(String name) { Map metaData = new HashMap<>(); int metaDataCount = randomBoolean() ? 0 : between(1, 10); while (metaData.size() < metaDataCount) { - metaData.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + metaData.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } return createUnmappedInstance(name, pipelineAggregators, metaData); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenTests.java index c7844f29d05d4..4098e85c62eda 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenTests.java @@ -26,8 +26,8 @@ public class ChildrenTests extends BaseAggregationTestCase includeValues = new TreeSet<>(); int numIncs = randomIntBetween(1, 20); for (int i = 0; i < numIncs; i++) { - includeValues.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + includeValues.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } SortedSet excludeValues = null; incExc = new IncludeExclude(includeValues, excludeValues); @@ -141,7 +141,7 @@ protected SignificantTermsAggregationBuilder createTestAggregatorBuilder() { SortedSet excludeValues2 = new TreeSet<>(); int numExcs2 = randomIntBetween(1, 20); for (int i = 0; i < numExcs2; i++) { - excludeValues2.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + excludeValues2.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } incExc = new IncludeExclude(includeValues2, excludeValues2); break; @@ -149,12 +149,12 @@ protected SignificantTermsAggregationBuilder createTestAggregatorBuilder() { SortedSet includeValues3 = new TreeSet<>(); int numIncs3 = randomIntBetween(1, 20); for (int i = 0; i < numIncs3; i++) { - includeValues3.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + includeValues3.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } SortedSet excludeValues3 = new TreeSet<>(); int numExcs3 = randomIntBetween(1, 20); for (int i = 0; i < numExcs3; i++) { - excludeValues3.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + excludeValues3.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } incExc = new IncludeExclude(includeValues3, excludeValues3); break; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java index 46af395c476ea..b6ff885638f87 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsIT.java @@ -18,8 +18,6 @@ */ package org.elasticsearch.search.aggregations.bucket; -import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.StringHelper; import org.apache.lucene.util.automaton.RegExp; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -1095,10 +1093,10 @@ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels( public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevelsSpecialChars() throws Exception { StringBuilder filter2NameBuilder = new StringBuilder("filt.er2"); - filter2NameBuilder.append(randomAsciiOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); + filter2NameBuilder.append(randomAlphaOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); String filter2Name = filter2NameBuilder.toString(); StringBuilder statsNameBuilder = new StringBuilder("st.ats"); - statsNameBuilder.append(randomAsciiOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); + statsNameBuilder.append(randomAlphaOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); String statsName = statsNameBuilder.toString(); boolean asc = randomBoolean(); SearchResponse response = client() @@ -1158,10 +1156,10 @@ public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevelsS public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevelsSpecialCharsNoDotNotation() throws Exception { StringBuilder filter2NameBuilder = new StringBuilder("filt.er2"); - filter2NameBuilder.append(randomAsciiOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); + filter2NameBuilder.append(randomAlphaOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); String filter2Name = filter2NameBuilder.toString(); StringBuilder statsNameBuilder = new StringBuilder("st.ats"); - statsNameBuilder.append(randomAsciiOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); + statsNameBuilder.append(randomAlphaOfLengthBetween(3, 10).replace("[", "").replace("]", "").replace(">", "")); String statsName = statsNameBuilder.toString(); boolean asc = randomBoolean(); SearchResponse response = client() diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsTests.java index 2241c0a2f9b55..d0a38d0890ab9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsTests.java @@ -47,9 +47,9 @@ public class TermsTests extends BaseAggregationTestCase @Override protected TermsAggregationBuilder createTestAggregatorBuilder() { - String name = randomAsciiOfLengthBetween(3, 20); + String name = randomAlphaOfLengthBetween(3, 20); TermsAggregationBuilder factory = new TermsAggregationBuilder(name, null); - String field = randomAsciiOfLengthBetween(3, 20); + String field = randomAlphaOfLengthBetween(3, 20); int randomFieldBranch = randomInt(2); switch (randomFieldBranch) { case 0: @@ -131,7 +131,7 @@ protected TermsAggregationBuilder createTestAggregatorBuilder() { SortedSet includeValues = new TreeSet<>(); int numIncs = randomIntBetween(1, 20); for (int i = 0; i < numIncs; i++) { - includeValues.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + includeValues.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } SortedSet excludeValues = null; incExc = new IncludeExclude(includeValues, excludeValues); @@ -141,7 +141,7 @@ protected TermsAggregationBuilder createTestAggregatorBuilder() { SortedSet excludeValues2 = new TreeSet<>(); int numExcs2 = randomIntBetween(1, 20); for (int i = 0; i < numExcs2; i++) { - excludeValues2.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + excludeValues2.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } incExc = new IncludeExclude(includeValues2, excludeValues2); break; @@ -149,12 +149,12 @@ protected TermsAggregationBuilder createTestAggregatorBuilder() { SortedSet includeValues3 = new TreeSet<>(); int numIncs3 = randomIntBetween(1, 20); for (int i = 0; i < numIncs3; i++) { - includeValues3.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + includeValues3.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } SortedSet excludeValues3 = new TreeSet<>(); int numExcs3 = randomIntBetween(1, 20); for (int i = 0; i < numExcs3; i++) { - excludeValues3.add(new BytesRef(randomAsciiOfLengthBetween(1, 30))); + excludeValues3.add(new BytesRef(randomAlphaOfLengthBetween(1, 30))); } incExc = new IncludeExclude(includeValues3, excludeValues3); break; @@ -188,10 +188,10 @@ private List randomOrder() { orders.add(Terms.Order.count(randomBoolean())); break; case 2: - orders.add(Terms.Order.aggregation(randomAsciiOfLengthBetween(3, 20), randomBoolean())); + orders.add(Terms.Order.aggregation(randomAlphaOfLengthBetween(3, 20), randomBoolean())); break; case 3: - orders.add(Terms.Order.aggregation(randomAsciiOfLengthBetween(3, 20), randomAsciiOfLengthBetween(3, 20), randomBoolean())); + orders.add(Terms.Order.aggregation(randomAlphaOfLengthBetween(3, 20), randomAlphaOfLengthBetween(3, 20), randomBoolean())); break; case 4: int numOrders = randomIntBetween(1, 3); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedTests.java index 29dde100a0891..ff2563fc4cc83 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedTests.java @@ -25,7 +25,7 @@ public class NestedTests extends BaseAggregationTestCase[] ranges = new Tuple[numRanges]; for (int i = 0; i < numRanges; i++) { BytesRef[] values = new BytesRef[2]; - values[0] = new BytesRef(randomAsciiOfLength(15)); - values[1] = new BytesRef(randomAsciiOfLength(15)); + values[0] = new BytesRef(randomAlphaOfLength(15)); + values[1] = new BytesRef(randomAlphaOfLength(15)); Arrays.sort(values); ranges[i] = new Tuple(values[0], values[1]); } @@ -60,7 +60,7 @@ protected InternalBinaryRange createTestInstance(String name, List buckets = new ArrayList<>(); for (int i = 0; i < RANGES.length; ++i) { final int docCount = randomIntBetween(1, 100); - buckets.add(new InternalBinaryRange.Bucket(format, keyed, randomAsciiOfLength(10), + buckets.add(new InternalBinaryRange.Bucket(format, keyed, randomAlphaOfLength(10), RANGES[i].v1(), RANGES[i].v2(), docCount, InternalAggregations.EMPTY)); } return new InternalBinaryRange(name, format, keyed, buckets, pipelineAggregators, Collections.emptyMap()); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java index f957836b3e4c0..82cd21cdf3873 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java @@ -62,7 +62,7 @@ protected InternalSignificantTerms createTestInstance(String name, List buckets = new ArrayList<>(numBuckets); Set terms = new HashSet<>(); for (int i = 0; i < numBuckets; ++i) { - BytesRef term = randomValueOtherThanMany(b -> terms.add(b) == false, () -> new BytesRef(randomAsciiOfLength(10))); + BytesRef term = randomValueOtherThanMany(b -> terms.add(b) == false, () -> new BytesRef(randomAlphaOfLength(10))); int subsetDf = randomIntBetween(1, 10); int supersetDf = randomIntBetween(subsetDf, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsTests.java index d20f546a5415d..64e814bd8192a 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsTests.java @@ -50,7 +50,7 @@ public class StringTermsTests extends InternalTermsTestCase { final int numBuckets = randomInt(shardSize); Set terms = new HashSet<>(); for (int i = 0; i < numBuckets; ++i) { - BytesRef term = randomValueOtherThanMany(b -> terms.add(b) == false, () -> new BytesRef(randomAsciiOfLength(10))); + BytesRef term = randomValueOtherThanMany(b -> terms.add(b) == false, () -> new BytesRef(randomAlphaOfLength(10))); int docCount = randomIntBetween(1, 100); buckets.add(new StringTerms.Bucket(term, docCount, InternalAggregations.EMPTY, showTermDocCountError, docCountError, format)); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AdjacencyMatrixTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AdjacencyMatrixTests.java index 05390b1282d94..a12dbad59fbfb 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AdjacencyMatrixTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AdjacencyMatrixTests.java @@ -36,10 +36,10 @@ protected AdjacencyMatrixAggregationBuilder createTestAggregatorBuilder() { int size = randomIntBetween(1, 20); AdjacencyMatrixAggregationBuilder factory; Map filters = new HashMap<>(size); - for (String key : randomUnique(() -> randomAsciiOfLengthBetween(1, 20), size)) { - filters.put(key, QueryBuilders.termQuery(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20))); + for (String key : randomUnique(() -> randomAlphaOfLengthBetween(1, 20), size)) { + filters.put(key, QueryBuilders.termQuery(randomAlphaOfLengthBetween(5, 20), randomAlphaOfLengthBetween(5, 20))); } - factory = new AdjacencyMatrixAggregationBuilder(randomAsciiOfLengthBetween(1, 20), filters) + factory = new AdjacencyMatrixAggregationBuilder(randomAlphaOfLengthBetween(1, 20), filters) .separator(randomFrom("&","+","\t")); return factory; } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/FilterTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/FilterTests.java index 1b563d531a84d..47b9ab07b104f 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/FilterTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/FilterTests.java @@ -27,8 +27,8 @@ public class FilterTests extends BaseAggregationTestCase randomAsciiOfLengthBetween(1, 20), size)) { + for (String key : randomUnique(() -> randomAlphaOfLengthBetween(1, 20), size)) { filters[i++] = new KeyedFilter(key, - QueryBuilders.termQuery(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20))); + QueryBuilders.termQuery(randomAlphaOfLengthBetween(5, 20), randomAlphaOfLengthBetween(5, 20))); } - factory = new FiltersAggregationBuilder(randomAsciiOfLengthBetween(1, 20), filters); + factory = new FiltersAggregationBuilder(randomAlphaOfLengthBetween(1, 20), filters); } else { QueryBuilder[] filters = new QueryBuilder[size]; for (int i = 0; i < size; i++) { - filters[i] = QueryBuilders.termQuery(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20)); + filters[i] = QueryBuilders.termQuery(randomAlphaOfLengthBetween(5, 20), randomAlphaOfLengthBetween(5, 20)); } - factory = new FiltersAggregationBuilder(randomAsciiOfLengthBetween(1, 20), filters); + factory = new FiltersAggregationBuilder(randomAlphaOfLengthBetween(1, 20), filters); } if (randomBoolean()) { factory.otherBucket(randomBoolean()); } if (randomBoolean()) { - factory.otherBucketKey(randomAsciiOfLengthBetween(1, 20)); + factory.otherBucketKey(randomAlphaOfLengthBetween(1, 20)); } return factory; } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsTests.java index e086598dbfe16..9f5bd13b5f664 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsTests.java @@ -26,8 +26,8 @@ public class GeoBoundsTests extends BaseAggregationTestCase fields = new ArrayList<>(fieldsSize); for (int i = 0; i < fieldsSize; i++) { - fields.add(randomAsciiOfLengthBetween(5, 50)); + fields.add(randomAlphaOfLengthBetween(5, 50)); } factory.storedFields(fields); break; @@ -83,16 +83,16 @@ protected final TopHitsAggregationBuilder createTestAggregatorBuilder() { if (randomBoolean()) { int fieldDataFieldsSize = randomInt(25); for (int i = 0; i < fieldDataFieldsSize; i++) { - factory.fieldDataField(randomAsciiOfLengthBetween(5, 50)); + factory.fieldDataField(randomAlphaOfLengthBetween(5, 50)); } } if (randomBoolean()) { int scriptFieldsSize = randomInt(25); for (int i = 0; i < scriptFieldsSize; i++) { if (randomBoolean()) { - factory.scriptField(randomAsciiOfLengthBetween(5, 50), new Script("foo"), randomBoolean()); + factory.scriptField(randomAlphaOfLengthBetween(5, 50), new Script("foo"), randomBoolean()); } else { - factory.scriptField(randomAsciiOfLengthBetween(5, 50), new Script("foo")); + factory.scriptField(randomAlphaOfLengthBetween(5, 50), new Script("foo")); } } } @@ -101,11 +101,11 @@ protected final TopHitsAggregationBuilder createTestAggregatorBuilder() { int branch = randomInt(5); String[] includes = new String[randomIntBetween(0, 20)]; for (int i = 0; i < includes.length; i++) { - includes[i] = randomAsciiOfLengthBetween(5, 20); + includes[i] = randomAlphaOfLengthBetween(5, 20); } String[] excludes = new String[randomIntBetween(0, 20)]; for (int i = 0; i < excludes.length; i++) { - excludes[i] = randomAsciiOfLengthBetween(5, 20); + excludes[i] = randomAlphaOfLengthBetween(5, 20); } switch (branch) { case 0: @@ -115,8 +115,8 @@ protected final TopHitsAggregationBuilder createTestAggregatorBuilder() { fetchSourceContext = new FetchSourceContext(true, includes, excludes); break; case 2: - fetchSourceContext = new FetchSourceContext(true, new String[]{randomAsciiOfLengthBetween(5, 20)}, - new String[]{randomAsciiOfLengthBetween(5, 20)}); + fetchSourceContext = new FetchSourceContext(true, new String[]{randomAlphaOfLengthBetween(5, 20)}, + new String[]{randomAlphaOfLengthBetween(5, 20)}); break; case 3: fetchSourceContext = new FetchSourceContext(true, includes, excludes); @@ -125,7 +125,7 @@ protected final TopHitsAggregationBuilder createTestAggregatorBuilder() { fetchSourceContext = new FetchSourceContext(true, includes, null); break; case 5: - fetchSourceContext = new FetchSourceContext(true, new String[] {randomAsciiOfLengthBetween(5, 20)}, null); + fetchSourceContext = new FetchSourceContext(true, new String[] {randomAlphaOfLengthBetween(5, 20)}, null); break; default: throw new IllegalStateException(); @@ -138,10 +138,10 @@ protected final TopHitsAggregationBuilder createTestAggregatorBuilder() { int branch = randomInt(5); switch (branch) { case 0: - factory.sort(SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); + factory.sort(SortBuilders.fieldSort(randomAlphaOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); break; case 1: - factory.sort(SortBuilders.geoDistanceSort(randomAsciiOfLengthBetween(5, 20), AbstractQueryTestCase.randomGeohash(1, 12)) + factory.sort(SortBuilders.geoDistanceSort(randomAlphaOfLengthBetween(5, 20), AbstractQueryTestCase.randomGeohash(1, 12)) .order(randomFrom(SortOrder.values()))); break; case 2: @@ -151,10 +151,10 @@ protected final TopHitsAggregationBuilder createTestAggregatorBuilder() { factory.sort(SortBuilders.scriptSort(new Script("foo"), ScriptSortType.NUMBER).order(randomFrom(SortOrder.values()))); break; case 4: - factory.sort(randomAsciiOfLengthBetween(5, 20)); + factory.sort(randomAlphaOfLengthBetween(5, 20)); break; case 5: - factory.sort(randomAsciiOfLengthBetween(5, 20), randomFrom(SortOrder.values())); + factory.sort(randomAlphaOfLengthBetween(5, 20), randomFrom(SortOrder.values())); break; } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java index b82e822f6b04c..be06bdd56b46d 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java @@ -50,13 +50,13 @@ protected InternalScriptedMetric createTestInstance(String name, List metaData) { Map params = new HashMap<>(); if (randomBoolean()) { - params.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + params.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } Script reduceScript = null; if (hasReduceScript) { reduceScript = new Script(ScriptType.INLINE, MockScriptEngine.NAME, REDUCE_SCRIPT_NAME, params); } - return new InternalScriptedMetric(name, randomAsciiOfLength(5), reduceScript, pipelineAggregators, metaData); + return new InternalScriptedMetric(name, randomAlphaOfLength(5), reduceScript, pipelineAggregators, metaData); } /** diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHitsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHitsTests.java index ba729d3c97887..8265933bfb622 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHitsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHitsTests.java @@ -122,9 +122,9 @@ private Object randomOfType(SortField.Type type) { case SCORE: return randomFloat(); case STRING: - return new BytesRef(randomAsciiOfLength(5)); + return new BytesRef(randomAlphaOfLength(5)); case STRING_VAL: - return new BytesRef(randomAsciiOfLength(5)); + return new BytesRef(randomAlphaOfLength(5)); default: throw new UnsupportedOperationException("Unkown SortField.Type: " + type); } @@ -168,7 +168,7 @@ private SortField[] randomSortFields() { SortField[] sortFields = new SortField[between(1, 5)]; Set usedSortFields = new HashSet<>(); for (int i = 0; i < sortFields.length; i++) { - String sortField = randomValueOtherThanMany(usedSortFields::contains, () -> randomAsciiOfLength(5)); + String sortField = randomValueOtherThanMany(usedSortFields::contains, () -> randomAlphaOfLength(5)); usedSortFields.add(sortField); SortField.Type type = randomValueOtherThanMany(t -> t == SortField.Type.CUSTOM || t == SortField.Type.REWRITEABLE, () -> randomFrom(SortField.Type.values())); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java index d1f3a31677d7e..b6d133f17116b 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptTests.java @@ -32,11 +32,11 @@ public class BucketScriptTests extends BasePipelineAggregationTestCase bucketsPaths = new HashMap<>(); int numBucketPaths = randomIntBetween(1, 10); for (int i = 0; i < numBucketPaths; i++) { - bucketsPaths.put(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 40)); + bucketsPaths.put(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 40)); } Script script; if (randomBoolean()) { @@ -52,7 +52,7 @@ protected BucketScriptPipelineAggregationBuilder createTestAggregatorFactory() { } BucketScriptPipelineAggregationBuilder factory = new BucketScriptPipelineAggregationBuilder(name, bucketsPaths, script); if (randomBoolean()) { - factory.format(randomAsciiOfLengthBetween(1, 10)); + factory.format(randomAlphaOfLengthBetween(1, 10)); } if (randomBoolean()) { factory.gapPolicy(randomFrom(GapPolicy.values())); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java index 0311781455a9f..c3e477a3a5051 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/BucketSelectorTests.java @@ -32,11 +32,11 @@ public class BucketSelectorTests extends BasePipelineAggregationTestCase bucketsPaths = new HashMap<>(); int numBucketPaths = randomIntBetween(1, 10); for (int i = 0; i < numBucketPaths; i++) { - bucketsPaths.put(randomAsciiOfLengthBetween(1, 20), randomAsciiOfLengthBetween(1, 40)); + bucketsPaths.put(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 40)); } Script script; if (randomBoolean()) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumTests.java index 07cd9010ed0e8..3b1514a8c38fd 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumTests.java @@ -26,11 +26,11 @@ public class CumulativeSumTests extends BasePipelineAggregationTestCase options = new HashMap<>(items); for (int i = 0; i < items; i++) { - options.put(randomAsciiOfLengthBetween(1, 10), randomAsciiOfLengthBetween(1, 10)); + options.put(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10)); } highlightBuilder.options(options); break; @@ -685,7 +685,7 @@ private static String[] randomStringArray(int minSize, int maxSize) { int size = randomIntBetween(minSize, maxSize); Set randomStrings = new HashSet<>(size); for (int f = 0; f < size; f++) { - randomStrings.add(randomAsciiOfLengthBetween(3, 10)); + randomStrings.add(randomAlphaOfLengthBetween(3, 10)); } return randomStrings.toArray(new String[randomStrings.size()]); } @@ -703,11 +703,11 @@ private static HighlightBuilder mutate(HighlightBuilder original) throws IOExcep case 0: mutation.useExplicitFieldOrder(!original.useExplicitFieldOrder()); break; case 1: - mutation.encoder(original.encoder() + randomAsciiOfLength(2)); break; + mutation.encoder(original.encoder() + randomAlphaOfLength(2)); break; case 2: if (randomBoolean()) { // add another field - mutation.field(new Field(randomAsciiOfLength(10))); + mutation.field(new Field(randomAlphaOfLength(10))); } else { // change existing fields List originalFields = original.fields(); diff --git a/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightFieldTests.java b/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightFieldTests.java index 027ae53a23d60..b4bf2950b7d07 100644 --- a/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightFieldTests.java +++ b/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightFieldTests.java @@ -38,14 +38,14 @@ public class HighlightFieldTests extends ESTestCase { public static HighlightField createTestItem() { - String name = frequently() ? randomAsciiOfLengthBetween(5, 20) : randomRealisticUnicodeOfCodepointLengthBetween(5, 20); + String name = frequently() ? randomAlphaOfLengthBetween(5, 20) : randomRealisticUnicodeOfCodepointLengthBetween(5, 20); Text[] fragments = null; if (frequently()) { int size = randomIntBetween(0, 5); fragments = new Text[size]; for (int i = 0; i < size; i++) { fragments[i] = new Text( - frequently() ? randomAsciiOfLengthBetween(10, 30) : randomRealisticUnicodeOfCodepointLengthBetween(10, 30)); + frequently() ? randomAlphaOfLengthBetween(10, 30) : randomRealisticUnicodeOfCodepointLengthBetween(10, 30)); } } return new HighlightField(name, fragments); diff --git a/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index 11496309d47a9..c0c52928d20e2 100644 --- a/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -2761,7 +2761,7 @@ public void testPostingsHighlighterManyDocs() throws Exception { for (int i = 0; i < COUNT; i++) { //generating text with word to highlight in a different position //(https://github.com/elastic/elasticsearch/issues/4103) - String prefix = randomAsciiOfLengthBetween(5, 30); + String prefix = randomAlphaOfLengthBetween(5, 30); prefixes.put(String.valueOf(i), prefix); indexRequestBuilders[i] = client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field1", "Sentence " + prefix + " test. Sentence two."); diff --git a/core/src/test/java/org/elasticsearch/search/internal/ShardSearchTransportRequestTests.java b/core/src/test/java/org/elasticsearch/search/internal/ShardSearchTransportRequestTests.java index d0132cca7ad50..b93b3795cb55d 100644 --- a/core/src/test/java/org/elasticsearch/search/internal/ShardSearchTransportRequestTests.java +++ b/core/src/test/java/org/elasticsearch/search/internal/ShardSearchTransportRequestTests.java @@ -87,7 +87,7 @@ public void testSerialization() throws Exception { private ShardSearchTransportRequest createShardSearchTransportRequest() throws IOException { SearchRequest searchRequest = createSearchRequest(); - ShardId shardId = new ShardId(randomAsciiOfLengthBetween(2, 10), randomAsciiOfLengthBetween(2, 10), randomInt()); + ShardId shardId = new ShardId(randomAlphaOfLengthBetween(2, 10), randomAlphaOfLengthBetween(2, 10), randomInt()); final AliasFilter filteringAliases; if (randomBoolean()) { String[] strings = generateRandomStringArray(10, 10, false, false); diff --git a/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java b/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java index fddbd6eaaef56..70375c6d20837 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/ProfileResultTests.java @@ -41,8 +41,8 @@ public class ProfileResultTests extends ESTestCase { public static ProfileResult createTestItem(int depth) { - String type = randomAsciiOfLengthBetween(5, 10); - String description = randomAsciiOfLengthBetween(5, 10); + String type = randomAlphaOfLengthBetween(5, 10); + String description = randomAlphaOfLengthBetween(5, 10); int timingsSize = randomIntBetween(0, 5); Map timings = new HashMap<>(timingsSize); for (int i = 0; i < timingsSize; i++) { @@ -51,7 +51,7 @@ public static ProfileResult createTestItem(int depth) { // also often use "small" values in tests time = randomNonNegativeLong() % 10000; } - timings.put(randomAsciiOfLengthBetween(5, 10), time); // don't overflow Long.MAX_VALUE; + timings.put(randomAlphaOfLengthBetween(5, 10), time); // don't overflow Long.MAX_VALUE; } int childrenSize = depth > 0 ? randomIntBetween(0, 1) : 0; List children = new ArrayList<>(childrenSize); diff --git a/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java b/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java index 2d9cf847861ac..82ed118f559db 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/SearchProfileShardResultsTests.java @@ -51,7 +51,7 @@ public static SearchProfileShardResults createTestItem() { queryProfileResults.add(QueryProfileShardResultTests.createTestItem()); } AggregationProfileShardResult aggProfileShardResult = AggregationProfileShardResultTests.createTestItem(1); - searchProfileResults.put(randomAsciiOfLengthBetween(5, 10), new ProfileShardResult(queryProfileResults, aggProfileShardResult)); + searchProfileResults.put(randomAlphaOfLengthBetween(5, 10), new ProfileShardResult(queryProfileResults, aggProfileShardResult)); } return new SearchProfileShardResults(searchProfileResults); } diff --git a/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java b/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java index 342da16f5087e..b09c177bf0b98 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java +++ b/core/src/test/java/org/elasticsearch/search/profile/aggregation/AggregationProfilerIT.java @@ -28,8 +28,6 @@ import org.elasticsearch.search.aggregations.metrics.max.MaxAggregator; import org.elasticsearch.search.profile.ProfileResult; import org.elasticsearch.search.profile.ProfileShardResult; -import org.elasticsearch.search.profile.aggregation.AggregationProfileShardResult; -import org.elasticsearch.search.profile.aggregation.AggregationTimingType; import org.elasticsearch.test.ESIntegTestCase; import java.util.ArrayList; import java.util.List; @@ -68,7 +66,7 @@ protected void setupSuiteScopeCluster() throws Exception { String[] randomStrings = new String[randomIntBetween(2, 10)]; for (int i = 0; i < randomStrings.length; i++) { - randomStrings[i] = randomAsciiOfLength(10); + randomStrings[i] = randomAlphaOfLength(10); } for (int i = 0; i < 5; i++) { diff --git a/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java b/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java index 43e1e32db36a6..698e4a387aa63 100644 --- a/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java +++ b/core/src/test/java/org/elasticsearch/search/profile/query/CollectorResultTests.java @@ -39,8 +39,8 @@ public class CollectorResultTests extends ESTestCase { public static CollectorResult createTestItem(int depth) { - String name = randomAsciiOfLengthBetween(5, 10); - String reason = randomAsciiOfLengthBetween(5, 10); + String name = randomAlphaOfLengthBetween(5, 10); + String reason = randomAlphaOfLengthBetween(5, 10); long time = randomNonNegativeLong(); if (randomBoolean()) { // also often use relatively "small" values, otherwise we will mostly test huge longs diff --git a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java index 2002e7ce5089b..7ae22485df3d4 100644 --- a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java @@ -720,7 +720,7 @@ private static List fill(List list, String value, int times) { private static List fillRandom(List list, int times) { for (int i = 0; i < times; i++) { - list.add(randomAsciiOfLength(5)); + list.add(randomAlphaOfLength(5)); } return list; } diff --git a/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java b/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java index 53277bd5b3c0b..ee68ea60036d8 100644 --- a/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java @@ -135,7 +135,7 @@ public void testBuildRescoreSearchContext() throws ElasticsearchParseException, final long nowInMillis = randomNonNegativeLong(); Settings indexSettings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAsciiOfLengthBetween(1, 10), indexSettings); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); // shard context will only need indicesQueriesRegistry for building Query objects nested in query rescorer QueryShardContext mockShardContext = new QueryShardContext(0, idxSettings, null, null, null, null, null, xContentRegistry(), null, null, () -> nowInMillis) { @@ -303,7 +303,7 @@ private static RescoreBuilder mutate(RescoreBuilder original) throws IOExc */ public static QueryRescorerBuilder randomRescoreBuilder() { QueryBuilder queryBuilder = new MatchAllQueryBuilder().boost(randomFloat()) - .queryName(randomAsciiOfLength(20)); + .queryName(randomAlphaOfLength(20)); org.elasticsearch.search.rescore.QueryRescorerBuilder rescorer = new org.elasticsearch.search.rescore.QueryRescorerBuilder(queryBuilder); if (randomBoolean()) { diff --git a/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterBuilderTests.java b/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterBuilderTests.java index cb45208a39fa4..2179444aad763 100644 --- a/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterBuilderTests.java @@ -58,7 +58,7 @@ private static SearchAfterBuilder randomSearchAfterBuilder() throws IOException values[i] = randomDouble(); break; case 4: - values[i] = randomAsciiOfLengthBetween(5, 20); + values[i] = randomAlphaOfLengthBetween(5, 20); break; case 5: values[i] = randomBoolean(); @@ -70,7 +70,7 @@ private static SearchAfterBuilder randomSearchAfterBuilder() throws IOException values[i] = randomShort(); break; case 8: - values[i] = new Text(randomAsciiOfLengthBetween(5, 20)); + values[i] = new Text(randomAlphaOfLengthBetween(5, 20)); break; case 9: values[i] = null; @@ -106,7 +106,7 @@ private SearchAfterBuilder randomJsonSearchFromBuilder() throws IOException { jsonBuilder.value(randomDouble()); break; case 4: - jsonBuilder.value(randomAsciiOfLengthBetween(5, 20)); + jsonBuilder.value(randomAlphaOfLengthBetween(5, 20)); break; case 5: jsonBuilder.value(randomBoolean()); @@ -118,7 +118,7 @@ private SearchAfterBuilder randomJsonSearchFromBuilder() throws IOException { jsonBuilder.value(randomShort()); break; case 8: - jsonBuilder.value(new Text(randomAsciiOfLengthBetween(5, 20))); + jsonBuilder.value(new Text(randomAlphaOfLengthBetween(5, 20))); break; case 9: jsonBuilder.nullValue(); diff --git a/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java b/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java index 05a5c4acbe6a7..76faac7341530 100644 --- a/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java +++ b/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java @@ -31,7 +31,6 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.transport.RemoteTransportException; import org.hamcrest.Matchers; import java.util.List; @@ -201,7 +200,7 @@ public void testWithSimpleTypes() throws Exception { values.add(randomDouble()); break; case 6: - values.add(randomAsciiOfLengthBetween(5, 20)); + values.add(randomAlphaOfLengthBetween(5, 20)); break; } } diff --git a/core/src/test/java/org/elasticsearch/search/slice/SearchSliceIT.java b/core/src/test/java/org/elasticsearch/search/slice/SearchSliceIT.java index aad6aa0982c9c..aa166f6e1a231 100644 --- a/core/src/test/java/org/elasticsearch/search/slice/SearchSliceIT.java +++ b/core/src/test/java/org/elasticsearch/search/slice/SearchSliceIT.java @@ -83,7 +83,7 @@ private int setupIndex(boolean withDocs) throws IOException, ExecutionException, for (int i = 0; i < NUM_DOCS; i++) { XContentBuilder builder = jsonBuilder(); builder.startObject(); - builder.field("invalid_random_kw", randomAsciiOfLengthBetween(5, 20)); + builder.field("invalid_random_kw", randomAlphaOfLengthBetween(5, 20)); builder.field("random_int", randomInt()); builder.field("static_int", 0); builder.field("invalid_random_int", randomInt()); diff --git a/core/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java b/core/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java index 9de5ee2a58346..f7ba4286c2b3a 100644 --- a/core/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java @@ -64,7 +64,7 @@ public class SliceBuilderTests extends ESTestCase { private static SliceBuilder randomSliceBuilder() throws IOException { int max = randomIntBetween(2, MAX_SLICE); int id = randomIntBetween(1, max - 1); - String field = randomAsciiOfLengthBetween(5, 20); + String field = randomAlphaOfLengthBetween(5, 20); return new SliceBuilder(field, id, max); } diff --git a/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java b/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java index 17c60152aaefc..6f1087561c42f 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/sort/AbstractSortTestCase.java @@ -70,7 +70,6 @@ import java.io.IOException; import java.nio.file.Path; import java.util.Collections; -import java.util.Map; import static java.util.Collections.emptyList; import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode; @@ -191,7 +190,7 @@ public void testEqualsAndHashcode() throws IOException { } protected QueryShardContext createMockShardContext() { - Index index = new Index(randomAsciiOfLengthBetween(1, 10), "_na_"); + Index index = new Index(randomAlphaOfLengthBetween(1, 10), "_na_"); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); IndicesFieldDataCache cache = new IndicesFieldDataCache(Settings.EMPTY, null); @@ -245,7 +244,7 @@ protected static QueryBuilder randomNestedFilter() { case 0: return (new MatchAllQueryBuilder()).boost(randomFloat()); case 1: return (new IdsQueryBuilder()).boost(randomFloat()); case 2: return (new TermQueryBuilder( - randomAsciiOfLengthBetween(1, 10), + randomAlphaOfLengthBetween(1, 10), randomDouble()).boost(randomFloat())); default: throw new IllegalStateException("Only three query builders supported for testing sort"); } diff --git a/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java index 55e6b0eabf455..57e79ce98c379 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java @@ -44,7 +44,7 @@ protected FieldSortBuilder createTestItem() { public FieldSortBuilder randomFieldSortBuilder() { - String fieldName = rarely() ? FieldSortBuilder.DOC_FIELD_NAME : randomAsciiOfLengthBetween(1, 10); + String fieldName = rarely() ? FieldSortBuilder.DOC_FIELD_NAME : randomAlphaOfLengthBetween(1, 10); FieldSortBuilder builder = new FieldSortBuilder(fieldName); if (randomBoolean()) { builder.order(randomFrom(SortOrder.values())); @@ -55,7 +55,7 @@ public FieldSortBuilder randomFieldSortBuilder() { } if (randomBoolean()) { - builder.unmappedType(randomAsciiOfLengthBetween(1, 10)); + builder.unmappedType(randomAlphaOfLengthBetween(1, 10)); } if (randomBoolean()) { @@ -67,7 +67,7 @@ public FieldSortBuilder randomFieldSortBuilder() { } if (randomBoolean()) { - builder.setNestedPath(randomAsciiOfLengthBetween(1, 10)); + builder.setNestedPath(randomAlphaOfLengthBetween(1, 10)); } return builder; @@ -81,7 +81,7 @@ protected FieldSortBuilder mutate(FieldSortBuilder original) throws IOException case 0: mutated.setNestedPath(randomValueOtherThan( original.getNestedPath(), - () -> randomAsciiOfLengthBetween(1, 10))); + () -> randomAlphaOfLengthBetween(1, 10))); break; case 1: mutated.setNestedFilter(randomValueOtherThan( @@ -94,7 +94,7 @@ protected FieldSortBuilder mutate(FieldSortBuilder original) throws IOException case 3: mutated.unmappedType(randomValueOtherThan( original.unmappedType(), - () -> randomAsciiOfLengthBetween(1, 10))); + () -> randomAlphaOfLengthBetween(1, 10))); break; case 4: mutated.missing(randomValueOtherThan(original.missing(), () -> randomFrom(missingContent))); diff --git a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java index cc0263c31f502..99ab42c6e42e4 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java @@ -50,7 +50,7 @@ protected GeoDistanceSortBuilder createTestItem() { } public static GeoDistanceSortBuilder randomGeoDistanceSortBuilder() { - String fieldName = randomAsciiOfLengthBetween(1, 10); + String fieldName = randomAlphaOfLengthBetween(1, 10); GeoDistanceSortBuilder result = null; int id = randomIntBetween(0, 2); @@ -94,7 +94,7 @@ public static GeoDistanceSortBuilder randomGeoDistanceSortBuilder() { result.setNestedPath( randomValueOtherThan( result.getNestedPath(), - () -> randomAsciiOfLengthBetween(1, 10))); + () -> randomAlphaOfLengthBetween(1, 10))); } if (randomBoolean()) { result.validation(randomValueOtherThan(result.validation(), () -> randomFrom(GeoValidationMethod.values()))); @@ -166,7 +166,7 @@ protected GeoDistanceSortBuilder mutate(GeoDistanceSortBuilder original) throws case 7: result.setNestedPath(randomValueOtherThan( result.getNestedPath(), - () -> randomAsciiOfLengthBetween(1, 10))); + () -> randomAlphaOfLengthBetween(1, 10))); break; case 8: result.validation(randomValueOtherThan(result.validation(), () -> randomFrom(GeoValidationMethod.values()))); diff --git a/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java index 1ad5de4071fd0..526be491f3dd2 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/ScriptSortBuilderTests.java @@ -43,7 +43,7 @@ protected ScriptSortBuilder createTestItem() { public static ScriptSortBuilder randomScriptSortBuilder() { ScriptSortType type = randomBoolean() ? ScriptSortType.NUMBER : ScriptSortType.STRING; - ScriptSortBuilder builder = new ScriptSortBuilder(new Script(randomAsciiOfLengthBetween(5, 10)), + ScriptSortBuilder builder = new ScriptSortBuilder(new Script(randomAlphaOfLengthBetween(5, 10)), type); if (randomBoolean()) { builder.order(randomFrom(SortOrder.values())); @@ -63,7 +63,7 @@ public static ScriptSortBuilder randomScriptSortBuilder() { builder.setNestedFilter(randomNestedFilter()); } if (randomBoolean()) { - builder.setNestedPath(randomAsciiOfLengthBetween(1, 10)); + builder.setNestedPath(randomAlphaOfLengthBetween(1, 10)); } return builder; } diff --git a/core/src/test/java/org/elasticsearch/search/sort/SortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/SortBuilderTests.java index cc62e546a3dd2..b1a6af88de133 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/SortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/SortBuilderTests.java @@ -189,7 +189,7 @@ public static List> randomSortBuilderList() { list.add(new ScoreSortBuilder()); break; case 1: - String fieldName = rarely() ? FieldSortBuilder.DOC_FIELD_NAME : randomAsciiOfLengthBetween(1, 10); + String fieldName = rarely() ? FieldSortBuilder.DOC_FIELD_NAME : randomAlphaOfLengthBetween(1, 10); list.add(new FieldSortBuilder(fieldName)); break; case 2: diff --git a/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java b/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java index 530a505a69589..7fd674486ed71 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java @@ -82,10 +82,10 @@ protected SB randomTestBuilder() { } public static void setCommonPropertiesOnRandomBuilder(SuggestionBuilder randomSuggestion) { - randomSuggestion.text(randomAsciiOfLengthBetween(2, 20)); // have to set the text because we don't know if the global text was set - maybeSet(randomSuggestion::prefix, randomAsciiOfLengthBetween(2, 20)); - maybeSet(randomSuggestion::regex, randomAsciiOfLengthBetween(2, 20)); - maybeSet(randomSuggestion::analyzer, randomAsciiOfLengthBetween(2, 20)); + randomSuggestion.text(randomAlphaOfLengthBetween(2, 20)); // have to set the text because we don't know if the global text was set + maybeSet(randomSuggestion::prefix, randomAlphaOfLengthBetween(2, 20)); + maybeSet(randomSuggestion::regex, randomAlphaOfLengthBetween(2, 20)); + maybeSet(randomSuggestion::analyzer, randomAlphaOfLengthBetween(2, 20)); maybeSet(randomSuggestion::size, randomIntBetween(1, 20)); maybeSet(randomSuggestion::shardSize, randomIntBetween(1, 20)); } @@ -146,16 +146,16 @@ private SB mutate(SB firstBuilder) throws IOException { if (randomBoolean()) { switch (randomIntBetween(0, 5)) { case 0: - mutation.text(randomValueOtherThan(mutation.text(), () -> randomAsciiOfLengthBetween(2, 20))); + mutation.text(randomValueOtherThan(mutation.text(), () -> randomAlphaOfLengthBetween(2, 20))); break; case 1: - mutation.prefix(randomValueOtherThan(mutation.prefix(), () -> randomAsciiOfLengthBetween(2, 20))); + mutation.prefix(randomValueOtherThan(mutation.prefix(), () -> randomAlphaOfLengthBetween(2, 20))); break; case 2: - mutation.regex(randomValueOtherThan(mutation.regex(), () -> randomAsciiOfLengthBetween(2, 20))); + mutation.regex(randomValueOtherThan(mutation.regex(), () -> randomAlphaOfLengthBetween(2, 20))); break; case 3: - mutation.analyzer(randomValueOtherThan(mutation.analyzer(), () -> randomAsciiOfLengthBetween(2, 20))); + mutation.analyzer(randomValueOtherThan(mutation.analyzer(), () -> randomAlphaOfLengthBetween(2, 20))); break; case 4: mutation.size(randomValueOtherThan(mutation.size(), () -> randomIntBetween(1, 20))); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestionOptionTests.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestionOptionTests.java index 4e93201a414c1..9aa4d9dc2b42d 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestionOptionTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestionOptionTests.java @@ -42,7 +42,7 @@ public class CompletionSuggestionOptionTests extends ESTestCase { public static Option createTestItem() { - Text text = new Text(randomAsciiOfLengthBetween(5, 15)); + Text text = new Text(randomAlphaOfLengthBetween(5, 15)); int docId = randomInt(); int numberOfContexts = randomIntBetween(0, 3); Map> contexts = new HashMap<>(); @@ -50,9 +50,9 @@ public static Option createTestItem() { int numberOfValues = randomIntBetween(0, 3); Set values = new HashSet<>(); for (int v = 0; v < numberOfValues; v++) { - values.add(randomAsciiOfLengthBetween(5, 15)); + values.add(randomAlphaOfLengthBetween(5, 15)); } - contexts.put(randomAsciiOfLengthBetween(5, 15), values); + contexts.put(randomAlphaOfLengthBetween(5, 15), values); } SearchHit hit = null; float score = randomFloat(); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java index fa94eabeb53f6..a3ea5e993241e 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/ContextCompletionSuggestSearchIT.java @@ -631,7 +631,7 @@ public void testGeoField() throws Exception { refresh(); - String suggestionName = randomAsciiOfLength(10); + String suggestionName = randomAlphaOfLength(10); CompletionSuggestionBuilder context = SuggestBuilders.completionSuggestion(FIELD).text("h").size(10) .contexts(Collections.singletonMap("st", Collections.singletonList(GeoQueryContext.builder().setGeoPoint(new GeoPoint(52.52, 13.4)).build()))); SearchResponse searchResponse = client().prepareSearch(INDEX).suggest(new SuggestBuilder().addSuggestion(suggestionName, context)).get(); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java index dde5a730457cf..d5eee4d3dee7c 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java @@ -82,9 +82,9 @@ public void testThatCustomSuggestersCanBeRegisteredAndWork() throws Exception { .endObject()) .setRefreshPolicy(IMMEDIATE).get(); - String randomText = randomAsciiOfLength(10); - String randomField = randomAsciiOfLength(10); - String randomSuffix = randomAsciiOfLength(10); + String randomText = randomAlphaOfLength(10); + String randomField = randomAlphaOfLength(10); + String randomSuffix = randomAlphaOfLength(10); SuggestBuilder suggestBuilder = new SuggestBuilder(); suggestBuilder.addSuggestion("someName", new CustomSuggestionBuilder(randomField, randomSuffix).text(randomText)); SearchRequestBuilder searchRequestBuilder = client().prepareSearch("test").setTypes("test").setFrom(0).setSize(1) diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestBuilderTests.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestBuilderTests.java index 9029a097caa31..61094be8a35eb 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestBuilderTests.java @@ -129,9 +129,9 @@ protected SuggestBuilder createMutation(SuggestBuilder original) throws IOExcept mutation.addSuggestion(suggestionBuilder.getKey(), suggestionBuilder.getValue()); } if (randomBoolean()) { - mutation.setGlobalText(randomAsciiOfLengthBetween(5, 60)); + mutation.setGlobalText(randomAlphaOfLengthBetween(5, 60)); } else { - mutation.addSuggestion(randomAsciiOfLength(10), PhraseSuggestionBuilderTests.randomPhraseSuggestionBuilder()); + mutation.addSuggestion(randomAlphaOfLength(10), PhraseSuggestionBuilderTests.randomPhraseSuggestionBuilder()); } return mutation; } @@ -139,11 +139,11 @@ protected SuggestBuilder createMutation(SuggestBuilder original) throws IOExcept public static SuggestBuilder randomSuggestBuilder() { SuggestBuilder builder = new SuggestBuilder(); if (randomBoolean()) { - builder.setGlobalText(randomAsciiOfLengthBetween(1, 20)); + builder.setGlobalText(randomAlphaOfLengthBetween(1, 20)); } final int numSuggestions = randomIntBetween(1, 5); for (int i = 0; i < numSuggestions; i++) { - builder.addSuggestion(randomAsciiOfLengthBetween(5, 10), randomSuggestionBuilder()); + builder.addSuggestion(randomAlphaOfLengthBetween(5, 10), randomSuggestionBuilder()); } return builder; } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java index 24e98899e8731..8a6713caf5ff4 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java @@ -125,9 +125,9 @@ public void testToXContent() throws IOException { public void testFilter() throws Exception { List>> suggestions; - CompletionSuggestion completionSuggestion = new CompletionSuggestion(randomAsciiOfLength(10), 2); - PhraseSuggestion phraseSuggestion = new PhraseSuggestion(randomAsciiOfLength(10), 2); - TermSuggestion termSuggestion = new TermSuggestion(randomAsciiOfLength(10), 2, SortBy.SCORE); + CompletionSuggestion completionSuggestion = new CompletionSuggestion(randomAlphaOfLength(10), 2); + PhraseSuggestion phraseSuggestion = new PhraseSuggestion(randomAlphaOfLength(10), 2); + TermSuggestion termSuggestion = new TermSuggestion(randomAlphaOfLength(10), 2, SortBy.SCORE); suggestions = Arrays.asList(completionSuggestion, phraseSuggestion, termSuggestion); Suggest suggest = new Suggest(suggestions); List phraseSuggestions = suggest.filter(PhraseSuggestion.class); @@ -146,7 +146,7 @@ public void testSuggestionOrdering() throws Exception { suggestions = new ArrayList<>(); int n = randomIntBetween(2, 5); for (int i = 0; i < n; i++) { - suggestions.add(new CompletionSuggestion(randomAsciiOfLength(10), randomIntBetween(3, 5))); + suggestions.add(new CompletionSuggestion(randomAlphaOfLength(10), randomIntBetween(3, 5))); } Collections.shuffle(suggestions, random()); Suggest suggest = new Suggest(suggestions); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestionEntryTests.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestionEntryTests.java index 07f310dfd0fd6..ddb49048274b6 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestionEntryTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestionEntryTests.java @@ -55,7 +55,7 @@ public class SuggestionEntryTests extends ESTestCase { */ @SuppressWarnings("unchecked") public static Entry createTestItem(Class entryType) { - Text entryText = new Text(randomAsciiOfLengthBetween(5, 15)); + Text entryText = new Text(randomAlphaOfLengthBetween(5, 15)); int offset = randomInt(); int length = randomInt(); Entry entry; diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestionOptionTests.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestionOptionTests.java index 9ffad11b0784a..268f7429d7178 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestionOptionTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestionOptionTests.java @@ -35,9 +35,9 @@ public class SuggestionOptionTests extends ESTestCase { public static Option createTestItem() { - Text text = new Text(randomAsciiOfLengthBetween(5, 15)); + Text text = new Text(randomAlphaOfLengthBetween(5, 15)); float score = randomFloat(); - Text highlighted = randomFrom((Text) null, new Text(randomAsciiOfLengthBetween(5, 15))); + Text highlighted = randomFrom((Text) null, new Text(randomAlphaOfLengthBetween(5, 15))); Boolean collateMatch = randomFrom((Boolean) null, randomBoolean()); return new Option(text, highlighted, score, collateMatch); } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/SuggestionTests.java b/core/src/test/java/org/elasticsearch/search/suggest/SuggestionTests.java index 259ff50e0b79b..9f1607d9d6500 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/SuggestionTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/SuggestionTests.java @@ -65,7 +65,7 @@ protected NamedXContentRegistry xContentRegistry() { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Suggestion> createTestItem(Class type) { - String name = randomAsciiOfLengthBetween(5, 10); + String name = randomAlphaOfLengthBetween(5, 10); // note: size will not be rendered via "toXContent", only passed on internally on transport layer int size = randomInt(); Supplier entrySupplier = null; diff --git a/core/src/test/java/org/elasticsearch/search/suggest/TermSuggestionOptionTests.java b/core/src/test/java/org/elasticsearch/search/suggest/TermSuggestionOptionTests.java index ad2aed0226fc9..668629fe57ef2 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/TermSuggestionOptionTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/TermSuggestionOptionTests.java @@ -35,7 +35,7 @@ public class TermSuggestionOptionTests extends ESTestCase { public static Option createTestItem() { - Text text = new Text(randomAsciiOfLengthBetween(5, 15)); + Text text = new Text(randomAlphaOfLengthBetween(5, 15)); float score = randomFloat(); int freq = randomInt(); return new Option(text, freq, score); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryQueryContextTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryQueryContextTests.java index 59d7bbd61b905..658f145b1c635 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryQueryContextTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryQueryContextTests.java @@ -28,7 +28,7 @@ public class CategoryQueryContextTests extends QueryContextTestCase> contextMap = new HashMap<>(); @@ -77,7 +77,7 @@ private static BuilderAndInfo randomSuggestionBuilderWithContextInfo() { for (int i = 0; i < numContext; i++) { contexts.add(CategoryQueryContextTests.randomCategoryQueryContext()); } - String name = randomAsciiOfLength(10); + String name = randomAlphaOfLength(10); contextMap.put(name, contexts); builderAndInfo.catContexts.add(name); } @@ -87,7 +87,7 @@ private static BuilderAndInfo randomSuggestionBuilderWithContextInfo() { for (int i = 0; i < numContext; i++) { contexts.add(GeoQueryContextTests.randomGeoQueryContext()); } - String name = randomAsciiOfLength(10); + String name = randomAlphaOfLength(10); contextMap.put(name, contexts); builderAndInfo.geoContexts.add(name); } @@ -114,7 +114,7 @@ protected void mutateSpecificParameters(CompletionSuggestionBuilder builder) thr for (int i = 0; i < nCatContext; i++) { contexts.add(CategoryQueryContextTests.randomCategoryQueryContext()); } - builder.contexts(Collections.singletonMap(randomAsciiOfLength(10), contexts)); + builder.contexts(Collections.singletonMap(randomAlphaOfLength(10), contexts)); break; case 1: int nGeoContext = randomIntBetween(1, 5); @@ -122,16 +122,16 @@ protected void mutateSpecificParameters(CompletionSuggestionBuilder builder) thr for (int i = 0; i < nGeoContext; i++) { geoContexts.add(GeoQueryContextTests.randomGeoQueryContext()); } - builder.contexts(Collections.singletonMap(randomAsciiOfLength(10), geoContexts)); + builder.contexts(Collections.singletonMap(randomAlphaOfLength(10), geoContexts)); break; case 2: - builder.prefix(randomAsciiOfLength(10), FuzzyOptionsTests.randomFuzzyOptions()); + builder.prefix(randomAlphaOfLength(10), FuzzyOptionsTests.randomFuzzyOptions()); break; case 3: - builder.prefix(randomAsciiOfLength(10), randomFrom(Fuzziness.ZERO, Fuzziness.ONE, Fuzziness.TWO)); + builder.prefix(randomAlphaOfLength(10), randomFrom(Fuzziness.ZERO, Fuzziness.ONE, Fuzziness.TWO)); break; case 4: - builder.regex(randomAsciiOfLength(10), RegexOptionsTests.randomRegexOptions()); + builder.regex(randomAlphaOfLength(10), RegexOptionsTests.randomRegexOptions()); break; default: throw new IllegalStateException("should not through"); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java index 60722fb5f6da7..4b0e60a1d00db 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java @@ -35,7 +35,7 @@ public class CompletionSuggestionTests extends ESTestCase { public void testToReduce() throws Exception { List> shardSuggestions = new ArrayList<>(); int nShards = randomIntBetween(1, 10); - String name = randomAsciiOfLength(10); + String name = randomAlphaOfLength(10); int size = randomIntBetween(3, 5); for (int i = 0; i < nShards; i++) { CompletionSuggestion suggestion = new CompletionSuggestion(name, size); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java b/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java index 6c30ccb45705c..10022cc289a71 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java @@ -177,7 +177,7 @@ private void assertIllegalXContent(String directGenerator, Class collateParams = new HashMap<>(); int numParams = randomIntBetween(1, 5); for (int i = 0; i < numParams; i++) { - collateParams.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + collateParams.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } testBuilder.collateParams(collateParams ); } } if (randomBoolean()) { // preTag, postTag - testBuilder.highlight(randomAsciiOfLengthBetween(3, 20), randomAsciiOfLengthBetween(3, 20)); + testBuilder.highlight(randomAlphaOfLengthBetween(3, 20), randomAlphaOfLengthBetween(3, 20)); } maybeSet(testBuilder::gramSize, randomIntBetween(1, 5)); maybeSet(testBuilder::forceUnigrams, randomBoolean()); @@ -106,14 +106,14 @@ protected void mutateSpecificParameters(PhraseSuggestionBuilder builder) throws builder.tokenLimit(randomValueOtherThan(builder.tokenLimit(), () -> randomIntBetween(1, 20))); break; case 5: - builder.separator(randomValueOtherThan(builder.separator(), () -> randomAsciiOfLengthBetween(1, 10))); + builder.separator(randomValueOtherThan(builder.separator(), () -> randomAlphaOfLengthBetween(1, 10))); break; case 6: Script collateQuery = builder.collateQuery(); if (collateQuery != null) { - builder.collateQuery(randomValueOtherThan(collateQuery.getIdOrCode(), () -> randomAsciiOfLengthBetween(3, 20))); + builder.collateQuery(randomValueOtherThan(collateQuery.getIdOrCode(), () -> randomAlphaOfLengthBetween(3, 20))); } else { - builder.collateQuery(randomAsciiOfLengthBetween(3, 20)); + builder.collateQuery(randomAlphaOfLengthBetween(3, 20)); } break; case 7: @@ -126,7 +126,7 @@ protected void mutateSpecificParameters(PhraseSuggestionBuilder builder) throws // simply double both values builder.highlight(builder.preTag() + builder.preTag(), builder.postTag() + builder.postTag()); } else { - builder.highlight(randomAsciiOfLengthBetween(3, 20), randomAsciiOfLengthBetween(3, 20)); + builder.highlight(randomAlphaOfLengthBetween(3, 20), randomAlphaOfLengthBetween(3, 20)); } break; case 9: @@ -134,7 +134,7 @@ protected void mutateSpecificParameters(PhraseSuggestionBuilder builder) throws break; case 10: Map collateParams = builder.collateParams() == null ? new HashMap<>(1) : builder.collateParams(); - collateParams.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + collateParams.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); builder.collateParams(collateParams); break; case 11: @@ -155,7 +155,7 @@ public void testInvalidParameters() throws IOException { e = expectThrows(IllegalArgumentException.class, () -> new PhraseSuggestionBuilder("")); assertEquals("suggestion field name is empty", e.getMessage()); - PhraseSuggestionBuilder builder = new PhraseSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); + PhraseSuggestionBuilder builder = new PhraseSuggestionBuilder(randomAlphaOfLengthBetween(2, 20)); e = expectThrows(IllegalArgumentException.class, () -> builder.gramSize(0)); assertEquals("gramSize must be >= 1", e.getMessage()); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java b/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java index f27d02fbe220c..c5471f3ee0acf 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/term/TermSuggestionBuilderTests.java @@ -58,7 +58,7 @@ protected TermSuggestionBuilder randomSuggestionBuilder() { * Creates a random TermSuggestionBuilder */ public static TermSuggestionBuilder randomTermSuggestionBuilder() { - TermSuggestionBuilder testBuilder = new TermSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); + TermSuggestionBuilder testBuilder = new TermSuggestionBuilder(randomAlphaOfLengthBetween(2, 20)); setCommonPropertiesOnRandomBuilder(testBuilder); maybeSet(testBuilder::suggestMode, randomSuggestMode()); maybeSet(testBuilder::accuracy, randomFloat()); @@ -151,7 +151,7 @@ public void testInvalidParameters() throws IOException { e = expectThrows(IllegalArgumentException.class, () -> new TermSuggestionBuilder("")); assertEquals("suggestion field name is empty", e.getMessage()); - TermSuggestionBuilder builder = new TermSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); + TermSuggestionBuilder builder = new TermSuggestionBuilder(randomAlphaOfLengthBetween(2, 20)); // test invalid accuracy values expectThrows(IllegalArgumentException.class, () -> builder.accuracy(-0.5f)); @@ -193,7 +193,7 @@ public void testInvalidParameters() throws IOException { } public void testDefaultValuesSet() { - TermSuggestionBuilder builder = new TermSuggestionBuilder(randomAsciiOfLengthBetween(2, 20)); + TermSuggestionBuilder builder = new TermSuggestionBuilder(randomAlphaOfLengthBetween(2, 20)); assertEquals(DEFAULT_ACCURACY, builder.accuracy(), Float.MIN_VALUE); assertEquals(DEFAULT_MAX_EDITS, builder.maxEdits()); assertEquals(DEFAULT_MAX_INSPECTIONS, builder.maxInspections()); diff --git a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java index 56ff111e4b0e0..9d0e353cd449d 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/BlobStoreFormatIT.java @@ -151,7 +151,7 @@ public void testCompressionIsApplied() throws IOException { public void testBlobCorruption() throws IOException { BlobStore blobStore = createTestBlobStore(); BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath()); - String testString = randomAsciiOfLength(randomInt(10000)); + String testString = randomAlphaOfLength(randomInt(10000)); BlobObj blobObj = new BlobObj(testString); ChecksumBlobStoreFormat checksumFormat = new ChecksumBlobStoreFormat<>(BLOB_CODEC, "%s", BlobObj::fromXContent, xContentRegistry(), randomBoolean(), randomBoolean() ? XContentType.SMILE : XContentType.JSON); @@ -171,7 +171,7 @@ public void testBlobCorruption() throws IOException { public void testAtomicWrite() throws Exception { final BlobStore blobStore = createTestBlobStore(); final BlobContainer blobContainer = blobStore.blobContainer(BlobPath.cleanPath()); - String testString = randomAsciiOfLength(randomInt(10000)); + String testString = randomAlphaOfLength(randomInt(10000)); final CountDownLatch block = new CountDownLatch(1); final CountDownLatch unblock = new CountDownLatch(1); final BlobObj blobObj = new BlobObj(testString) { diff --git a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 6c0ecd510d11b..08a3308172bd3 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -347,7 +347,7 @@ public void testSnapshotDuringNodeShutdown() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200) ).get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); @@ -395,7 +395,7 @@ public void testSnapshotWithStuckNode() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", repo) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200) ).get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); diff --git a/core/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java index d1759d83e3410..680bfea6b3b3c 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/MinThreadsSnapshotRestoreIT.java @@ -59,7 +59,7 @@ public void testConcurrentSnapshotDeletionsNotAllowed() throws Exception { assertAcked(client().admin().cluster().preparePutRepository(repo).setType("mock").setSettings( Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200)).get()); logger.info("--> snapshot twice"); @@ -113,7 +113,7 @@ public void testSnapshottingWithInProgressDeletionNotAllowed() throws Exception assertAcked(client().admin().cluster().preparePutRepository(repo).setType("mock").setSettings( Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200)).get()); logger.info("--> snapshot"); @@ -160,7 +160,7 @@ public void testRestoreWithInProgressDeletionsNotAllowed() throws Exception { assertAcked(client().admin().cluster().preparePutRepository(repo).setType("mock").setSettings( Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200)).get()); logger.info("--> snapshot"); diff --git a/core/src/test/java/org/elasticsearch/snapshots/RepositoriesMetaDataSerializationTests.java b/core/src/test/java/org/elasticsearch/snapshots/RepositoriesMetaDataSerializationTests.java index 101ae591292b3..8f027b6695024 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/RepositoriesMetaDataSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/snapshots/RepositoriesMetaDataSerializationTests.java @@ -42,7 +42,7 @@ protected Custom createTestInstance() { int numberOfRepositories = randomInt(10); List entries = new ArrayList<>(); for (int i = 0; i < numberOfRepositories; i++) { - entries.add(new RepositoryMetaData(randomAsciiOfLength(10), randomAsciiOfLength(10), randomSettings())); + entries.add(new RepositoryMetaData(randomAlphaOfLength(10), randomAlphaOfLength(10), randomSettings())); } entries.sort(Comparator.comparing(RepositoryMetaData::name)); return new RepositoriesMetaData(entries.toArray(new RepositoryMetaData[entries.size()])); @@ -60,7 +60,7 @@ public Settings randomSettings() { int numberOfSettings = randomInt(10); Settings.Builder builder = Settings.builder(); for (int i = 0; i < numberOfSettings; i++) { - builder.put(randomAsciiOfLength(10), randomAsciiOfLength(20)); + builder.put(randomAlphaOfLength(10), randomAlphaOfLength(20)); } return builder.build(); } @@ -79,7 +79,7 @@ protected Custom makeTestChanges(Custom testInstance) { // add some elements int addElements = randomInt(10); for (int i = 0; i < addElements; i++) { - repos.add(new RepositoryMetaData(randomAsciiOfLength(10), randomAsciiOfLength(10), randomSettings())); + repos.add(new RepositoryMetaData(randomAlphaOfLength(10), randomAlphaOfLength(10), randomSettings())); } } return new RepositoriesMetaData(repos.toArray(new RepositoryMetaData[repos.size()])); diff --git a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java index 77a0514a140ba..45bd369a94176 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java @@ -657,7 +657,7 @@ public void testSnapshotFileFailureDuringSnapshot() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("random_control_io_exception_rate", 0.2)) .setVerify(false)); @@ -707,7 +707,7 @@ public void testDataFileFailureDuringSnapshot() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("random_data_file_io_exception_rate", 0.3))); createIndex("test-idx"); @@ -792,7 +792,7 @@ public void testDataFileFailureDuringRestore() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", repositoryLocation) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("random_data_file_io_exception_rate", 0.3))); // Test restore after index deletion @@ -833,7 +833,7 @@ public void testDataFileCorruptionDuringRestore() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", repositoryLocation) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("use_lucene_corruption", true) .put("max_failure_number", 10000000L) .put("random_data_file_io_exception_rate", 1.0))); @@ -879,7 +879,7 @@ public void testDeletionOfFailingToRecoverIndexShouldStopRestore() throws Except .setType("mock").setSettings( Settings.builder() .put("location", repositoryLocation) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("random_data_file_io_exception_rate", 1.0) // Fail completely )); @@ -1312,7 +1312,7 @@ public void testMoveShardWhileSnapshotting() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", repositoryLocation) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200))); // Create index on 2 nodes and make sure each node has a primary by setting no replicas @@ -1373,7 +1373,7 @@ public void testDeleteRepositoryWhileSnapshotting() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", repositoryLocation) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200) ).get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); @@ -1569,7 +1569,7 @@ public void testSnapshotStatus() throws Exception { .setType("mock").setSettings( Settings.builder() .put("location", repositoryLocation) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200) ).get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); @@ -2533,7 +2533,7 @@ public void testGetSnapshotsRequest() throws Exception { logger.info("--> take {} snapshot(s)", numSnapshots - 1); final String[] snapshotNames = new String[numSnapshots]; for (int i = 0; i < numSnapshots - 1; i++) { - final String snapshotName = randomAsciiOfLength(8).toLowerCase(Locale.ROOT); + final String snapshotName = randomAlphaOfLength(8).toLowerCase(Locale.ROOT); CreateSnapshotResponse createSnapshotResponse = client.admin() .cluster() .prepareCreateSnapshot(repositoryName, snapshotName) @@ -2550,7 +2550,7 @@ public void testGetSnapshotsRequest() throws Exception { } refresh(); - final String inProgressSnapshot = randomAsciiOfLength(8).toLowerCase(Locale.ROOT); + final String inProgressSnapshot = randomAlphaOfLength(8).toLowerCase(Locale.ROOT); snapshotNames[numSnapshots - 1] = inProgressSnapshot; // block a node so the create snapshot operation can remain in progress final String blockedNode = blockNodeWithIndex(repositoryName, indexName); @@ -2644,7 +2644,7 @@ public void testSnapshotCanceledOnRemovedShard() throws Exception { PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository(repo).setType("mock").setSettings(Settings.builder() .put("location", randomRepoPath()) - .put("random", randomAsciiOfLength(10)) + .put("random", randomAlphaOfLength(10)) .put("wait_after_unblock", 200) ).get(); assertTrue(putRepositoryResponse.isAcknowledged()); @@ -2688,7 +2688,7 @@ public void testSnapshotSucceedsAfterSnapshotFailure() throws Exception { .put("random_control_io_exception_rate", randomIntBetween(5, 20) / 100f) // test that we can take a snapshot after a failed one, even if a partial index-N was written .put("atomic_move", false) - .put("random", randomAsciiOfLength(10)))); + .put("random", randomAlphaOfLength(10)))); logger.info("--> indexing some data"); assertAcked(prepareCreate("test-idx").setSettings( diff --git a/core/src/test/java/org/elasticsearch/snapshots/SnapshotTests.java b/core/src/test/java/org/elasticsearch/snapshots/SnapshotTests.java index aceefea97f587..3d7277b9c68d3 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/SnapshotTests.java +++ b/core/src/test/java/org/elasticsearch/snapshots/SnapshotTests.java @@ -46,8 +46,8 @@ public void testSnapshotEquals() { } public void testSerialization() throws IOException { - final SnapshotId snapshotId = new SnapshotId(randomAsciiOfLength(randomIntBetween(2, 8)), UUIDs.randomBase64UUID()); - final Snapshot original = new Snapshot(randomAsciiOfLength(randomIntBetween(2, 8)), snapshotId); + final SnapshotId snapshotId = new SnapshotId(randomAlphaOfLength(randomIntBetween(2, 8)), UUIDs.randomBase64UUID()); + final Snapshot original = new Snapshot(randomAlphaOfLength(randomIntBetween(2, 8)), snapshotId); final BytesStreamOutput out = new BytesStreamOutput(); original.writeTo(out); assertThat(new Snapshot(out.bytes().streamInput()), equalTo(original)); diff --git a/core/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java b/core/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java index 4b5a967794551..edf3ada587f31 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java @@ -49,22 +49,22 @@ protected Custom createTestInstance() { } private Entry randomSnapshot() { - Snapshot snapshot = new Snapshot(randomAsciiOfLength(10), new SnapshotId(randomAsciiOfLength(10), randomAsciiOfLength(10))); + Snapshot snapshot = new Snapshot(randomAlphaOfLength(10), new SnapshotId(randomAlphaOfLength(10), randomAlphaOfLength(10))); boolean includeGlobalState = randomBoolean(); boolean partial = randomBoolean(); State state = randomFrom(State.values()); int numberOfIndices = randomIntBetween(0, 10); List indices = new ArrayList<>(); for (int i = 0; i < numberOfIndices; i++) { - indices.add(new IndexId(randomAsciiOfLength(10), randomAsciiOfLength(10))); + indices.add(new IndexId(randomAlphaOfLength(10), randomAlphaOfLength(10))); } long startTime = randomLong(); long repositoryStateId = randomLong(); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(); int shardsCount = randomIntBetween(0, 10); for (int j = 0; j < shardsCount; j++) { - ShardId shardId = new ShardId(new Index(randomAsciiOfLength(10), randomAsciiOfLength(10)), randomIntBetween(0, 10)); - String nodeId = randomAsciiOfLength(10); + ShardId shardId = new ShardId(new Index(randomAlphaOfLength(10), randomAlphaOfLength(10)), randomIntBetween(0, 10)); + String nodeId = randomAlphaOfLength(10); State shardState = randomFrom(State.values()); builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(nodeId, shardState)); } diff --git a/core/src/test/java/org/elasticsearch/tasks/TaskResultTests.java b/core/src/test/java/org/elasticsearch/tasks/TaskResultTests.java index ff8fcd8fbaf47..c4cf7713c3d4a 100644 --- a/core/src/test/java/org/elasticsearch/tasks/TaskResultTests.java +++ b/core/src/test/java/org/elasticsearch/tasks/TaskResultTests.java @@ -89,10 +89,10 @@ private static TaskResult randomTaskResult() throws IOException { private static TaskInfo randomTaskInfo() throws IOException { TaskId taskId = randomTaskId(); - String type = randomAsciiOfLength(5); - String action = randomAsciiOfLength(5); + String type = randomAlphaOfLength(5); + String action = randomAlphaOfLength(5); Task.Status status = randomBoolean() ? randomRawTaskStatus() : null; - String description = randomBoolean() ? randomAsciiOfLength(5) : null; + String description = randomBoolean() ? randomAlphaOfLength(5) : null; long startTime = randomLong(); long runningTimeNanos = randomLong(); boolean cancellable = randomBoolean(); @@ -101,7 +101,7 @@ private static TaskInfo randomTaskInfo() throws IOException { } private static TaskId randomTaskId() { - return new TaskId(randomAsciiOfLength(5), randomLong()); + return new TaskId(randomAlphaOfLength(5), randomLong()); } private static RawTaskStatus randomRawTaskStatus() throws IOException { @@ -109,7 +109,7 @@ private static RawTaskStatus randomRawTaskStatus() throws IOException { builder.startObject(); int fields = between(0, 10); for (int f = 0; f < fields; f++) { - builder.field(randomAsciiOfLength(5), randomAsciiOfLength(5)); + builder.field(randomAlphaOfLength(5), randomAlphaOfLength(5)); } builder.endObject(); return new RawTaskStatus(builder.bytes()); @@ -120,7 +120,7 @@ private static ToXContent randomTaskResponse() { Map result = new TreeMap<>(); int fields = between(0, 10); for (int f = 0; f < fields; f++) { - result.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + result.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } return new ToXContent() { @Override diff --git a/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java b/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java index 3b6165adab158..ab882b4031600 100644 --- a/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java +++ b/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java @@ -166,7 +166,7 @@ public void testNodeConnectWithDifferentNodeId() { NetworkHandle handleA = startServices("TS_A", settings, Version.CURRENT); NetworkHandle handleB = startServices("TS_B", settings, Version.CURRENT); DiscoveryNode discoveryNode = new DiscoveryNode( - randomAsciiOfLength(10), + randomAlphaOfLength(10), handleB.discoveryNode.getAddress(), emptyMap(), emptySet(), diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index a63d16a936457..9e1d37681be93 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -504,8 +504,8 @@ public void testMergingRemovedCustomMetaData() throws Exception { public void testMergingCustomMetaData() throws Exception { removeCustomMetaData(cluster1, MergableCustomMetaData1.TYPE); removeCustomMetaData(cluster2, MergableCustomMetaData1.TYPE); - MergableCustomMetaData1 customMetaData1 = new MergableCustomMetaData1(randomAsciiOfLength(10)); - MergableCustomMetaData1 customMetaData2 = new MergableCustomMetaData1(randomAsciiOfLength(10)); + MergableCustomMetaData1 customMetaData1 = new MergableCustomMetaData1(randomAlphaOfLength(10)); + MergableCustomMetaData1 customMetaData2 = new MergableCustomMetaData1(randomAlphaOfLength(10)); List customMetaDatas = Arrays.asList(customMetaData1, customMetaData2); Collections.sort(customMetaDatas, (cm1, cm2) -> cm2.getData().compareTo(cm1.getData())); final MergableCustomMetaData1 tribeNodeCustomMetaData = customMetaDatas.get(0); @@ -521,10 +521,10 @@ public void testMergingCustomMetaData() throws Exception { public void testMergingMultipleCustomMetaData() throws Exception { removeCustomMetaData(cluster1, MergableCustomMetaData1.TYPE); removeCustomMetaData(cluster2, MergableCustomMetaData1.TYPE); - MergableCustomMetaData1 firstCustomMetaDataType1 = new MergableCustomMetaData1(randomAsciiOfLength(10)); - MergableCustomMetaData1 secondCustomMetaDataType1 = new MergableCustomMetaData1(randomAsciiOfLength(10)); - MergableCustomMetaData2 firstCustomMetaDataType2 = new MergableCustomMetaData2(randomAsciiOfLength(10)); - MergableCustomMetaData2 secondCustomMetaDataType2 = new MergableCustomMetaData2(randomAsciiOfLength(10)); + MergableCustomMetaData1 firstCustomMetaDataType1 = new MergableCustomMetaData1(randomAlphaOfLength(10)); + MergableCustomMetaData1 secondCustomMetaDataType1 = new MergableCustomMetaData1(randomAlphaOfLength(10)); + MergableCustomMetaData2 firstCustomMetaDataType2 = new MergableCustomMetaData2(randomAlphaOfLength(10)); + MergableCustomMetaData2 secondCustomMetaDataType2 = new MergableCustomMetaData2(randomAlphaOfLength(10)); List mergedCustomMetaDataType1 = Arrays.asList(firstCustomMetaDataType1, secondCustomMetaDataType1); List mergedCustomMetaDataType2 = Arrays.asList(firstCustomMetaDataType2, secondCustomMetaDataType2); Collections.sort(mergedCustomMetaDataType1, (cm1, cm2) -> cm2.getData().compareTo(cm1.getData())); diff --git a/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java b/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java index beab15165d698..ae232c2c6872b 100644 --- a/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java +++ b/core/src/test/java/org/elasticsearch/update/UpdateNoopIT.java @@ -51,9 +51,9 @@ public void testSingleField() throws Exception { public void testTwoFields() throws Exception { // Use random keys so we get random iteration order. - String key1 = 1 + randomAsciiOfLength(3); - String key2 = 2 + randomAsciiOfLength(3); - String key3 = 3 + randomAsciiOfLength(3); + String key1 = 1 + randomAlphaOfLength(3); + String key2 = 2 + randomAlphaOfLength(3); + String key3 = 3 + randomAlphaOfLength(3); updateAndCheckSource(1, fields(key1, "foo", key2, "baz")); updateAndCheckSource(1, fields(key1, "foo", key2, "baz")); updateAndCheckSource(2, fields(key1, "foo", key2, "bir")); @@ -90,9 +90,9 @@ public void testArrayField() throws Exception { public void testMap() throws Exception { // Use random keys so we get variable iteration order. - String key1 = 1 + randomAsciiOfLength(3); - String key2 = 2 + randomAsciiOfLength(3); - String key3 = 3 + randomAsciiOfLength(3); + String key1 = 1 + randomAlphaOfLength(3); + String key2 = 2 + randomAlphaOfLength(3); + String key3 = 3 + randomAlphaOfLength(3); updateAndCheckSource(1, XContentFactory.jsonBuilder().startObject() .startObject("test") .field(key1, "foo") diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java index e70bc3434eeac..072aa6faf84a4 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorFactoryTests.java @@ -51,7 +51,7 @@ public void testCreate() throws Exception { value = Arrays.asList("value1", "value2", "value3"); } config.put("value", value); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); AppendProcessor appendProcessor = factory.create(null, processorTag, config); assertThat(appendProcessor.getTag(), equalTo(processorTag)); assertThat(appendProcessor.getField().execute(Collections.emptyMap()), equalTo("field1")); @@ -97,7 +97,7 @@ public void testInvalidMustacheTemplate() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("value", "value1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("java.lang.RuntimeException: could not compile script")); assertThat(exception.getHeader("processor_tag").get(0), equalTo(processorTag)); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorTests.java index 16df08721d3d8..fbbfb8a8440b0 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/AppendProcessorTests.java @@ -130,13 +130,13 @@ public void testAppendMetadata() throws Exception { List values = new ArrayList<>(); Processor appendProcessor; if (randomBoolean()) { - String value = randomAsciiOfLengthBetween(1, 10); + String value = randomAlphaOfLengthBetween(1, 10); values.add(value); appendProcessor = createAppendProcessor(randomMetaData.getFieldName(), value); } else { int valuesSize = randomIntBetween(0, 10); for (int i = 0; i < valuesSize; i++) { - values.add(randomAsciiOfLengthBetween(1, 10)); + values.add(randomAlphaOfLengthBetween(1, 10)); } appendProcessor = createAppendProcessor(randomMetaData.getFieldName(), values); } @@ -158,7 +158,7 @@ public void testAppendMetadata() throws Exception { private static Processor createAppendProcessor(String fieldName, Object fieldValue) { TemplateService templateService = TestTemplateService.instance(); - return new AppendProcessor(randomAsciiOfLength(10), templateService.compile(fieldName), ValueSource.wrap(fieldValue, + return new AppendProcessor(randomAlphaOfLength(10), templateService.compile(fieldName), ValueSource.wrap(fieldValue, templateService)); } @@ -186,7 +186,7 @@ Object randomValue() { }, STRING { @Override Object randomValue() { - return randomAsciiOfLengthBetween(1, 10); + return randomAlphaOfLengthBetween(1, 10); } }, MAP { @Override @@ -194,7 +194,7 @@ Object randomValue() { int numItems = randomIntBetween(1, 10); Map map = new HashMap<>(numItems); for (int i = 0; i < numItems; i++) { - map.put(randomAsciiOfLengthBetween(1, 10), randomFrom(Scalar.values()).randomValue()); + map.put(randomAlphaOfLengthBetween(1, 10), randomFrom(Scalar.values()).randomValue()); } return map; } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java index afdb7f7841de4..9e4acd7b17f83 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorFactoryTests.java @@ -38,7 +38,7 @@ public void testCreate() throws Exception { ConvertProcessor.Type type = randomFrom(ConvertProcessor.Type.values()); config.put("field", "field1"); config.put("type", type.toString()); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ConvertProcessor convertProcessor = factory.create(null, processorTag, config); assertThat(convertProcessor.getTag(), equalTo(processorTag)); assertThat(convertProcessor.getField(), equalTo("field1")); @@ -50,7 +50,7 @@ public void testCreate() throws Exception { public void testCreateUnsupportedType() throws Exception { ConvertProcessor.Factory factory = new ConvertProcessor.Factory(); Map config = new HashMap<>(); - String type = "type-" + randomAsciiOfLengthBetween(1, 10); + String type = "type-" + randomAlphaOfLengthBetween(1, 10); config.put("field", "field1"); config.put("type", type); try { @@ -67,7 +67,7 @@ public void testCreateUnsupportedType() throws Exception { public void testCreateNoFieldPresent() throws Exception { ConvertProcessor.Factory factory = new ConvertProcessor.Factory(); Map config = new HashMap<>(); - String type = "type-" + randomAsciiOfLengthBetween(1, 10); + String type = "type-" + randomAlphaOfLengthBetween(1, 10); config.put("type", type); try { factory.create(null, null, config); @@ -96,7 +96,7 @@ public void testCreateWithExplicitTargetField() throws Exception { config.put("field", "field1"); config.put("target_field", "field2"); config.put("type", type.toString()); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ConvertProcessor convertProcessor = factory.create(null, processorTag, config); assertThat(convertProcessor.getTag(), equalTo(processorTag)); assertThat(convertProcessor.getField(), equalTo("field1")); @@ -112,7 +112,7 @@ public void testCreateWithIgnoreMissing() throws Exception { config.put("field", "field1"); config.put("type", type.toString()); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ConvertProcessor convertProcessor = factory.create(null, processorTag, config); assertThat(convertProcessor.getTag(), equalTo(processorTag)); assertThat(convertProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorTests.java index f8a8a24286f4f..7cab5fff45c6f 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ConvertProcessorTests.java @@ -43,7 +43,7 @@ public void testConvertInt() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); int randomInt = randomInt(); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, randomInt); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.INTEGER, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.INTEGER, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, Integer.class), equalTo(randomInt)); } @@ -59,7 +59,7 @@ public void testConvertIntList() throws Exception { expectedList.add(randomInt); } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.INTEGER, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.INTEGER, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, List.class), equalTo(expectedList)); } @@ -67,10 +67,10 @@ public void testConvertIntList() throws Exception { public void testConvertIntError() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - String value = "string-" + randomAsciiOfLengthBetween(1, 10); + String value = "string-" + randomAlphaOfLengthBetween(1, 10); ingestDocument.setFieldValue(fieldName, value); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.INTEGER, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.INTEGER, false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -86,7 +86,7 @@ public void testConvertFloat() throws Exception { String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, randomFloat); expectedResult.put(fieldName, randomFloat); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.FLOAT, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.FLOAT, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, Float.class), equalTo(randomFloat)); } @@ -102,7 +102,7 @@ public void testConvertFloatList() throws Exception { expectedList.add(randomFloat); } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.FLOAT, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.FLOAT, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, List.class), equalTo(expectedList)); } @@ -110,10 +110,10 @@ public void testConvertFloatList() throws Exception { public void testConvertFloatError() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - String value = "string-" + randomAsciiOfLengthBetween(1, 10); + String value = "string-" + randomAlphaOfLengthBetween(1, 10); ingestDocument.setFieldValue(fieldName, value); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.FLOAT, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.FLOAT, false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -131,7 +131,7 @@ public void testConvertBoolean() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, booleanString); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.BOOLEAN, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.BOOLEAN, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, Boolean.class), equalTo(randomBoolean)); } @@ -151,7 +151,7 @@ public void testConvertBooleanList() throws Exception { expectedList.add(randomBoolean); } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.BOOLEAN, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.BOOLEAN, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, List.class), equalTo(expectedList)); } @@ -161,14 +161,14 @@ public void testConvertBooleanError() throws Exception { String fieldName = RandomDocumentPicks.randomFieldName(random()); String fieldValue; if (randomBoolean()) { - fieldValue = "string-" + randomAsciiOfLengthBetween(1, 10); + fieldValue = "string-" + randomAlphaOfLengthBetween(1, 10); } else { //verify that only proper boolean values are supported and we are strict about it fieldValue = randomFrom("on", "off", "yes", "no", "0", "1"); } ingestDocument.setFieldValue(fieldName, fieldValue); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.BOOLEAN, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.BOOLEAN, false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -202,7 +202,7 @@ public void testConvertString() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.STRING, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.STRING, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, String.class), equalTo(expectedFieldValue)); } @@ -238,7 +238,7 @@ public void testConvertStringList() throws Exception { expectedList.add(randomValueString); } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, Type.STRING, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, Type.STRING, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, List.class), equalTo(expectedList)); } @@ -247,7 +247,7 @@ public void testConvertNonExistingField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); Type type = randomFrom(Type.values()); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, type, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, type, false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -259,7 +259,7 @@ public void testConvertNonExistingField() throws Exception { public void testConvertNullField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null)); Type type = randomFrom(Type.values()); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", type, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", type, false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -273,7 +273,7 @@ public void testConvertNonExistingFieldWithIgnoreMissing() throws Exception { IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); String fieldName = RandomDocumentPicks.randomFieldName(random()); Type type = randomFrom(Type.values()); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, fieldName, type, true); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, fieldName, type, true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -282,7 +282,7 @@ public void testConvertNullFieldWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null)); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); Type type = randomFrom(Type.values()); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", type, true); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", type, true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -306,7 +306,7 @@ public void testAutoConvertNotString() throws Exception { throw new UnsupportedOperationException(); } IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", randomValue)); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", Type.AUTO, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", Type.AUTO, false); processor.execute(ingestDocument); Object convertedValue = ingestDocument.getFieldValue("field", Object.class); assertThat(convertedValue, sameInstance(randomValue)); @@ -315,7 +315,7 @@ public void testAutoConvertNotString() throws Exception { public void testAutoConvertStringNotMatched() throws Exception { String value = "notAnIntFloatOrBool"; IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", value)); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", Type.AUTO, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", Type.AUTO, false); processor.execute(ingestDocument); Object convertedValue = ingestDocument.getFieldValue("field", Object.class); assertThat(convertedValue, sameInstance(value)); @@ -326,7 +326,7 @@ public void testAutoConvertMatchBoolean() throws Exception { String booleanString = Boolean.toString(randomBoolean); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", booleanString)); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", Type.AUTO, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", Type.AUTO, false); processor.execute(ingestDocument); Object convertedValue = ingestDocument.getFieldValue("field", Object.class); assertThat(convertedValue, equalTo(randomBoolean)); @@ -336,7 +336,7 @@ public void testAutoConvertMatchInteger() throws Exception { int randomInt = randomInt(); String randomString = Integer.toString(randomInt); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", randomString)); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", Type.AUTO, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", Type.AUTO, false); processor.execute(ingestDocument); Object convertedValue = ingestDocument.getFieldValue("field", Object.class); assertThat(convertedValue, equalTo(randomInt)); @@ -346,7 +346,7 @@ public void testAutoConvertMatchFloat() throws Exception { float randomFloat = randomFloat(); String randomString = Float.toString(randomFloat); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", randomString)); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), "field", "field", Type.AUTO, false); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), "field", "field", Type.AUTO, false); processor.execute(ingestDocument); Object convertedValue = ingestDocument.getFieldValue("field", Object.class); assertThat(convertedValue, equalTo(randomFloat)); @@ -356,8 +356,8 @@ public void testTargetField() throws Exception { IngestDocument ingestDocument = new IngestDocument(new HashMap<>(), new HashMap<>()); int randomInt = randomInt(); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, String.valueOf(randomInt)); - String targetField = fieldName + randomAsciiOfLength(5); - Processor processor = new ConvertProcessor(randomAsciiOfLength(10), fieldName, targetField, Type.INTEGER, false); + String targetField = fieldName + randomAlphaOfLength(5); + Processor processor = new ConvertProcessor(randomAlphaOfLength(10), fieldName, targetField, Type.INTEGER, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, String.class), equalTo(String.valueOf(randomInt))); assertThat(ingestDocument.getFieldValue(targetField, Integer.class), equalTo(randomInt)); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateFormatTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateFormatTests.java index 0885371f867bf..886630dbbd926 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateFormatTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateFormatTests.java @@ -81,6 +81,6 @@ public void testFromString() { assertThat(DateFormat.fromString("iso8601"), equalTo(DateFormat.Joda)); assertThat(DateFormat.fromString("TAI64N"), equalTo(DateFormat.Tai64n)); assertThat(DateFormat.fromString("tai64n"), equalTo(DateFormat.Joda)); - assertThat(DateFormat.fromString("prefix-" + randomAsciiOfLengthBetween(1, 10)), equalTo(DateFormat.Joda)); + assertThat(DateFormat.fromString("prefix-" + randomAlphaOfLengthBetween(1, 10)), equalTo(DateFormat.Joda)); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java index 95ad68bb110a4..2dc16ad7bd7fd 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorFactoryTests.java @@ -37,10 +37,10 @@ public class DateProcessorFactoryTests extends ESTestCase { public void testBuildDefaults() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("formats", Collections.singletonList("dd/MM/yyyyy")); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); DateProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); assertThat(processor.getField(), equalTo(sourceField)); @@ -53,7 +53,7 @@ public void testBuildDefaults() throws Exception { public void testMatchFieldIsMandatory() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String targetField = randomAsciiOfLengthBetween(1, 10); + String targetField = randomAlphaOfLengthBetween(1, 10); config.put("target_field", targetField); config.put("formats", Collections.singletonList("dd/MM/yyyyy")); @@ -68,8 +68,8 @@ public void testMatchFieldIsMandatory() throws Exception { public void testMatchFormatsIsMandatory() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); - String targetField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); + String targetField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("target_field", targetField); @@ -84,7 +84,7 @@ public void testMatchFormatsIsMandatory() throws Exception { public void testParseLocale() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("formats", Collections.singletonList("dd/MM/yyyyy")); Locale locale = randomLocale(random()); @@ -97,7 +97,7 @@ public void testParseLocale() throws Exception { public void testParseInvalidLocale() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("formats", Collections.singletonList("dd/MM/yyyyy")); config.put("locale", "invalid_locale"); @@ -112,7 +112,7 @@ public void testParseInvalidLocale() throws Exception { public void testParseTimezone() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("formats", Collections.singletonList("dd/MM/yyyyy")); @@ -125,7 +125,7 @@ public void testParseTimezone() throws Exception { public void testParseInvalidTimezone() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("match_formats", Collections.singletonList("dd/MM/yyyyy")); config.put("timezone", "invalid_timezone"); @@ -140,7 +140,7 @@ public void testParseInvalidTimezone() throws Exception { public void testParseMatchFormats() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("formats", Arrays.asList("dd/MM/yyyy", "dd-MM-yyyy")); @@ -151,7 +151,7 @@ public void testParseMatchFormats() throws Exception { public void testParseMatchFormatsFailure() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("formats", "dd/MM/yyyy"); @@ -166,8 +166,8 @@ public void testParseMatchFormatsFailure() throws Exception { public void testParseTargetField() throws Exception { DateProcessor.Factory factory = new DateProcessor.Factory(); Map config = new HashMap<>(); - String sourceField = randomAsciiOfLengthBetween(1, 10); - String targetField = randomAsciiOfLengthBetween(1, 10); + String sourceField = randomAlphaOfLengthBetween(1, 10); + String targetField = randomAlphaOfLengthBetween(1, 10); config.put("field", sourceField); config.put("target_field", targetField); config.put("formats", Arrays.asList("dd/MM/yyyy", "dd-MM-yyyy")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java index 8ac5a56abb0b6..d92f2e84be135 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java @@ -38,7 +38,7 @@ public class DateProcessorTests extends ESTestCase { public void testJodaPattern() { - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ENGLISH, + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ENGLISH, "date_as_string", Collections.singletonList("yyyy dd MM hh:mm:ss"), "date_as_date"); Map document = new HashMap<>(); document.put("date_as_string", "2010 12 06 11:05:15"); @@ -52,7 +52,7 @@ public void testJodaPatternMultipleFormats() { matchFormats.add("yyyy dd MM"); matchFormats.add("dd/MM/yyyy"); matchFormats.add("dd-MM-yyyy"); - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ENGLISH, + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ENGLISH, "date_as_string", matchFormats, "date_as_date"); Map document = new HashMap<>(); @@ -86,7 +86,7 @@ public void testJodaPatternMultipleFormats() { public void testInvalidJodaPattern() { try { - new DateProcessor(randomAsciiOfLength(10), DateTimeZone.UTC, randomLocale(random()), + new DateProcessor(randomAlphaOfLength(10), DateTimeZone.UTC, randomLocale(random()), "date_as_string", Collections.singletonList("invalid pattern"), "date_as_date"); fail("date processor initialization should have failed"); } catch(IllegalArgumentException e) { @@ -95,7 +95,7 @@ public void testInvalidJodaPattern() { } public void testJodaPatternLocale() { - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ITALIAN, + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ITALIAN, "date_as_string", Collections.singletonList("yyyy dd MMM"), "date_as_date"); Map document = new HashMap<>(); document.put("date_as_string", "2010 12 giugno"); @@ -105,7 +105,7 @@ public void testJodaPatternLocale() { } public void testJodaPatternDefaultYear() { - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ENGLISH, + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.forID("Europe/Amsterdam"), Locale.ENGLISH, "date_as_string", Collections.singletonList("dd/MM"), "date_as_date"); Map document = new HashMap<>(); document.put("date_as_string", "12/06"); @@ -116,7 +116,7 @@ public void testJodaPatternDefaultYear() { } public void testTAI64N() { - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.forOffsetHours(2), randomLocale(random()), + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.forOffsetHours(2), randomLocale(random()), "date_as_string", Collections.singletonList("TAI64N"), "date_as_date"); Map document = new HashMap<>(); String dateAsString = (randomBoolean() ? "@" : "") + "4000000050d506482dbdf024"; @@ -127,7 +127,7 @@ public void testTAI64N() { } public void testUnixMs() { - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.UTC, randomLocale(random()), + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.UTC, randomLocale(random()), "date_as_string", Collections.singletonList("UNIX_MS"), "date_as_date"); Map document = new HashMap<>(); document.put("date_as_string", "1000500"); @@ -137,7 +137,7 @@ public void testUnixMs() { } public void testUnix() { - DateProcessor dateProcessor = new DateProcessor(randomAsciiOfLength(10), DateTimeZone.UTC, randomLocale(random()), + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), DateTimeZone.UTC, randomLocale(random()), "date_as_string", Collections.singletonList("UNIX"), "date_as_date"); Map document = new HashMap<>(); document.put("date_as_string", "1000.5"); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java index 217a15cf5b395..ab0acad4aea1f 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorFactoryTests.java @@ -43,7 +43,7 @@ public void init() { public void testCreate() throws Exception { Map config = new HashMap<>(); config.put("message", "error"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); FailProcessor failProcessor = factory.create(null, processorTag, config); assertThat(failProcessor.getTag(), equalTo(processorTag)); assertThat(failProcessor.getMessage().execute(Collections.emptyMap()), equalTo("error")); @@ -63,7 +63,7 @@ public void testInvalidMustacheTemplate() throws Exception { FailProcessor.Factory factory = new FailProcessor.Factory(TestTemplateService.instance(true)); Map config = new HashMap<>(); config.put("message", "error"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("java.lang.RuntimeException: could not compile script")); assertThat(exception.getHeader("processor_tag").get(0), equalTo(processorTag)); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorTests.java index 76685854d21eb..c05323c12e3a6 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/FailProcessorTests.java @@ -31,8 +31,8 @@ public class FailProcessorTests extends ESTestCase { public void test() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); - String message = randomAsciiOfLength(10); - Processor processor = new FailProcessor(randomAsciiOfLength(10), new TestTemplateService.MockTemplate(message)); + String message = randomAlphaOfLength(10); + Processor processor = new FailProcessor(randomAlphaOfLength(10), new TestTemplateService.MockTemplate(message)); try { processor.execute(ingestDocument); fail("fail processor should throw an exception"); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java index 37aa8adca9aaf..4cac94cd5b571 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorFactoryTests.java @@ -38,7 +38,7 @@ public void testBuild() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); config.put("patterns", Collections.singletonList("(?\\w+)")); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); GrokProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); assertThat(processor.getMatchField(), equalTo("_field")); @@ -53,7 +53,7 @@ public void testBuildWithIgnoreMissing() throws Exception { config.put("field", "_field"); config.put("patterns", Collections.singletonList("(?\\w+)")); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); GrokProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); assertThat(processor.getMatchField(), equalTo("_field")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorTests.java index 24d775db68210..86bc780b75e0b 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GrokProcessorTests.java @@ -38,7 +38,7 @@ public void testMatch() throws Exception { String fieldName = RandomDocumentPicks.randomFieldName(random()); IngestDocument doc = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); doc.setFieldValue(fieldName, "1"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, false); processor.execute(doc); assertThat(doc.getFieldValue("one", String.class), equalTo("1")); @@ -48,7 +48,7 @@ public void testNoMatch() { String fieldName = RandomDocumentPicks.randomFieldName(random()); IngestDocument doc = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); doc.setFieldValue(fieldName, "23"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, false); Exception e = expectThrows(Exception.class, () -> processor.execute(doc)); assertThat(e.getMessage(), equalTo("Provided Grok expressions do not match field value: [23]")); @@ -59,7 +59,7 @@ public void testMatchWithoutCaptures() throws Exception { IngestDocument originalDoc = new IngestDocument(new HashMap<>(), new HashMap<>()); originalDoc.setFieldValue(fieldName, fieldName); IngestDocument doc = new IngestDocument(originalDoc); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.emptyMap(), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.emptyMap(), Collections.singletonList(fieldName), fieldName, false, false); processor.execute(doc); assertThat(doc, equalTo(originalDoc)); @@ -69,7 +69,7 @@ public void testNullField() { String fieldName = RandomDocumentPicks.randomFieldName(random()); IngestDocument doc = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); doc.setFieldValue(fieldName, null); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, false); Exception e = expectThrows(Exception.class, () -> processor.execute(doc)); assertThat(e.getMessage(), equalTo("field [" + fieldName + "] is null, cannot process it.")); @@ -80,7 +80,7 @@ public void testNullFieldWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); originalIngestDocument.setFieldValue(fieldName, null); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); @@ -90,7 +90,7 @@ public void testNotStringField() { String fieldName = RandomDocumentPicks.randomFieldName(random()); IngestDocument doc = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); doc.setFieldValue(fieldName, 1); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, false); Exception e = expectThrows(Exception.class, () -> processor.execute(doc)); assertThat(e.getMessage(), equalTo("field [" + fieldName + "] of type [java.lang.Integer] cannot be cast to [java.lang.String]")); @@ -100,7 +100,7 @@ public void testNotStringFieldWithIgnoreMissing() { String fieldName = RandomDocumentPicks.randomFieldName(random()); IngestDocument doc = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); doc.setFieldValue(fieldName, 1); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, true); Exception e = expectThrows(Exception.class, () -> processor.execute(doc)); assertThat(e.getMessage(), equalTo("field [" + fieldName + "] of type [java.lang.Integer] cannot be cast to [java.lang.String]")); @@ -109,7 +109,7 @@ public void testNotStringFieldWithIgnoreMissing() { public void testMissingField() { String fieldName = "foo.bar"; IngestDocument doc = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, false); Exception e = expectThrows(Exception.class, () -> processor.execute(doc)); assertThat(e.getMessage(), equalTo("field [foo] not present as part of path [foo.bar]")); @@ -119,7 +119,7 @@ public void testMissingFieldWithIgnoreMissing() throws Exception { String fieldName = "foo.bar"; IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), Collections.singletonMap("ONE", "1"), + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), Collections.singletonMap("ONE", "1"), Collections.singletonList("%{ONE:one}"), fieldName, false, true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); @@ -133,7 +133,7 @@ public void testMultiplePatternsWithMatchReturn() throws Exception { patternBank.put("ONE", "1"); patternBank.put("TWO", "2"); patternBank.put("THREE", "3"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), patternBank, + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), patternBank, Arrays.asList("%{ONE:one}", "%{TWO:two}", "%{THREE:three}"), fieldName, false, false); processor.execute(doc); assertThat(doc.hasField("one"), equalTo(false)); @@ -149,7 +149,7 @@ public void testSetMetadata() throws Exception { patternBank.put("ONE", "1"); patternBank.put("TWO", "2"); patternBank.put("THREE", "3"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), patternBank, + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), patternBank, Arrays.asList("%{ONE:one}", "%{TWO:two}", "%{THREE:three}"), fieldName, true, false); processor.execute(doc); assertThat(doc.hasField("one"), equalTo(false)); @@ -164,7 +164,7 @@ public void testTraceWithOnePattern() throws Exception { doc.setFieldValue(fieldName, "first1"); Map patternBank = new HashMap<>(); patternBank.put("ONE", "1"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), patternBank, + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), patternBank, Arrays.asList("%{ONE:one}"), fieldName, true, false); processor.execute(doc); assertThat(doc.hasField("one"), equalTo(true)); @@ -195,7 +195,7 @@ public void testCombineSamePatternNameAcrossPatterns() throws Exception { patternBank.put("ONE", "1"); patternBank.put("TWO", "2"); patternBank.put("THREE", "3"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), patternBank, + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), patternBank, Arrays.asList("%{ONE:first}-%{TWO:second}", "%{ONE:first}-%{THREE:second}"), fieldName, randomBoolean(), randomBoolean()); processor.execute(doc); assertThat(doc.getFieldValue("first", String.class), equalTo("1")); @@ -208,7 +208,7 @@ public void testFirstWinNamedCapture() throws Exception { doc.setFieldValue(fieldName, "12"); Map patternBank = new HashMap<>(); patternBank.put("ONETWO", "1|2"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), patternBank, + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), patternBank, Collections.singletonList("%{ONETWO:first}%{ONETWO:first}"), fieldName, randomBoolean(), randomBoolean()); processor.execute(doc); assertThat(doc.getFieldValue("first", String.class), equalTo("1")); @@ -221,7 +221,7 @@ public void testUnmatchedNamesNotIncludedInDocument() throws Exception { Map patternBank = new HashMap<>(); patternBank.put("ONETWO", "1|2"); patternBank.put("THREE", "3"); - GrokProcessor processor = new GrokProcessor(randomAsciiOfLength(10), patternBank, + GrokProcessor processor = new GrokProcessor(randomAlphaOfLength(10), patternBank, Collections.singletonList("%{ONETWO:first}|%{THREE:second}"), fieldName, randomBoolean(), randomBoolean()); processor.execute(doc); assertFalse(doc.hasField("first")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java index 51e246c67e913..f7947c2162138 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorFactoryTests.java @@ -36,7 +36,7 @@ public void testCreate() throws Exception { config.put("field", "field1"); config.put("pattern", "\\."); config.put("replacement", "-"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); GsubProcessor gsubProcessor = factory.create(null, processorTag, config); assertThat(gsubProcessor.getTag(), equalTo(processorTag)); assertThat(gsubProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorTests.java index 20dc5b8c8dec9..d791d34722a3e 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/GsubProcessorTests.java @@ -36,7 +36,7 @@ public class GsubProcessorTests extends ESTestCase { public void testGsub() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "127.0.0.1"); - Processor processor = new GsubProcessor(randomAsciiOfLength(10), fieldName, Pattern.compile("\\."), "-"); + Processor processor = new GsubProcessor(randomAlphaOfLength(10), fieldName, Pattern.compile("\\."), "-"); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, String.class), equalTo("127-0-0-1")); } @@ -45,7 +45,7 @@ public void testGsubNotAStringValue() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); ingestDocument.setFieldValue(fieldName, 123); - Processor processor = new GsubProcessor(randomAsciiOfLength(10), fieldName, Pattern.compile("\\."), "-"); + Processor processor = new GsubProcessor(randomAlphaOfLength(10), fieldName, Pattern.compile("\\."), "-"); try { processor.execute(ingestDocument); fail("processor execution should have failed"); @@ -58,7 +58,7 @@ public void testGsubNotAStringValue() throws Exception { public void testGsubFieldNotFound() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new GsubProcessor(randomAsciiOfLength(10), fieldName, Pattern.compile("\\."), "-"); + Processor processor = new GsubProcessor(randomAlphaOfLength(10), fieldName, Pattern.compile("\\."), "-"); try { processor.execute(ingestDocument); fail("processor execution should have failed"); @@ -69,7 +69,7 @@ public void testGsubFieldNotFound() throws Exception { public void testGsubNullValue() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null)); - Processor processor = new GsubProcessor(randomAsciiOfLength(10), "field", Pattern.compile("\\."), "-"); + Processor processor = new GsubProcessor(randomAlphaOfLength(10), "field", Pattern.compile("\\."), "-"); try { processor.execute(ingestDocument); fail("processor execution should have failed"); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java index 68b2daecb4a48..0eda639afceee 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorFactoryTests.java @@ -34,7 +34,7 @@ public void testCreate() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("separator", "-"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); JoinProcessor joinProcessor = factory.create(null, processorTag, config); assertThat(joinProcessor.getTag(), equalTo(processorTag)); assertThat(joinProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorTests.java index 078d63657097b..b7ef9d675c2e6 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JoinProcessorTests.java @@ -43,7 +43,7 @@ public void testJoinStrings() throws Exception { List fieldValue = new ArrayList<>(numItems); String expectedResult = ""; for (int j = 0; j < numItems; j++) { - String value = randomAsciiOfLengthBetween(1, 10); + String value = randomAlphaOfLengthBetween(1, 10); fieldValue.add(value); expectedResult += value; if (j < numItems - 1) { @@ -51,7 +51,7 @@ public void testJoinStrings() throws Exception { } } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new JoinProcessor(randomAsciiOfLength(10), fieldName, separator); + Processor processor = new JoinProcessor(randomAlphaOfLength(10), fieldName, separator); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, String.class), equalTo(expectedResult)); } @@ -71,7 +71,7 @@ public void testJoinIntegers() throws Exception { } } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new JoinProcessor(randomAsciiOfLength(10), fieldName, separator); + Processor processor = new JoinProcessor(randomAlphaOfLength(10), fieldName, separator); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, String.class), equalTo(expectedResult)); } @@ -79,8 +79,8 @@ public void testJoinIntegers() throws Exception { public void testJoinNonListField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - ingestDocument.setFieldValue(fieldName, randomAsciiOfLengthBetween(1, 10)); - Processor processor = new JoinProcessor(randomAsciiOfLength(10), fieldName, "-"); + ingestDocument.setFieldValue(fieldName, randomAlphaOfLengthBetween(1, 10)); + Processor processor = new JoinProcessor(randomAlphaOfLength(10), fieldName, "-"); try { processor.execute(ingestDocument); } catch(IllegalArgumentException e) { @@ -91,7 +91,7 @@ public void testJoinNonListField() throws Exception { public void testJoinNonExistingField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new JoinProcessor(randomAsciiOfLength(10), fieldName, "-"); + Processor processor = new JoinProcessor(randomAlphaOfLength(10), fieldName, "-"); try { processor.execute(ingestDocument); } catch(IllegalArgumentException e) { @@ -101,7 +101,7 @@ public void testJoinNonExistingField() throws Exception { public void testJoinNullValue() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null)); - Processor processor = new JoinProcessor(randomAsciiOfLength(10), "field", "-"); + Processor processor = new JoinProcessor(randomAlphaOfLength(10), "field", "-"); try { processor.execute(ingestDocument); } catch(IllegalArgumentException e) { diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java index 456b31f8720b1..66f163a31eb8f 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorFactoryTests.java @@ -21,11 +21,8 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.test.ESTestCase; -import org.junit.Before; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -36,9 +33,9 @@ public class JsonProcessorFactoryTests extends ESTestCase { private static final JsonProcessor.Factory FACTORY = new JsonProcessor.Factory(); public void testCreate() throws Exception { - String processorTag = randomAsciiOfLength(10); - String randomField = randomAsciiOfLength(10); - String randomTargetField = randomAsciiOfLength(5); + String processorTag = randomAlphaOfLength(10); + String randomField = randomAlphaOfLength(10); + String randomTargetField = randomAlphaOfLength(5); Map config = new HashMap<>(); config.put("field", randomField); config.put("target_field", randomTargetField); @@ -49,8 +46,8 @@ public void testCreate() throws Exception { } public void testCreateWithAddToRoot() throws Exception { - String processorTag = randomAsciiOfLength(10); - String randomField = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); + String randomField = randomAlphaOfLength(10); Map config = new HashMap<>(); config.put("field", randomField); config.put("add_to_root", true); @@ -62,8 +59,8 @@ public void testCreateWithAddToRoot() throws Exception { } public void testCreateWithDefaultTarget() throws Exception { - String processorTag = randomAsciiOfLength(10); - String randomField = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); + String randomField = randomAlphaOfLength(10); Map config = new HashMap<>(); config.put("field", randomField); JsonProcessor jsonProcessor = FACTORY.create(null, processorTag, config); @@ -74,21 +71,21 @@ public void testCreateWithDefaultTarget() throws Exception { public void testCreateWithMissingField() throws Exception { Map config = new HashMap<>(); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchParseException.class, () -> FACTORY.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("[field] required property is missing")); } public void testCreateWithBothTargetFieldAndAddToRoot() throws Exception { - String randomField = randomAsciiOfLength(10); - String randomTargetField = randomAsciiOfLength(5); + String randomField = randomAlphaOfLength(10); + String randomTargetField = randomAlphaOfLength(5); Map config = new HashMap<>(); config.put("field", randomField); config.put("target_field", randomTargetField); config.put("add_to_root", true); ElasticsearchException exception = expectThrows(ElasticsearchParseException.class, - () -> FACTORY.create(null, randomAsciiOfLength(10), config)); + () -> FACTORY.create(null, randomAlphaOfLength(10), config)); assertThat(exception.getMessage(), equalTo("[target_field] Cannot set a target field while also setting `add_to_root` to true")); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java index 5d087ebbc12f6..66ffb87e8da14 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java @@ -36,9 +36,9 @@ public class JsonProcessorTests extends ESTestCase { @SuppressWarnings("unchecked") public void testExecute() throws Exception { - String processorTag = randomAsciiOfLength(3); - String randomField = randomAsciiOfLength(3); - String randomTargetField = randomAsciiOfLength(2); + String processorTag = randomAlphaOfLength(3); + String randomField = randomAlphaOfLength(3); + String randomTargetField = randomAlphaOfLength(2); JsonProcessor jsonProcessor = new JsonProcessor(processorTag, randomField, randomTargetField, false); Map document = new HashMap<>(); @@ -76,8 +76,8 @@ public void testFieldMissing() { @SuppressWarnings("unchecked") public void testAddToRoot() throws Exception { - String processorTag = randomAsciiOfLength(3); - String randomTargetField = randomAsciiOfLength(2); + String processorTag = randomAlphaOfLength(3); + String randomTargetField = randomAlphaOfLength(2); JsonProcessor jsonProcessor = new JsonProcessor(processorTag, "a", randomTargetField, true); Map document = new HashMap<>(); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java index 4dc4e08265502..8c1e8a7149203 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorFactoryTests.java @@ -39,7 +39,7 @@ public void testCreateWithDefaults() throws Exception { config.put("field", "field1"); config.put("field_split", "&"); config.put("value_split", "="); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); KeyValueProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); assertThat(processor.getField(), equalTo("field1")); @@ -59,7 +59,7 @@ public void testCreateWithAllFieldsSet() throws Exception { config.put("target_field", "target"); config.put("include_keys", Arrays.asList("a", "b")); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); KeyValueProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); assertThat(processor.getField(), equalTo("field1")); @@ -73,7 +73,7 @@ public void testCreateWithAllFieldsSet() throws Exception { public void testCreateWithMissingField() { KeyValueProcessor.Factory factory = new KeyValueProcessor.Factory(); Map config = new HashMap<>(); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("[field] required property is missing")); @@ -83,7 +83,7 @@ public void testCreateWithMissingFieldSplit() { KeyValueProcessor.Factory factory = new KeyValueProcessor.Factory(); Map config = new HashMap<>(); config.put("field", "field1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("[field_split] required property is missing")); @@ -94,7 +94,7 @@ public void testCreateWithMissingValueSplit() { Map config = new HashMap<>(); config.put("field", "field1"); config.put("field_split", "&"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("[value_split] required property is missing")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorTests.java index f5db4be143596..1c7103d35b44a 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/KeyValueProcessorTests.java @@ -36,7 +36,7 @@ public class KeyValueProcessorTests extends ESTestCase { public void test() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "first=hello&second=world&second=universe"); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), fieldName, "&", "=", null, "target", false); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), fieldName, "&", "=", null, "target", false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("target.first", String.class), equalTo("hello")); assertThat(ingestDocument.getFieldValue("target.second", List.class), equalTo(Arrays.asList("world", "universe"))); @@ -45,7 +45,7 @@ public void test() throws Exception { public void testRootTarget() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); ingestDocument.setFieldValue("myField", "first=hello&second=world&second=universe"); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), "myField", "&", "=", null, null, false); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), "myField", "&", "=", null, null, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("first", String.class), equalTo("hello")); assertThat(ingestDocument.getFieldValue("second", List.class), equalTo(Arrays.asList("world", "universe"))); @@ -54,7 +54,7 @@ public void testRootTarget() throws Exception { public void testKeySameAsSourceField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); ingestDocument.setFieldValue("first", "first=hello"); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), "first", "&", "=", null, null, false); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), "first", "&", "=", null, null, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("first", List.class), equalTo(Arrays.asList("first=hello", "hello"))); } @@ -62,7 +62,7 @@ public void testKeySameAsSourceField() throws Exception { public void testIncludeKeys() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "first=hello&second=world&second=universe"); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), fieldName, "&", "=", + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), fieldName, "&", "=", Collections.singletonList("first"), "target", false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("target.first", String.class), equalTo("hello")); @@ -71,7 +71,7 @@ public void testIncludeKeys() throws Exception { public void testMissingField() { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), "unknown", "&", "=", null, "target", false); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), "unknown", "&", "=", null, "target", false); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> processor.execute(ingestDocument)); assertThat(exception.getMessage(), equalTo("field [unknown] not present as part of path [unknown]")); } @@ -81,7 +81,7 @@ public void testNullValueWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap(fieldName, null)); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), fieldName, "", "", null, "target", true); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), fieldName, "", "", null, "target", true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -89,7 +89,7 @@ public void testNullValueWithIgnoreMissing() throws Exception { public void testNonExistentWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), "unknown", "", "", null, "target", true); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), "unknown", "", "", null, "target", true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -97,7 +97,7 @@ public void testNonExistentWithIgnoreMissing() throws Exception { public void testFailFieldSplitMatch() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "first=hello|second=world|second=universe"); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), fieldName, "&", "=", null, "target", false); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), fieldName, "&", "=", null, "target", false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("target.first", String.class), equalTo("hello|second=world|second=universe")); assertFalse(ingestDocument.hasField("target.second")); @@ -105,7 +105,7 @@ public void testFailFieldSplitMatch() throws Exception { public void testFailValueSplitMatch() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("foo", "bar")); - Processor processor = new KeyValueProcessor(randomAsciiOfLength(10), "foo", "&", "=", null, "target", false); + Processor processor = new KeyValueProcessor(randomAlphaOfLength(10), "foo", "&", "=", null, "target", false); Exception exception = expectThrows(IllegalArgumentException.class, () -> processor.execute(ingestDocument)); assertThat(exception.getMessage(), equalTo("field [foo] does not contain value_split [=]")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorFactoryTests.java index 2c80071b80302..dc12556df4dca 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorFactoryTests.java @@ -34,7 +34,7 @@ public void testCreate() throws Exception { LowercaseProcessor.Factory factory = new LowercaseProcessor.Factory(); Map config = new HashMap<>(); config.put("field", "field1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); LowercaseProcessor uppercaseProcessor = (LowercaseProcessor)factory.create(null, processorTag, config); assertThat(uppercaseProcessor.getTag(), equalTo(processorTag)); assertThat(uppercaseProcessor.getField(), equalTo("field1")); @@ -46,7 +46,7 @@ public void testCreateWithIgnoreMissing() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); LowercaseProcessor uppercaseProcessor = (LowercaseProcessor)factory.create(null, processorTag, config); assertThat(uppercaseProcessor.getTag(), equalTo(processorTag)); assertThat(uppercaseProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorTests.java index 560a949f1565c..77e26d3eb963b 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/LowercaseProcessorTests.java @@ -24,7 +24,7 @@ public class LowercaseProcessorTests extends AbstractStringProcessorTestCase { @Override protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing) { - return new LowercaseProcessor(randomAsciiOfLength(10), field, ignoreMissing); + return new LowercaseProcessor(randomAlphaOfLength(10), field, ignoreMissing); } @Override diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java index 71e878744d5f0..d53e5ff1cd059 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorFactoryTests.java @@ -43,7 +43,7 @@ public void init() { public void testCreate() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); RemoveProcessor removeProcessor = factory.create(null, processorTag, config); assertThat(removeProcessor.getTag(), equalTo(processorTag)); assertThat(removeProcessor.getField().execute(Collections.emptyMap()), equalTo("field1")); @@ -63,7 +63,7 @@ public void testInvalidMustacheTemplate() throws Exception { RemoveProcessor.Factory factory = new RemoveProcessor.Factory(TestTemplateService.instance(true)); Map config = new HashMap<>(); config.put("field", "field1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("java.lang.RuntimeException: could not compile script")); assertThat(exception.getHeader("processor_tag").get(0), equalTo(processorTag)); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorTests.java index fd569567d1af9..60748a520313c 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RemoveProcessorTests.java @@ -35,7 +35,7 @@ public class RemoveProcessorTests extends ESTestCase { public void testRemoveFields() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String field = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument); - Processor processor = new RemoveProcessor(randomAsciiOfLength(10), new TestTemplateService.MockTemplate(field)); + Processor processor = new RemoveProcessor(randomAlphaOfLength(10), new TestTemplateService.MockTemplate(field)); processor.execute(ingestDocument); assertThat(ingestDocument.hasField(field), equalTo(false)); } @@ -43,7 +43,7 @@ public void testRemoveFields() throws Exception { public void testRemoveNonExistingField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new RemoveProcessor(randomAsciiOfLength(10), new TestTemplateService.MockTemplate(fieldName)); + Processor processor = new RemoveProcessor(randomAlphaOfLength(10), new TestTemplateService.MockTemplate(fieldName)); try { processor.execute(ingestDocument); fail("remove field should have failed"); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java index b631b78bf0390..1eaac36a64cca 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorFactoryTests.java @@ -34,7 +34,7 @@ public void testCreate() throws Exception { Map config = new HashMap<>(); config.put("field", "old_field"); config.put("target_field", "new_field"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); RenameProcessor renameProcessor = factory.create(null, processorTag, config); assertThat(renameProcessor.getTag(), equalTo(processorTag)); assertThat(renameProcessor.getField(), equalTo("old_field")); @@ -48,7 +48,7 @@ public void testCreateWithIgnoreMissing() throws Exception { config.put("field", "old_field"); config.put("target_field", "new_field"); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); RenameProcessor renameProcessor = factory.create(null, processorTag, config); assertThat(renameProcessor.getTag(), equalTo(processorTag)); assertThat(renameProcessor.getField(), equalTo("old_field")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java index 9fae812822b70..758e5eb997297 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RenameProcessorTests.java @@ -45,7 +45,7 @@ public void testRename() throws Exception { do { newFieldName = RandomDocumentPicks.randomFieldName(random()); } while (RandomDocumentPicks.canAddField(newFieldName, ingestDocument) == false || newFieldName.equals(fieldName)); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), fieldName, newFieldName, false); + Processor processor = new RenameProcessor(randomAlphaOfLength(10), fieldName, newFieldName, false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(newFieldName, Object.class), equalTo(fieldValue)); } @@ -63,7 +63,7 @@ public void testRenameArrayElement() throws Exception { document.put("one", one); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), "list.0", "item", false); + Processor processor = new RenameProcessor(randomAlphaOfLength(10), "list.0", "item", false); processor.execute(ingestDocument); Object actualObject = ingestDocument.getSourceAndMetadata().get("list"); assertThat(actualObject, instanceOf(List.class)); @@ -76,7 +76,7 @@ public void testRenameArrayElement() throws Exception { assertThat(actualObject, instanceOf(String.class)); assertThat(actualObject, equalTo("item1")); - processor = new RenameProcessor(randomAsciiOfLength(10), "list.0", "list.3", false); + processor = new RenameProcessor(randomAlphaOfLength(10), "list.0", "list.3", false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -91,7 +91,7 @@ public void testRenameArrayElement() throws Exception { public void testRenameNonExistingField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), fieldName, + Processor processor = new RenameProcessor(randomAlphaOfLength(10), fieldName, RandomDocumentPicks.randomFieldName(random()), false); try { processor.execute(ingestDocument); @@ -105,7 +105,7 @@ public void testRenameNonExistingFieldWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); String fieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), fieldName, + Processor processor = new RenameProcessor(randomAlphaOfLength(10), fieldName, RandomDocumentPicks.randomFieldName(random()), true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); @@ -114,7 +114,7 @@ public void testRenameNonExistingFieldWithIgnoreMissing() throws Exception { public void testRenameNewFieldAlreadyExists() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String fieldName = RandomDocumentPicks.randomExistingFieldName(random(), ingestDocument); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), RandomDocumentPicks.randomExistingFieldName( + Processor processor = new RenameProcessor(randomAlphaOfLength(10), RandomDocumentPicks.randomExistingFieldName( random(), ingestDocument), fieldName, false); try { processor.execute(ingestDocument); @@ -129,7 +129,7 @@ public void testRenameExistingFieldNullValue() throws Exception { String fieldName = RandomDocumentPicks.randomFieldName(random()); ingestDocument.setFieldValue(fieldName, null); String newFieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), fieldName, newFieldName, false); + Processor processor = new RenameProcessor(randomAlphaOfLength(10), fieldName, newFieldName, false); processor.execute(ingestDocument); assertThat(ingestDocument.hasField(fieldName), equalTo(false)); assertThat(ingestDocument.hasField(newFieldName), equalTo(true)); @@ -149,7 +149,7 @@ public Object put(String key, Object value) { source.put("list", Collections.singletonList("item")); IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap()); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), "list", "new_field", false); + Processor processor = new RenameProcessor(randomAlphaOfLength(10), "list", "new_field", false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -173,7 +173,7 @@ public Object remove(Object key) { source.put("list", Collections.singletonList("item")); IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap()); - Processor processor = new RenameProcessor(randomAsciiOfLength(10), "list", "new_field", false); + Processor processor = new RenameProcessor(randomAlphaOfLength(10), "list", "new_field", false); try { processor.execute(ingestDocument); fail("processor execute should have failed"); @@ -188,12 +188,12 @@ public void testRenameLeafIntoBranch() throws Exception { Map source = new HashMap<>(); source.put("foo", "bar"); IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap()); - Processor processor1 = new RenameProcessor(randomAsciiOfLength(10), "foo", "foo.bar", false); + Processor processor1 = new RenameProcessor(randomAlphaOfLength(10), "foo", "foo.bar", false); processor1.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("foo", Map.class), equalTo(Collections.singletonMap("bar", "bar"))); assertThat(ingestDocument.getFieldValue("foo.bar", String.class), equalTo("bar")); - Processor processor2 = new RenameProcessor(randomAsciiOfLength(10), "foo.bar", "foo.bar.baz", false); + Processor processor2 = new RenameProcessor(randomAlphaOfLength(10), "foo.bar", "foo.bar.baz", false); processor2.execute(ingestDocument); assertThat(ingestDocument.getFieldValue("foo", Map.class), equalTo(Collections.singletonMap("bar", Collections.singletonMap("baz", "bar")))); @@ -201,7 +201,7 @@ public void testRenameLeafIntoBranch() throws Exception { assertThat(ingestDocument.getFieldValue("foo.bar.baz", String.class), equalTo("bar")); // for fun lets try to restore it (which don't allow today) - Processor processor3 = new RenameProcessor(randomAsciiOfLength(10), "foo.bar.baz", "foo", false); + Processor processor3 = new RenameProcessor(randomAlphaOfLength(10), "foo.bar.baz", "foo", false); Exception e = expectThrows(IllegalArgumentException.class, () -> processor3.execute(ingestDocument)); assertThat(e.getMessage(), equalTo("field [foo] already exists")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java index 60b4297946607..b3ee7a23a5d6c 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorFactoryTests.java @@ -57,7 +57,7 @@ public void testFactoryValidationWithDefaultLang() throws Exception { Map configMap = new HashMap<>(); String randomType = randomFrom("id", "inline", "file"); configMap.put(randomType, "foo"); - ScriptProcessor processor = factory.create(null, randomAsciiOfLength(10), configMap); + ScriptProcessor processor = factory.create(null, randomAlphaOfLength(10), configMap); assertThat(processor.getScript().getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG)); assertThat(processor.getScript().getType().toString(), equalTo(ingestScriptParamToType.get(randomType))); assertThat(processor.getScript().getParams(), equalTo(Collections.emptyMap())); @@ -66,10 +66,10 @@ public void testFactoryValidationWithDefaultLang() throws Exception { public void testFactoryValidationWithParams() throws Exception { Map configMap = new HashMap<>(); String randomType = randomFrom("id", "inline", "file"); - Map randomParams = Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10)); + Map randomParams = Collections.singletonMap(randomAlphaOfLength(10), randomAlphaOfLength(10)); configMap.put(randomType, "foo"); configMap.put("params", randomParams); - ScriptProcessor processor = factory.create(null, randomAsciiOfLength(10), configMap); + ScriptProcessor processor = factory.create(null, randomAlphaOfLength(10), configMap); assertThat(processor.getScript().getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG)); assertThat(processor.getScript().getType().toString(), equalTo(ingestScriptParamToType.get(randomType))); assertThat(processor.getScript().getParams(), equalTo(randomParams)); @@ -88,7 +88,7 @@ public void testFactoryValidationForMultipleScriptingTypes() throws Exception { configMap.put("lang", "mockscript"); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> factory.create(null, randomAsciiOfLength(10), configMap)); + () -> factory.create(null, randomAlphaOfLength(10), configMap)); assertThat(exception.getMessage(), is("Only one of [file], [id], or [inline] may be configured")); } @@ -97,7 +97,7 @@ public void testFactoryValidationAtLeastOneScriptingType() throws Exception { configMap.put("lang", "mockscript"); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> factory.create(null, randomAsciiOfLength(10), configMap)); + () -> factory.create(null, randomAlphaOfLength(10), configMap)); assertThat(exception.getMessage(), is("Need [file], [id], or [inline] parameter to refer to scripts")); } @@ -115,7 +115,7 @@ public void testFactoryInvalidateWithInvalidCompiledScript() throws Exception { configMap.put(randomType, "my_script"); ElasticsearchException exception = expectThrows(ElasticsearchException.class, - () -> factory.create(null, randomAsciiOfLength(10), configMap)); + () -> factory.create(null, randomAlphaOfLength(10), configMap)); assertThat(exception.getMessage(), is("compile-time exception")); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorTests.java index 8b16fdb7e61d4..94430622d1a46 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ScriptProcessorTests.java @@ -58,7 +58,7 @@ public void testScripting() throws Exception { return null; }).when(executableScript).run(); - ScriptProcessor processor = new ScriptProcessor(randomAsciiOfLength(10), script, scriptService); + ScriptProcessor processor = new ScriptProcessor(randomAlphaOfLength(10), script, scriptService); processor.execute(ingestDocument); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java index 45f144e330502..57d0b7f7b9371 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java @@ -44,7 +44,7 @@ public void testCreate() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("value", "value1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); SetProcessor setProcessor = factory.create(null, processorTag, config); assertThat(setProcessor.getTag(), equalTo(processorTag)); assertThat(setProcessor.getField().execute(Collections.emptyMap()), equalTo("field1")); @@ -58,7 +58,7 @@ public void testCreateWithOverride() throws Exception { config.put("field", "field1"); config.put("value", "value1"); config.put("override", overrideEnabled); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); SetProcessor setProcessor = factory.create(null, processorTag, config); assertThat(setProcessor.getTag(), equalTo(processorTag)); assertThat(setProcessor.getField().execute(Collections.emptyMap()), equalTo("field1")); @@ -105,7 +105,7 @@ public void testInvalidMustacheTemplate() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("value", "value1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> factory.create(null, processorTag, config)); assertThat(exception.getMessage(), equalTo("java.lang.RuntimeException: could not compile script")); assertThat(exception.getHeader("processor_tag").get(0), equalTo(processorTag)); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorTests.java index 9ef8fa44ac97f..d5a693b2bc142 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorTests.java @@ -110,7 +110,7 @@ public void testSetMetadata() throws Exception { private static Processor createSetProcessor(String fieldName, Object fieldValue, boolean overrideEnabled) { TemplateService templateService = TestTemplateService.instance(); - return new SetProcessor(randomAsciiOfLength(10), templateService.compile(fieldName), + return new SetProcessor(randomAlphaOfLength(10), templateService.compile(fieldName), ValueSource.wrap(fieldValue, templateService), overrideEnabled); } } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java index 97352109e2cb0..6b878b00a5a73 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SortProcessorTests.java @@ -42,7 +42,7 @@ public void testSortStrings() throws Exception { List fieldValue = new ArrayList<>(numItems); List expectedResult = new ArrayList<>(numItems); for (int j = 0; j < numItems; j++) { - String value = randomAsciiOfLengthBetween(1, 10); + String value = randomAlphaOfLengthBetween(1, 10); fieldValue.add(value); expectedResult.add(value); } @@ -54,7 +54,7 @@ public void testSortStrings() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -68,7 +68,7 @@ public void testSortIntegersNonRandom() throws Exception { Collections.shuffle(fieldValue, random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, SortOrder.ASCENDING); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, SortOrder.ASCENDING); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, List.class).toArray(), equalTo(expectedResult)); } @@ -91,7 +91,7 @@ public void testSortIntegers() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -114,7 +114,7 @@ public void testSortShorts() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -137,7 +137,7 @@ public void testSortDoubles() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -160,7 +160,7 @@ public void testSortFloats() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -183,7 +183,7 @@ public void testSortBytes() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -206,7 +206,7 @@ public void testSortBooleans() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -221,7 +221,7 @@ public void testSortMixedStrings() throws Exception { if (randomBoolean()) { value = String.valueOf(randomIntBetween(0, 100)); } else { - value = randomAsciiOfLengthBetween(1, 10); + value = randomAlphaOfLengthBetween(1, 10); } fieldValue.add(value); expectedResult.add(value); @@ -234,7 +234,7 @@ public void testSortMixedStrings() throws Exception { } String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, fieldValue); - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); processor.execute(ingestDocument); assertEquals(ingestDocument.getFieldValue(fieldName, List.class), expectedResult); } @@ -242,9 +242,9 @@ public void testSortMixedStrings() throws Exception { public void testSortNonListField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - ingestDocument.setFieldValue(fieldName, randomAsciiOfLengthBetween(1, 10)); + ingestDocument.setFieldValue(fieldName, randomAlphaOfLengthBetween(1, 10)); SortOrder order = randomBoolean() ? SortOrder.ASCENDING : SortOrder.DESCENDING; - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); try { processor.execute(ingestDocument); } catch(IllegalArgumentException e) { @@ -256,7 +256,7 @@ public void testSortNonExistingField() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); SortOrder order = randomBoolean() ? SortOrder.ASCENDING : SortOrder.DESCENDING; - Processor processor = new SortProcessor(randomAsciiOfLength(10), fieldName, order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), fieldName, order); try { processor.execute(ingestDocument); } catch(IllegalArgumentException e) { @@ -267,7 +267,7 @@ public void testSortNonExistingField() throws Exception { public void testSortNullValue() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null)); SortOrder order = randomBoolean() ? SortOrder.ASCENDING : SortOrder.DESCENDING; - Processor processor = new SortProcessor(randomAsciiOfLength(10), "field", order); + Processor processor = new SortProcessor(randomAlphaOfLength(10), "field", order); try { processor.execute(ingestDocument); } catch(IllegalArgumentException e) { diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java index 68580eb8f1d21..b165dae39b221 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorFactoryTests.java @@ -34,7 +34,7 @@ public void testCreate() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("separator", "\\."); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); SplitProcessor splitProcessor = factory.create(null, processorTag, config); assertThat(splitProcessor.getTag(), equalTo(processorTag)); assertThat(splitProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorTests.java index 253ddfd194b83..257719f7f70f7 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SplitProcessorTests.java @@ -39,7 +39,7 @@ public class SplitProcessorTests extends ESTestCase { public void testSplit() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, "127.0.0.1"); - Processor processor = new SplitProcessor(randomAsciiOfLength(10), fieldName, "\\.", false); + Processor processor = new SplitProcessor(randomAlphaOfLength(10), fieldName, "\\.", false); processor.execute(ingestDocument); assertThat(ingestDocument.getFieldValue(fieldName, List.class), equalTo(Arrays.asList("127", "0", "0", "1"))); } @@ -47,7 +47,7 @@ public void testSplit() throws Exception { public void testSplitFieldNotFound() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); - Processor processor = new SplitProcessor(randomAsciiOfLength(10), fieldName, "\\.", false); + Processor processor = new SplitProcessor(randomAlphaOfLength(10), fieldName, "\\.", false); try { processor.execute(ingestDocument); fail("split processor should have failed"); @@ -59,7 +59,7 @@ public void testSplitFieldNotFound() throws Exception { public void testSplitNullValue() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("field", null)); - Processor processor = new SplitProcessor(randomAsciiOfLength(10), "field", "\\.", false); + Processor processor = new SplitProcessor(randomAlphaOfLength(10), "field", "\\.", false); try { processor.execute(ingestDocument); fail("split processor should have failed"); @@ -73,7 +73,7 @@ public void testSplitNullValueWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap(fieldName, null)); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new SplitProcessor(randomAsciiOfLength(10), fieldName, "\\.", true); + Processor processor = new SplitProcessor(randomAlphaOfLength(10), fieldName, "\\.", true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -81,7 +81,7 @@ public void testSplitNullValueWithIgnoreMissing() throws Exception { public void testSplitNonExistentWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new SplitProcessor(randomAsciiOfLength(10), "field", "\\.", true); + Processor processor = new SplitProcessor(randomAlphaOfLength(10), "field", "\\.", true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -90,7 +90,7 @@ public void testSplitNonStringValue() throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>()); String fieldName = RandomDocumentPicks.randomFieldName(random()); ingestDocument.setFieldValue(fieldName, randomInt()); - Processor processor = new SplitProcessor(randomAsciiOfLength(10), fieldName, "\\.", false); + Processor processor = new SplitProcessor(randomAlphaOfLength(10), fieldName, "\\.", false); try { processor.execute(ingestDocument); fail("split processor should have failed"); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorFactoryTests.java index bcc0dde94090a..ee57724bfcdf2 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorFactoryTests.java @@ -34,7 +34,7 @@ public void testCreate() throws Exception { TrimProcessor.Factory factory = new TrimProcessor.Factory(); Map config = new HashMap<>(); config.put("field", "field1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); TrimProcessor uppercaseProcessor = (TrimProcessor)factory.create(null, processorTag, config); assertThat(uppercaseProcessor.getTag(), equalTo(processorTag)); assertThat(uppercaseProcessor.getField(), equalTo("field1")); @@ -46,7 +46,7 @@ public void testCreateWithIgnoreMissing() throws Exception { Map config = new HashMap<>(); config.put("field", "field1"); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); TrimProcessor uppercaseProcessor = (TrimProcessor)factory.create(null, processorTag, config); assertThat(uppercaseProcessor.getTag(), equalTo(processorTag)); assertThat(uppercaseProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorTests.java index ce21cf3e38173..99b543b8fe120 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/TrimProcessorTests.java @@ -23,7 +23,7 @@ public class TrimProcessorTests extends AbstractStringProcessorTestCase { @Override protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing) { - return new TrimProcessor(randomAsciiOfLength(10), field, ignoreMissing); + return new TrimProcessor(randomAlphaOfLength(10), field, ignoreMissing); } @Override diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorFactoryTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorFactoryTests.java index 0f8341195102f..7dbdf123298a5 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorFactoryTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorFactoryTests.java @@ -33,7 +33,7 @@ public void testCreate() throws Exception { UppercaseProcessor.Factory factory = new UppercaseProcessor.Factory(); Map config = new HashMap<>(); config.put("field", "field1"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); UppercaseProcessor uppercaseProcessor = (UppercaseProcessor)factory.create(null, processorTag, config); assertThat(uppercaseProcessor.getTag(), equalTo(processorTag)); assertThat(uppercaseProcessor.getField(), equalTo("field1")); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorTests.java index e52c240928d90..2e4c6bf9ce9ed 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/UppercaseProcessorTests.java @@ -25,7 +25,7 @@ public class UppercaseProcessorTests extends AbstractStringProcessorTestCase { @Override protected AbstractStringProcessor newProcessor(String field, boolean ignoreMissing) { - return new UppercaseProcessor(randomAsciiOfLength(10), field, ignoreMissing); + return new UppercaseProcessor(randomAlphaOfLength(10), field, ignoreMissing); } @Override diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java index 5e9f6a5c91e2e..0d527590e478c 100644 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java +++ b/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java @@ -377,7 +377,7 @@ public void testUrlEncoderWithParam() throws Exception { assertScript("{{#url}}{{index}}{{/url}}", singletonMap("index", ""), equalTo("%3Clogstash-%7Bnow%2Fd%7BYYYY.MM.dd%7C%2B12%3A00%7D%7D%3E")); - final String random = randomAsciiOfLength(10); + final String random = randomAlphaOfLength(10); assertScript("{{#url}}prefix_{{s}}{{/url}}", singletonMap("s", random), equalTo("prefix_" + URLEncoder.encode(random, StandardCharsets.UTF_8.name()))); } diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ImplementInterfacesTests.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ImplementInterfacesTests.java index 2455af32528fc..fe95e8c8c2316 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ImplementInterfacesTests.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ImplementInterfacesTests.java @@ -62,7 +62,7 @@ public interface OneArg { public void testOneArg() { Object rando = randomInt(); assertEquals(rando, scriptEngine.compile(OneArg.class, null, "arg", emptyMap()).execute(rando)); - rando = randomAsciiOfLength(5); + rando = randomAlphaOfLength(5); assertEquals(rando, scriptEngine.compile(OneArg.class, null, "arg", emptyMap()).execute(rando)); Exception e = expectScriptThrows(IllegalArgumentException.class, () -> @@ -79,7 +79,7 @@ public interface ArrayArg { Object execute(String[] arg); } public void testArrayArg() { - String rando = randomAsciiOfLength(5); + String rando = randomAlphaOfLength(5); assertEquals(rando, scriptEngine.compile(ArrayArg.class, null, "arg[0]", emptyMap()).execute(new String[] {rando, "foo"})); } @@ -99,7 +99,7 @@ public interface DefArrayArg { public void testDefArrayArg() { Object rando = randomInt(); assertEquals(rando, scriptEngine.compile(DefArrayArg.class, null, "arg[0]", emptyMap()).execute(new Object[] {rando, 10})); - rando = randomAsciiOfLength(5); + rando = randomAlphaOfLength(5); assertEquals(rando, scriptEngine.compile(DefArrayArg.class, null, "arg[0]", emptyMap()).execute(new Object[] {rando, 10})); assertEquals(5, scriptEngine.compile(DefArrayArg.class, null, "arg[0].length()", emptyMap()).execute(new Object[] {rando, 10})); } diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java index 23f3fc77c2055..a47422180581c 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java @@ -85,8 +85,8 @@ protected Collection> getPlugins() { @Override protected void initializeAdditionalMappings(MapperService mapperService) throws IOException { - queryField = randomAsciiOfLength(4); - docType = randomAsciiOfLength(4); + queryField = randomAlphaOfLength(4); + docType = randomAlphaOfLength(4); mapperService.merge("query_type", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("query_type", queryField, "type=percolator" ).string()), MapperService.MergeReason.MAPPING_UPDATE, false); @@ -103,11 +103,11 @@ protected PercolateQueryBuilder doCreateTestQueryBuilder() { private PercolateQueryBuilder doCreateTestQueryBuilder(boolean indexedDocument) { documentSource = randomSource(); if (indexedDocument) { - indexedDocumentIndex = randomAsciiOfLength(4); - indexedDocumentType = randomAsciiOfLength(4); - indexedDocumentId = randomAsciiOfLength(4); - indexedDocumentRouting = randomAsciiOfLength(4); - indexedDocumentPreference = randomAsciiOfLength(4); + indexedDocumentIndex = randomAlphaOfLength(4); + indexedDocumentType = randomAlphaOfLength(4); + indexedDocumentId = randomAlphaOfLength(4); + indexedDocumentRouting = randomAlphaOfLength(4); + indexedDocumentPreference = randomAlphaOfLength(4); indexedDocumentVersion = (long) randomIntBetween(0, Integer.MAX_VALUE); return new PercolateQueryBuilder(queryField, docType, indexedDocumentIndex, indexedDocumentType, indexedDocumentId, indexedDocumentRouting, indexedDocumentPreference, indexedDocumentVersion); diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java index cd702784ee514..13b3e206eed96 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java @@ -134,8 +134,8 @@ public void init() throws Exception { } private void addQueryMapping() throws Exception { - typeName = randomAsciiOfLength(4); - fieldName = randomAsciiOfLength(4); + typeName = randomAlphaOfLength(4); + fieldName = randomAlphaOfLength(4); String percolatorMapper = XContentFactory.jsonBuilder().startObject().startObject(typeName) .startObject("properties").startObject(fieldName).field("type", "percolator").endObject().endObject() .endObject().endObject().string(); diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index 43d4e4388c4ef..ebf0c13b20aa0 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -467,7 +467,7 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { public void testManyPercolatorFields() throws Exception { - String queryFieldName = randomAsciiOfLength(8); + String queryFieldName = randomAlphaOfLength(8); createIndex("test", client().admin().indices().prepareCreate("test") .addMapping("doc_type", "field", "type=keyword") .addMapping("query_type1", queryFieldName, "type=percolator") @@ -487,7 +487,7 @@ public void testManyPercolatorFields() throws Exception { } public void testWithMultiplePercolatorFields() throws Exception { - String queryFieldName = randomAsciiOfLength(8); + String queryFieldName = randomAlphaOfLength(8); createIndex("test1", client().admin().indices().prepareCreate("test1") .addMapping("doc_type", "field", "type=keyword") .addMapping("query_type", queryFieldName, "type=percolator")); diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/QueryAnalyzerTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/QueryAnalyzerTests.java index 4a8bec903a7ff..558d237f1259c 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/QueryAnalyzerTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/QueryAnalyzerTests.java @@ -536,7 +536,7 @@ public void testSelectTermsListWithHighestSumOfTermLength() { while (sumTermLength > 0) { int length = randomInt(sumTermLength); shortestTerms1Length = Math.min(shortestTerms1Length, length); - terms1.add(new Term("field", randomAsciiOfLength(length))); + terms1.add(new Term("field", randomAlphaOfLength(length))); sumTermLength -= length; } @@ -546,7 +546,7 @@ public void testSelectTermsListWithHighestSumOfTermLength() { while (sumTermLength > 0) { int length = randomInt(sumTermLength); shortestTerms2Length = Math.min(shortestTerms2Length, length); - terms2.add(new Term("field", randomAsciiOfLength(length))); + terms2.add(new Term("field", randomAlphaOfLength(length))); sumTermLength -= length; } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/BulkIndexByScrollResponseTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/BulkIndexByScrollResponseTests.java index d33d8b2c8779c..791277ad27097 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/BulkIndexByScrollResponseTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/BulkIndexByScrollResponseTests.java @@ -43,13 +43,13 @@ public void testMergeConstructor() { List allBulkFailures = new ArrayList<>(); List allSearchFailures = new ArrayList<>(); boolean timedOut = false; - String reasonCancelled = rarely() ? randomAsciiOfLength(5) : null; + String reasonCancelled = rarely() ? randomAlphaOfLength(5) : null; for (int i = 0; i < mergeCount; i++) { // One of the merged responses gets the expected value for took, the others get a smaller value TimeValue thisTook = timeValueMillis(i == tookIndex ? took : between(0, took)); // The actual status doesn't matter too much - we test merging those elsewhere - String thisReasonCancelled = rarely() ? randomAsciiOfLength(5) : null; + String thisReasonCancelled = rarely() ? randomAlphaOfLength(5) : null; BulkByScrollTask.Status status = new BulkByScrollTask.Status(i, 0, 0, 0, 0, 0, 0, 0, 0, 0, timeValueMillis(0), 0f, thisReasonCancelled, timeValueMillis(0)); List bulkFailures = frequently() ? emptyList() diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/DeleteByQueryBasicTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/DeleteByQueryBasicTests.java index aaab77f543f8b..f0eba7e9fa68f 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/DeleteByQueryBasicTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/DeleteByQueryBasicTests.java @@ -166,7 +166,7 @@ public void testDeleteByMatchQuery() throws Exception { List builders = new ArrayList<>(); for (int i = 0; i < docs; i++) { builders.add(client().prepareIndex("test", "test", Integer.toString(i)) - .setRouting(randomAsciiOfLengthBetween(1, 5)) + .setRouting(randomAlphaOfLengthBetween(1, 5)) .setSource("foo", "bar")); } indexRandom(true, true, true, builders); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWhitelistTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWhitelistTests.java index 1a22fe53ef4a9..1a25e4e5e9c45 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWhitelistTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWhitelistTests.java @@ -50,7 +50,7 @@ public void testLocalRequestWithWhitelist() { * Build a {@link RemoteInfo}, defaulting values that we don't care about in this test to values that don't hurt anything. */ private RemoteInfo newRemoteInfo(String host, int port) { - return new RemoteInfo(randomAsciiOfLength(5), host, port, new BytesArray("test"), null, null, emptyMap(), + return new RemoteInfo(randomAlphaOfLength(5), host, port, new BytesArray("test"), null, null, emptyMap(), RemoteInfo.DEFAULT_SOCKET_TIMEOUT, RemoteInfo.DEFAULT_CONNECT_TIMEOUT); } @@ -64,7 +64,7 @@ public void testWhitelistedRemote() { public void testWhitelistedByPrefix() { checkRemoteWhitelist(buildRemoteWhitelist(singletonList("*.example.com:9200")), - new RemoteInfo(randomAsciiOfLength(5), "es.example.com", 9200, new BytesArray("test"), null, null, emptyMap(), + new RemoteInfo(randomAlphaOfLength(5), "es.example.com", 9200, new BytesArray("test"), null, null, emptyMap(), RemoteInfo.DEFAULT_SOCKET_TIMEOUT, RemoteInfo.DEFAULT_CONNECT_TIMEOUT)); checkRemoteWhitelist(buildRemoteWhitelist(singletonList("*.example.com:9200")), newRemoteInfo("6e134134a1.us-east-1.aws.example.com", 9200)); @@ -114,7 +114,7 @@ private List randomWhitelist() { int size = between(1, 100); List whitelist = new ArrayList<>(size); for (int i = 0; i < size; i++) { - whitelist.add(randomAsciiOfLength(5) + ':' + between(1, Integer.MAX_VALUE)); + whitelist.add(randomAlphaOfLength(5) + ':' + between(1, Integer.MAX_VALUE)); } return whitelist; } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java index e0155ca6cab67..c2b072396716f 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java @@ -40,7 +40,7 @@ public class ReindexRequestTests extends AbstractBulkByScrollRequestTestCase headers = new HashMap<>(headersCount); while (headers.size() < headersCount) { - headers.put(randomAsciiOfLength(5), randomAsciiOfLength(5)); + headers.put(randomAlphaOfLength(5), randomAlphaOfLength(5)); } TimeValue socketTimeout = parseTimeValue(randomPositiveTimeValue(), "socketTimeout"); TimeValue connectTimeout = parseTimeValue(randomPositiveTimeValue(), "connectTimeout"); - reindex.setRemoteInfo(new RemoteInfo(randomAsciiOfLength(5), randomAsciiOfLength(5), port, query, username, password, headers, + reindex.setRemoteInfo(new RemoteInfo(randomAlphaOfLength(5), randomAlphaOfLength(5), port, query, username, password, headers, socketTimeout, connectTimeout)); } ReindexRequest tripped = new ReindexRequest(); @@ -90,7 +90,7 @@ public void testUpdateByQueryRequest() throws IOException { UpdateByQueryRequest update = new UpdateByQueryRequest(new SearchRequest()); randomRequest(update); if (randomBoolean()) { - update.setPipeline(randomAsciiOfLength(5)); + update.setPipeline(randomAlphaOfLength(5)); } UpdateByQueryRequest tripped = new UpdateByQueryRequest(); roundTrip(update, tripped); @@ -196,7 +196,7 @@ public void testRethrottleRequest() throws IOException { if (randomBoolean()) { request.setActions(randomFrom(UpdateByQueryAction.NAME, ReindexAction.NAME)); } else { - request.setTaskId(new TaskId(randomAsciiOfLength(5), randomLong())); + request.setTaskId(new TaskId(randomAlphaOfLength(5), randomLong())); } RethrottleRequest tripped = new RethrottleRequest(); roundTrip(request, tripped); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportRethrottleActionTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportRethrottleActionTests.java index 566358f459480..14ae9b5abb842 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportRethrottleActionTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportRethrottleActionTests.java @@ -68,7 +68,7 @@ public void createTask() { private void rethrottleTestCase(int runningSlices, Consumer> simulator, Consumer> verifier) { Client client = mock(Client.class); - String localNodeId = randomAsciiOfLength(5); + String localNodeId = randomAlphaOfLength(5); float newRequestsPerSecond = randomValueOtherThanMany(f -> f <= 0, () -> randomFloat()); @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryRequestTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryRequestTests.java index 9ecb008918726..c932e83ce1c9f 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryRequestTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryRequestTests.java @@ -62,16 +62,16 @@ public void testUpdateByQueryRequestImplementsIndicesRequestReplaceable() { @Override protected UpdateByQueryRequest newRequest() { - return new UpdateByQueryRequest(new SearchRequest(randomAsciiOfLength(5))); + return new UpdateByQueryRequest(new SearchRequest(randomAlphaOfLength(5))); } @Override protected void extraRandomizationForSlice(UpdateByQueryRequest original) { if (randomBoolean()) { - original.setScript(new Script(randomAsciiOfLength(5))); + original.setScript(new Script(randomAlphaOfLength(5))); } if (randomBoolean()) { - original.setPipeline(randomAsciiOfLength(5)); + original.setPipeline(randomAlphaOfLength(5)); } } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuildersTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuildersTests.java index b77dba6e9c9b3..16f0c2a0a4ecb 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuildersTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuildersTests.java @@ -185,7 +185,7 @@ public void testScrollParams() { } public void testScrollEntity() throws IOException { - String scroll = randomAsciiOfLength(30); + String scroll = randomAlphaOfLength(30); HttpEntity entity = scrollEntity(scroll, Version.V_5_0_0); assertEquals(ContentType.APPLICATION_JSON.toString(), entity.getContentType().getValue()); assertThat(Streams.copyToString(new InputStreamReader(entity.getContent(), StandardCharsets.UTF_8)), @@ -198,7 +198,7 @@ public void testScrollEntity() throws IOException { } public void testClearScrollEntity() throws IOException { - String scroll = randomAsciiOfLength(30); + String scroll = randomAlphaOfLength(30); HttpEntity entity = clearScrollEntity(scroll, Version.V_5_0_0); assertEquals(ContentType.APPLICATION_JSON.toString(), entity.getContentType().getValue()); assertThat(Streams.copyToString(new InputStreamReader(entity.getContent(), StandardCharsets.UTF_8)), diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteScrollableHitSourceTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteScrollableHitSourceTests.java index eb7abea6af5d1..2a67306425c29 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteScrollableHitSourceTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/RemoteScrollableHitSourceTests.java @@ -370,7 +370,7 @@ public void testRetryUntilYouRunOutOfTries() throws Exception { } public void testThreadContextRestored() throws Exception { - String header = randomAsciiOfLength(5); + String header = randomAlphaOfLength(5); threadPool.getThreadContext().putHeader("test", header); AtomicBoolean called = new AtomicBoolean(); sourceWithMockedRemoteCall("start_ok.json").doStart(r -> { diff --git a/modules/repository-url/src/test/java/org/elasticsearch/common/blobstore/url/URLBlobStoreTests.java b/modules/repository-url/src/test/java/org/elasticsearch/common/blobstore/url/URLBlobStoreTests.java index 4df83c58bd38b..5489eff71f4e7 100644 --- a/modules/repository-url/src/test/java/org/elasticsearch/common/blobstore/url/URLBlobStoreTests.java +++ b/modules/repository-url/src/test/java/org/elasticsearch/common/blobstore/url/URLBlobStoreTests.java @@ -52,7 +52,7 @@ public static void startHttp() throws Exception { for (int i = 0; i < message.length; ++i) { message[i] = randomByte(); } - blobName = randomAsciiOfLength(8); + blobName = randomAlphaOfLength(8); httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress().getHostAddress(), 6001), 0); diff --git a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java index 376214eb17315..c5f2b0d7fbd35 100644 --- a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java +++ b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorFactoryTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.ingest.attachment; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.ingest.ConfigurationUtils; import org.elasticsearch.test.ESTestCase; import java.util.ArrayList; @@ -45,7 +44,7 @@ public void testBuildDefaults() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); AttachmentProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); @@ -61,7 +60,7 @@ public void testConfigureIndexedChars() throws Exception { config.put("field", "_field"); config.put("indexed_chars", indexedChars); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); AttachmentProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); assertThat(processor.getIndexedChars(), is(indexedChars)); @@ -127,7 +126,7 @@ public void testIgnoreMissing() throws Exception { config.put("field", "_field"); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); AttachmentProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); diff --git a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java index e5b9d72017fd3..07e369985321a 100644 --- a/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java +++ b/plugins/ingest-attachment/src/test/java/org/elasticsearch/ingest/attachment/AttachmentProcessorTests.java @@ -42,7 +42,6 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -56,7 +55,7 @@ public class AttachmentProcessorTests extends ESTestCase { @Before public void createStandardProcessor() throws IOException { - processor = new AttachmentProcessor(randomAsciiOfLength(10), "source_field", + processor = new AttachmentProcessor(randomAlphaOfLength(10), "source_field", "target_field", EnumSet.allOf(AttachmentProcessor.Property.class), 10000, false); } @@ -89,7 +88,7 @@ public void testHtmlDocumentWithRandomFields() throws Exception { if (randomBoolean()) { selectedProperties.add(AttachmentProcessor.Property.DATE); } - processor = new AttachmentProcessor(randomAsciiOfLength(10), "source_field", + processor = new AttachmentProcessor(randomAlphaOfLength(10), "source_field", "target_field", selectedProperties, 10000, false); Map attachmentData = parseDocument("htmlWithEmptyDateMeta.html", processor); @@ -243,7 +242,7 @@ public void testNullValueWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null)); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new AttachmentProcessor(randomAsciiOfLength(10), "source_field", "randomTarget", null, 10, true); + Processor processor = new AttachmentProcessor(randomAlphaOfLength(10), "source_field", "randomTarget", null, 10, true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -251,7 +250,7 @@ public void testNullValueWithIgnoreMissing() throws Exception { public void testNonExistentWithIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new AttachmentProcessor(randomAsciiOfLength(10), "source_field", "randomTarget", null, 10, true); + Processor processor = new AttachmentProcessor(randomAlphaOfLength(10), "source_field", "randomTarget", null, 10, true); processor.execute(ingestDocument); assertIngestDocument(originalIngestDocument, ingestDocument); } @@ -260,7 +259,7 @@ public void testNullWithoutIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null)); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new AttachmentProcessor(randomAsciiOfLength(10), "source_field", "randomTarget", null, 10, false); + Processor processor = new AttachmentProcessor(randomAlphaOfLength(10), "source_field", "randomTarget", null, 10, false); Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument)); assertThat(exception.getMessage(), equalTo("field [source_field] is null, cannot parse.")); } @@ -268,7 +267,7 @@ public void testNullWithoutIgnoreMissing() throws Exception { public void testNonExistentWithoutIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); - Processor processor = new AttachmentProcessor(randomAsciiOfLength(10), "source_field", "randomTarget", null, 10, false); + Processor processor = new AttachmentProcessor(randomAlphaOfLength(10), "source_field", "randomTarget", null, 10, false); Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument)); assertThat(exception.getMessage(), equalTo("field [source_field] not present as part of path [source_field]")); } diff --git a/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java b/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java index 8db0d15f7966c..3904b043a5255 100644 --- a/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java +++ b/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java @@ -76,7 +76,7 @@ public void testBuildDefaults() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); GeoIpProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); @@ -93,7 +93,7 @@ public void testSetIgnoreMissing() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); GeoIpProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); @@ -110,7 +110,7 @@ public void testCountryBuildDefaults() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); config.put("database_file", "GeoLite2-Country.mmdb.gz"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); GeoIpProcessor processor = factory.create(null, processorTag, config); diff --git a/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorTests.java b/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorTests.java index 221c06d3b6842..54c504ca5c579 100644 --- a/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorTests.java +++ b/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.ingest.geoip; import com.maxmind.geoip2.DatabaseReader; -import org.elasticsearch.ingest.Processor; import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.ingest.IngestDocument; import org.elasticsearch.test.ESTestCase; @@ -42,7 +41,7 @@ public class GeoIpProcessorTests extends ESTestCase { public void testCity() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); Map document = new HashMap<>(); @@ -69,7 +68,7 @@ public void testCity() throws Exception { public void testNullValueWithIgnoreMissing() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null)); @@ -80,7 +79,7 @@ public void testNullValueWithIgnoreMissing() throws Exception { public void testNonExistentWithIgnoreMissing() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); @@ -90,7 +89,7 @@ public void testNonExistentWithIgnoreMissing() throws Exception { public void testNullWithoutIgnoreMissing() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null)); @@ -101,7 +100,7 @@ public void testNullWithoutIgnoreMissing() throws Exception { public void testNonExistentWithoutIgnoreMissing() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); @@ -111,7 +110,7 @@ public void testNonExistentWithoutIgnoreMissing() throws Exception { public void testCity_withIpV6() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); String address = "2602:306:33d3:8000::3257:9652"; @@ -139,7 +138,7 @@ public void testCity_withIpV6() throws Exception { public void testCityWithMissingLocation() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); Map document = new HashMap<>(); @@ -156,7 +155,7 @@ public void testCityWithMissingLocation() throws Exception { public void testCountry() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-Country.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); Map document = new HashMap<>(); @@ -176,7 +175,7 @@ public void testCountry() throws Exception { public void testCountryWithMissingLocation() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-Country.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); Map document = new HashMap<>(); @@ -193,7 +192,7 @@ public void testCountryWithMissingLocation() throws Exception { public void testAddressIsNotInTheDatabase() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); Map document = new HashMap<>(); @@ -206,7 +205,7 @@ public void testAddressIsNotInTheDatabase() throws Exception { /** Don't silently do DNS lookups or anything trappy on bogus data */ public void testInvalid() throws Exception { InputStream database = getDatabaseFileInputStream("/GeoLite2-City.mmdb.gz"); - GeoIpProcessor processor = new GeoIpProcessor(randomAsciiOfLength(10), "source_field", + GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), "source_field", new DatabaseReader.Builder(database).build(), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), false); Map document = new HashMap<>(); diff --git a/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java b/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java index c1c46283076c3..4e0d0fb3695c8 100644 --- a/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java +++ b/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorFactoryTests.java @@ -79,7 +79,7 @@ public void testBuildDefaults() throws Exception { Map config = new HashMap<>(); config.put("field", "_field"); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); UserAgentProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); @@ -99,7 +99,7 @@ public void testBuildWithIgnoreMissing() throws Exception { config.put("field", "_field"); config.put("ignore_missing", true); - String processorTag = randomAsciiOfLength(10); + String processorTag = randomAlphaOfLength(10); UserAgentProcessor processor = factory.create(null, processorTag, config); assertThat(processor.getTag(), equalTo(processorTag)); diff --git a/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java b/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java index 2c9e72ae9d9bc..92e94434ccdbe 100644 --- a/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java +++ b/plugins/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.ingest.IngestDocument; -import org.elasticsearch.ingest.useragent.UserAgentProcessor; import org.elasticsearch.test.ESTestCase; import org.junit.BeforeClass; @@ -46,14 +45,14 @@ public static void setupProcessor() throws IOException { InputStream regexStream = UserAgentProcessor.class.getResourceAsStream("/regexes.yaml"); assertNotNull(regexStream); - UserAgentParser parser = new UserAgentParser(randomAsciiOfLength(10), regexStream, new UserAgentCache(1000)); + UserAgentParser parser = new UserAgentParser(randomAlphaOfLength(10), regexStream, new UserAgentCache(1000)); - processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", parser, + processor = new UserAgentProcessor(randomAlphaOfLength(10), "source_field", "target_field", parser, EnumSet.allOf(UserAgentProcessor.Property.class), false); } public void testNullValueWithIgnoreMissing() throws Exception { - UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, + UserAgentProcessor processor = new UserAgentProcessor(randomAlphaOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), true); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null)); @@ -63,7 +62,7 @@ public void testNullValueWithIgnoreMissing() throws Exception { } public void testNonExistentWithIgnoreMissing() throws Exception { - UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, + UserAgentProcessor processor = new UserAgentProcessor(randomAlphaOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), true); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); @@ -72,7 +71,7 @@ public void testNonExistentWithIgnoreMissing() throws Exception { } public void testNullWithoutIgnoreMissing() throws Exception { - UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, + UserAgentProcessor processor = new UserAgentProcessor(randomAlphaOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), false); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.singletonMap("source_field", null)); @@ -82,7 +81,7 @@ public void testNullWithoutIgnoreMissing() throws Exception { } public void testNonExistentWithoutIgnoreMissing() throws Exception { - UserAgentProcessor processor = new UserAgentProcessor(randomAsciiOfLength(10), "source_field", "target_field", null, + UserAgentProcessor processor = new UserAgentProcessor(randomAlphaOfLength(10), "source_field", "target_field", null, EnumSet.allOf(UserAgentProcessor.Property.class), false); IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap()); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); diff --git a/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreContainerTests.java b/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreContainerTests.java index 091c92ffd31f2..f7c6fc2eac97c 100644 --- a/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreContainerTests.java +++ b/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreContainerTests.java @@ -29,7 +29,7 @@ public class GoogleCloudStorageBlobStoreContainerTests extends ESBlobStoreContainerTestCase { @Override protected BlobStore newBlobStore() throws IOException { - String bucket = randomAsciiOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); + String bucket = randomAlphaOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); return new GoogleCloudStorageBlobStore(Settings.EMPTY, bucket, MockHttpTransport.newStorage(bucket, getTestName())); } } diff --git a/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreTests.java b/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreTests.java index b5489466b5136..65add371855d0 100644 --- a/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreTests.java +++ b/plugins/repository-gcs/src/test/java/org/elasticsearch/common/blobstore/gcs/GoogleCloudStorageBlobStoreTests.java @@ -30,7 +30,7 @@ public class GoogleCloudStorageBlobStoreTests extends ESBlobStoreTestCase { @Override protected BlobStore newBlobStore() throws IOException { - String bucket = randomAsciiOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); + String bucket = randomAlphaOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); return new GoogleCloudStorageBlobStore(Settings.EMPTY, bucket, MockHttpTransport.newStorage(bucket, getTestName())); } } diff --git a/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStoreContainerTests.java b/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStoreContainerTests.java index 98dd43b6f4d7e..187ce9b23b43e 100644 --- a/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStoreContainerTests.java +++ b/plugins/repository-s3/src/test/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStoreContainerTests.java @@ -31,7 +31,7 @@ public class S3BlobStoreContainerTests extends ESBlobStoreContainerTestCase { protected BlobStore newBlobStore() throws IOException { MockAmazonS3 client = new MockAmazonS3(); - String bucket = randomAsciiOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); + String bucket = randomAlphaOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); return new S3BlobStore(Settings.EMPTY, client, bucket, false, new ByteSizeValue(10, ByteSizeUnit.MB), 5, "public-read-write", "standard"); diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilBootstrapChecksTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilBootstrapChecksTests.java index 79c3f9248b5e1..8e346bf7d9cb9 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilBootstrapChecksTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilBootstrapChecksTests.java @@ -92,7 +92,7 @@ public void testNonEnforcedBootstrapChecks() throws NodeValidationException { } public void testInvalidValue() { - final String value = randomAsciiOfLength(8); + final String value = randomAlphaOfLength(8); setEsEnforceBootstrapChecks(value); final boolean enforceLimits = randomBoolean(); final IllegalArgumentException e = expectThrows( diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilElasticsearchCliTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilElasticsearchCliTests.java index 2c00030973bcf..02caeca808944 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilElasticsearchCliTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilElasticsearchCliTests.java @@ -33,7 +33,7 @@ public class EvilElasticsearchCliTests extends ESElasticsearchCliTestCase { @SuppressForbidden(reason = "manipulates system properties for testing") public void testPathHome() throws Exception { final String pathHome = System.getProperty("es.path.home"); - final String value = randomAsciiOfLength(16); + final String value = randomAlphaOfLength(16); System.setProperty("es.path.home", value); runTest( @@ -48,7 +48,7 @@ public void testPathHome() throws Exception { }); System.clearProperty("es.path.home"); - final String commandLineValue = randomAsciiOfLength(16); + final String commandLineValue = randomAlphaOfLength(16); runTest( ExitCodes.OK, true, diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerConfigurationTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerConfigurationTests.java index 9cd6ec630ad47..6270111a0971c 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerConfigurationTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerConfigurationTests.java @@ -179,7 +179,7 @@ public void testLoggingLevelsFromSettings() throws IOException, UserException { assertThat(loggerConfigs, hasKey("bar")); assertThat(loggerConfigs.get("bar").getLevel(), equalTo(barLevel)); - assertThat(ctx.getLogger(randomAsciiOfLength(16)).getLevel(), equalTo(rootLevel)); + assertThat(ctx.getLogger(randomAlphaOfLength(16)).getLevel(), equalTo(rootLevel)); } } diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java index f02ce6031c35e..6246f3e1dd4a4 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java @@ -37,16 +37,12 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.hamcrest.RegexMatcher; -import javax.management.MBeanServerPermission; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.Path; -import java.security.AccessControlException; -import java.security.Permission; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -126,7 +122,7 @@ public void testFindAppender() throws IOException, UserException { public void testPrefixLogger() throws IOException, IllegalAccessException, UserException { setupLogging("prefix"); - final String prefix = randomBoolean() ? null : randomAsciiOfLength(16); + final String prefix = randomBoolean() ? null : randomAlphaOfLength(16); final Logger logger = Loggers.getLogger("prefix", prefix); logger.info("test"); logger.info("{}", "test"); @@ -156,9 +152,9 @@ public void testPrefixLogger() throws IOException, IllegalAccessException, UserE } public void testProperties() throws IOException, UserException { - final Settings.Builder builder = Settings.builder().put("cluster.name", randomAsciiOfLength(16)); + final Settings.Builder builder = Settings.builder().put("cluster.name", randomAlphaOfLength(16)); if (randomBoolean()) { - builder.put("node.name", randomAsciiOfLength(16)); + builder.put("node.name", randomAlphaOfLength(16)); } final Settings settings = builder.build(); setupLogging("minimal", settings); diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java index 397838862c33f..28b5825513f8f 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java @@ -76,9 +76,9 @@ public class ContextAndHeaderTransportIT extends HttpSmokeTestCase { private static final List requests = new CopyOnWriteArrayList<>(); private static final String CUSTOM_HEADER = "SomeCustomHeader"; - private String randomHeaderValue = randomAsciiOfLength(20); - private String queryIndex = "query-" + randomAsciiOfLength(10).toLowerCase(Locale.ROOT); - private String lookupIndex = "lookup-" + randomAsciiOfLength(10).toLowerCase(Locale.ROOT); + private String randomHeaderValue = randomAlphaOfLength(20); + private String queryIndex = "query-" + randomAlphaOfLength(10).toLowerCase(Locale.ROOT); + private String lookupIndex = "lookup-" + randomAlphaOfLength(10).toLowerCase(Locale.ROOT); @Override protected Settings nodeSettings(int nodeOrdinal) { diff --git a/test/framework/src/main/java/org/elasticsearch/action/bulk/byscroll/AbstractBulkByScrollRequestTestCase.java b/test/framework/src/main/java/org/elasticsearch/action/bulk/byscroll/AbstractBulkByScrollRequestTestCase.java index 8a12a32ad0bbc..c4ac9587e82f7 100644 --- a/test/framework/src/main/java/org/elasticsearch/action/bulk/byscroll/AbstractBulkByScrollRequestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/action/bulk/byscroll/AbstractBulkByScrollRequestTestCase.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.bulk.byscroll; -import org.elasticsearch.action.bulk.byscroll.AbstractBulkByScrollRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.tasks.TaskId; @@ -45,7 +44,7 @@ public void testForSlice() { randomBoolean() ? Float.POSITIVE_INFINITY : randomValueOtherThanMany(r -> r < 0, ESTestCase::randomFloat)); original.setSize(randomBoolean() ? AbstractBulkByScrollRequest.SIZE_ALL_MATCHES : between(0, Integer.MAX_VALUE)); - TaskId slicingTask = new TaskId(randomAsciiOfLength(5), randomLong()); + TaskId slicingTask = new TaskId(randomAlphaOfLength(5), randomLong()); SearchRequest sliceRequest = new SearchRequest(); R forSliced = original.forSlice(slicingTask, sliceRequest); assertEquals(original.isAbortOnVersionConflict(), forSliced.isAbortOnVersionConflict()); diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/routing/TestShardRouting.java b/test/framework/src/main/java/org/elasticsearch/cluster/routing/TestShardRouting.java index d0d6c02f6360f..a4ac6fad241a5 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/routing/TestShardRouting.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/routing/TestShardRouting.java @@ -27,7 +27,7 @@ import org.elasticsearch.snapshots.SnapshotId; import org.elasticsearch.test.ESTestCase; -import static org.elasticsearch.test.ESTestCase.randomAsciiOfLength; +import static org.elasticsearch.test.ESTestCase.randomAlphaOfLength; /** * A helper that allows to create shard routing instances within tests, while not requiring to expose @@ -131,7 +131,7 @@ public static RecoverySource randomRecoverySource() { RecoverySource.PeerRecoverySource.INSTANCE, RecoverySource.LocalShardsRecoverySource.INSTANCE, new RecoverySource.SnapshotRecoverySource( - new Snapshot("repo", new SnapshotId(randomAsciiOfLength(8), UUIDs.randomBase64UUID())), + new Snapshot("repo", new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())), Version.CURRENT, "some_index")); } diff --git a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java index 01c142133a6e7..215551da35628 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java @@ -173,7 +173,7 @@ protected IndexShard newShard(ShardRouting shardRouting, IndexingOperationListen * @param listeners an optional set of listeners to add to the shard */ protected IndexShard newShard(ShardId shardId, boolean primary, IndexingOperationListener... listeners) throws IOException { - ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, randomAsciiOfLength(5), primary, + ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, randomAlphaOfLength(5), primary, ShardRoutingState.INITIALIZING, primary ? RecoverySource.StoreRecoverySource.EMPTY_STORE_INSTANCE : RecoverySource.PeerRecoverySource.INSTANCE); return newShard(shardRouting, listeners); diff --git a/test/framework/src/main/java/org/elasticsearch/node/NodeTests.java b/test/framework/src/main/java/org/elasticsearch/node/NodeTests.java index 69291ccaba69c..ae4aff917a974 100644 --- a/test/framework/src/main/java/org/elasticsearch/node/NodeTests.java +++ b/test/framework/src/main/java/org/elasticsearch/node/NodeTests.java @@ -48,7 +48,7 @@ public class NodeTests extends ESTestCase { public void testNodeName() throws IOException { final Path tempDir = createTempDir(); - final String name = randomBoolean() ? randomAsciiOfLength(10) : null; + final String name = randomBoolean() ? randomAlphaOfLength(10) : null; Settings.Builder settings = Settings.builder() .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", randomLong())) .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) @@ -88,7 +88,7 @@ public List getBootstrapChecks() { public void testLoadPluginBootstrapChecks() throws IOException { final Path tempDir = createTempDir(); - final String name = randomBoolean() ? randomAsciiOfLength(10) : null; + final String name = randomBoolean() ? randomAlphaOfLength(10) : null; Settings.Builder settings = Settings.builder() .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", randomLong())) .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) @@ -139,7 +139,7 @@ public void testWarnIfPreRelease() { } public void testNodeAttributes() throws IOException { - String attr = randomAsciiOfLength(5); + String attr = randomAlphaOfLength(5); Settings.Builder settings = baseSettings().put(Node.NODE_ATTRIBUTES.getKey() + "test_attr", attr); try (Node node = new MockNode(settings.build(), Collections.singleton(MockTcpTransportPlugin.class))) { final Settings nodeSettings = randomBoolean() ? node.settings() : node.getEnvironment().settings(); diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java index 1bb5bb58eaf06..c79f432278ae8 100644 --- a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java @@ -222,7 +222,7 @@ protected void addRandomDocuments(String name, int numDocs) throws ExecutionExce IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[numDocs]; for (int i = 0; i < numDocs; i++) { indexRequestBuilders[i] = client().prepareIndex(name, name, Integer.toString(i)) - .setRouting(randomAsciiOfLength(randomIntBetween(1, 10))).setSource("field", "value"); + .setRouting(randomAlphaOfLength(randomIntBetween(1, 10))).setSource("field", "value"); } indexRandom(true, indexRequestBuilders); } @@ -262,6 +262,6 @@ public static void assertSuccessfulRestore(RestoreSnapshotResponse response) { } public static String randomAsciiName() { - return randomAsciiOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); + return randomAlphaOfLength(randomIntBetween(1, 10)).toLowerCase(Locale.ROOT); } } diff --git a/test/framework/src/main/java/org/elasticsearch/search/RandomSearchRequestGenerator.java b/test/framework/src/main/java/org/elasticsearch/search/RandomSearchRequestGenerator.java index f49cd174b7fd2..2a072a1d3be7b 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/RandomSearchRequestGenerator.java +++ b/test/framework/src/main/java/org/elasticsearch/search/RandomSearchRequestGenerator.java @@ -52,7 +52,7 @@ import static org.elasticsearch.test.ESTestCase.between; import static org.elasticsearch.test.ESTestCase.generateRandomStringArray; -import static org.elasticsearch.test.ESTestCase.randomAsciiOfLengthBetween; +import static org.elasticsearch.test.ESTestCase.randomAlphaOfLengthBetween; import static org.elasticsearch.test.ESTestCase.randomBoolean; import static org.elasticsearch.test.ESTestCase.randomByte; import static org.elasticsearch.test.ESTestCase.randomDouble; @@ -89,13 +89,13 @@ public static SearchRequest randomSearchRequest(Supplier ra searchRequest.types(generateRandomStringArray(10, 10, false, false)); } if (randomBoolean()) { - searchRequest.preference(randomAsciiOfLengthBetween(3, 10)); + searchRequest.preference(randomAlphaOfLengthBetween(3, 10)); } if (randomBoolean()) { searchRequest.requestCache(randomBoolean()); } if (randomBoolean()) { - searchRequest.routing(randomAsciiOfLengthBetween(3, 10)); + searchRequest.routing(randomAlphaOfLengthBetween(3, 10)); } if (randomBoolean()) { searchRequest.scroll(randomPositiveTimeValue()); @@ -152,7 +152,7 @@ public static SearchSourceBuilder randomSearchSourceBuilder( int fieldsSize = randomInt(25); List fields = new ArrayList<>(fieldsSize); for (int i = 0; i < fieldsSize; i++) { - fields.add(randomAsciiOfLengthBetween(5, 50)); + fields.add(randomAlphaOfLengthBetween(5, 50)); } builder.storedFields(fields); break; @@ -164,9 +164,9 @@ public static SearchSourceBuilder randomSearchSourceBuilder( int scriptFieldsSize = randomInt(25); for (int i = 0; i < scriptFieldsSize; i++) { if (randomBoolean()) { - builder.scriptField(randomAsciiOfLengthBetween(5, 50), new Script("foo"), randomBoolean()); + builder.scriptField(randomAlphaOfLengthBetween(5, 50), new Script("foo"), randomBoolean()); } else { - builder.scriptField(randomAsciiOfLengthBetween(5, 50), new Script("foo")); + builder.scriptField(randomAlphaOfLengthBetween(5, 50), new Script("foo")); } } } @@ -175,11 +175,11 @@ public static SearchSourceBuilder randomSearchSourceBuilder( int branch = randomInt(5); String[] includes = new String[randomIntBetween(0, 20)]; for (int i = 0; i < includes.length; i++) { - includes[i] = randomAsciiOfLengthBetween(5, 20); + includes[i] = randomAlphaOfLengthBetween(5, 20); } String[] excludes = new String[randomIntBetween(0, 20)]; for (int i = 0; i < excludes.length; i++) { - excludes[i] = randomAsciiOfLengthBetween(5, 20); + excludes[i] = randomAlphaOfLengthBetween(5, 20); } switch (branch) { case 0: @@ -189,8 +189,8 @@ public static SearchSourceBuilder randomSearchSourceBuilder( fetchSourceContext = new FetchSourceContext(true, includes, excludes); break; case 2: - fetchSourceContext = new FetchSourceContext(true, new String[]{randomAsciiOfLengthBetween(5, 20)}, - new String[]{randomAsciiOfLengthBetween(5, 20)}); + fetchSourceContext = new FetchSourceContext(true, new String[]{randomAlphaOfLengthBetween(5, 20)}, + new String[]{randomAlphaOfLengthBetween(5, 20)}); break; case 3: fetchSourceContext = new FetchSourceContext(true, includes, excludes); @@ -199,7 +199,7 @@ public static SearchSourceBuilder randomSearchSourceBuilder( fetchSourceContext = new FetchSourceContext(true, includes, null); break; case 5: - fetchSourceContext = new FetchSourceContext(true, new String[] {randomAsciiOfLengthBetween(5, 20)}, null); + fetchSourceContext = new FetchSourceContext(true, new String[] {randomAlphaOfLengthBetween(5, 20)}, null); break; default: throw new IllegalStateException(); @@ -210,21 +210,21 @@ public static SearchSourceBuilder randomSearchSourceBuilder( int size = randomIntBetween(0, 20); List statsGroups = new ArrayList<>(size); for (int i = 0; i < size; i++) { - statsGroups.add(randomAsciiOfLengthBetween(5, 20)); + statsGroups.add(randomAlphaOfLengthBetween(5, 20)); } builder.stats(statsGroups); } if (randomBoolean()) { int indexBoostSize = randomIntBetween(1, 10); for (int i = 0; i < indexBoostSize; i++) { - builder.indexBoost(randomAsciiOfLengthBetween(5, 20), randomFloat() * 10); + builder.indexBoost(randomAlphaOfLengthBetween(5, 20), randomFloat() * 10); } } if (randomBoolean()) { - builder.query(QueryBuilders.termQuery(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20))); + builder.query(QueryBuilders.termQuery(randomAlphaOfLengthBetween(5, 20), randomAlphaOfLengthBetween(5, 20))); } if (randomBoolean()) { - builder.postFilter(QueryBuilders.termQuery(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20))); + builder.postFilter(QueryBuilders.termQuery(randomAlphaOfLengthBetween(5, 20), randomAlphaOfLengthBetween(5, 20))); } if (randomBoolean()) { int numSorts = randomIntBetween(1, 5); @@ -232,10 +232,10 @@ public static SearchSourceBuilder randomSearchSourceBuilder( int branch = randomInt(5); switch (branch) { case 0: - builder.sort(SortBuilders.fieldSort(randomAsciiOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); + builder.sort(SortBuilders.fieldSort(randomAlphaOfLengthBetween(5, 20)).order(randomFrom(SortOrder.values()))); break; case 1: - builder.sort(SortBuilders.geoDistanceSort(randomAsciiOfLengthBetween(5, 20), + builder.sort(SortBuilders.geoDistanceSort(randomAlphaOfLengthBetween(5, 20), AbstractQueryTestCase.randomGeohash(1, 12)).order(randomFrom(SortOrder.values()))); break; case 2: @@ -246,10 +246,10 @@ public static SearchSourceBuilder randomSearchSourceBuilder( ScriptSortBuilder.ScriptSortType.NUMBER).order(randomFrom(SortOrder.values()))); break; case 4: - builder.sort(randomAsciiOfLengthBetween(5, 20)); + builder.sort(randomAlphaOfLengthBetween(5, 20)); break; case 5: - builder.sort(randomAsciiOfLengthBetween(5, 20), randomFrom(SortOrder.values())); + builder.sort(randomAlphaOfLengthBetween(5, 20), randomFrom(SortOrder.values())); break; } } @@ -281,7 +281,7 @@ public static SearchSourceBuilder randomSearchSourceBuilder( jsonBuilder.value(randomDouble()); break; case 4: - jsonBuilder.value(randomAsciiOfLengthBetween(5, 20)); + jsonBuilder.value(randomAlphaOfLengthBetween(5, 20)); break; case 5: jsonBuilder.value(randomBoolean()); @@ -293,7 +293,7 @@ public static SearchSourceBuilder randomSearchSourceBuilder( jsonBuilder.value(randomShort()); break; case 8: - jsonBuilder.value(new Text(randomAsciiOfLengthBetween(5, 20))); + jsonBuilder.value(new Text(randomAlphaOfLengthBetween(5, 20))); break; } } @@ -322,13 +322,13 @@ public static SearchSourceBuilder randomSearchSourceBuilder( } } if (randomBoolean()) { - builder.aggregation(AggregationBuilders.avg(randomAsciiOfLengthBetween(5, 20))); + builder.aggregation(AggregationBuilders.avg(randomAlphaOfLengthBetween(5, 20))); } if (randomBoolean()) { builder.ext(randomExtBuilders.get()); } if (randomBoolean()) { - String field = randomBoolean() ? null : randomAsciiOfLengthBetween(5, 20); + String field = randomBoolean() ? null : randomAlphaOfLengthBetween(5, 20); int max = between(2, 1000); int id = randomInt(max-1); if (field == null) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java index ad414db491fb9..cb271b25b3c68 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java @@ -183,12 +183,12 @@ public static void beforeClass() { indexSettings = Settings.builder() .put(IndexMetaData.SETTING_VERSION_CREATED, indexVersionCreated).build(); - index = new Index(randomAsciiOfLengthBetween(1, 10), "_na_"); + index = new Index(randomAlphaOfLengthBetween(1, 10), "_na_"); //create some random type with some default field, those types will stick around for all of the subclasses currentTypes = new String[randomIntBetween(0, 5)]; for (int i = 0; i < currentTypes.length; i++) { - String type = randomAsciiOfLengthBetween(1, 10); + String type = randomAlphaOfLengthBetween(1, 10); currentTypes[i] = type; } //set some random types to be queried as part the search request, before each test @@ -248,7 +248,7 @@ public final QB createTestQueryBuilder() { * make sure query names are unique by suffixing them with increasing counter */ private static String createUniqueRandomName() { - String queryName = randomAsciiOfLengthBetween(1, 10) + queryNameId; + String queryName = randomAlphaOfLengthBetween(1, 10) + queryNameId; queryNameId++; return queryName; } @@ -597,8 +597,8 @@ public void testToQuery() throws IOException { QB secondQuery = copyQuery(firstQuery); // query _name never should affect the result of toQuery, we randomly set it to make sure if (randomBoolean()) { - secondQuery.queryName(secondQuery.queryName() == null ? randomAsciiOfLengthBetween(1, 30) : secondQuery.queryName() - + randomAsciiOfLengthBetween(1, 10)); + secondQuery.queryName(secondQuery.queryName() == null ? randomAlphaOfLengthBetween(1, 30) : secondQuery.queryName() + + randomAlphaOfLengthBetween(1, 10)); } searchContext = getSearchContext(randomTypes, context); Query secondLuceneQuery = rewriteQuery(secondQuery, context).toQuery(context); @@ -733,8 +733,8 @@ public void testEqualsAndHashcode() throws IOException { private QB changeNameOrBoost(QB original) throws IOException { QB secondQuery = copyQuery(original); if (randomBoolean()) { - secondQuery.queryName(secondQuery.queryName() == null ? randomAsciiOfLengthBetween(1, 30) : secondQuery.queryName() - + randomAsciiOfLengthBetween(1, 10)); + secondQuery.queryName(secondQuery.queryName() == null ? randomAlphaOfLengthBetween(1, 30) : secondQuery.queryName() + + randomAlphaOfLengthBetween(1, 10)); } else { secondQuery.boost(original.boost() + 1f + randomFloat()); } @@ -773,7 +773,7 @@ protected static Object getRandomValueForFieldName(String fieldName) { JsonStringEncoder encoder = JsonStringEncoder.getInstance(); value = new String(encoder.quoteAsString(randomUnicodeOfLength(10))); } else { - value = randomAsciiOfLengthBetween(1, 10); + value = randomAlphaOfLengthBetween(1, 10); } break; case INT_FIELD_NAME: @@ -789,7 +789,7 @@ protected static Object getRandomValueForFieldName(String fieldName) { value = new DateTime(System.currentTimeMillis(), DateTimeZone.UTC).toString(); break; default: - value = randomAsciiOfLengthBetween(1, 10); + value = randomAlphaOfLengthBetween(1, 10); } return value; } @@ -798,7 +798,7 @@ protected static String getRandomQueryText() { int terms = randomIntBetween(0, 3); StringBuilder builder = new StringBuilder(); for (int i = 0; i < terms; i++) { - builder.append(randomAsciiOfLengthBetween(1, 10)).append(" "); + builder.append(randomAlphaOfLengthBetween(1, 10)).append(" "); } return builder.toString().trim(); } @@ -809,7 +809,7 @@ protected static String getRandomQueryText() { protected static String getRandomFieldName() { // if no type is set then return a random field name if (currentTypes.length == 0 || randomBoolean()) { - return randomAsciiOfLengthBetween(1, 10); + return randomAlphaOfLengthBetween(1, 10); } return randomFrom(MAPPED_LEAF_FIELD_NAMES); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index b4239ccd77a16..db15ac0c33533 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -705,7 +705,7 @@ public Settings indexSettings() { } // 30% of the time if (randomInt(9) < 3) { - final String dataPath = randomAsciiOfLength(10); + final String dataPath = randomAlphaOfLength(10); logger.info("using custom data_path for index: [{}]", dataPath); builder.put(IndexMetaData.SETTING_DATA_PATH, dataPath); } @@ -1963,7 +1963,7 @@ public static Path randomRepoPath(Settings settings) { assert repoFiles.length > 0; Path path; do { - path = repoFiles[0].resolve(randomAsciiOfLength(10)); + path = repoFiles[0].resolve(randomAlphaOfLength(10)); } while (Files.exists(path)); return path; } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index fa659e06fb214..587d390f300ca 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -572,11 +572,11 @@ public static T randomFrom(Random random, Collection collection) { return RandomPicks.randomFrom(random, collection); } - public static String randomAsciiOfLengthBetween(int minCodeUnits, int maxCodeUnits) { + public static String randomAlphaOfLengthBetween(int minCodeUnits, int maxCodeUnits) { return RandomizedTest.randomAsciiOfLengthBetween(minCodeUnits, maxCodeUnits); } - public static String randomAsciiOfLength(int codeUnits) { + public static String randomAlphaOfLength(int codeUnits) { return RandomizedTest.randomAsciiOfLength(codeUnits); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruptionTests.java b/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruptionTests.java index edc261c175959..298ca869ae51c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruptionTests.java +++ b/test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruptionTests.java @@ -48,10 +48,10 @@ private void checkTwoPartitions(TwoPartitions topology, Set partition1, assertTrue(topology.disrupt(randomFrom(partition2), randomFrom(partition1))); assertFalse(topology.disrupt(randomFrom(partition1), randomFrom(partition1))); assertFalse(topology.disrupt(randomFrom(partition2), randomFrom(partition2))); - assertFalse(topology.disrupt(randomAsciiOfLength(10), randomFrom(partition1))); - assertFalse(topology.disrupt(randomAsciiOfLength(10), randomFrom(partition2))); - assertFalse(topology.disrupt(randomFrom(partition1), randomAsciiOfLength(10))); - assertFalse(topology.disrupt(randomFrom(partition2), randomAsciiOfLength(10))); + assertFalse(topology.disrupt(randomAlphaOfLength(10), randomFrom(partition1))); + assertFalse(topology.disrupt(randomAlphaOfLength(10), randomFrom(partition2))); + assertFalse(topology.disrupt(randomFrom(partition1), randomAlphaOfLength(10))); + assertFalse(topology.disrupt(randomFrom(partition2), randomAlphaOfLength(10))); } assertTrue(topology.getMajoritySide().size() >= topology.getMinoritySide().size()); } @@ -74,7 +74,7 @@ public void testIsolateAll() { public void testBridge() { Set partition1 = generateRandomStringSet(1, 10); Set partition2 = generateRandomStringSet(1, 10); - String bridgeNode = randomAsciiOfLength(10); + String bridgeNode = randomAlphaOfLength(10); Bridge topology = new Bridge(bridgeNode, partition1, partition2); checkBridge(topology, bridgeNode, partition1, partition2); } @@ -97,12 +97,12 @@ private void checkBridge(Bridge topology, String bridgeNode, Set partiti assertFalse(topology.disrupt(randomFrom(partition2), randomFrom(partition2))); assertFalse(topology.disrupt(randomFrom(partition2), bridgeNode)); assertFalse(topology.disrupt(bridgeNode, randomFrom(partition2))); - assertFalse(topology.disrupt(randomAsciiOfLength(10), randomFrom(partition1))); - assertFalse(topology.disrupt(randomAsciiOfLength(10), randomFrom(partition2))); - assertFalse(topology.disrupt(randomAsciiOfLength(10), bridgeNode)); - assertFalse(topology.disrupt(randomFrom(partition1), randomAsciiOfLength(10))); - assertFalse(topology.disrupt(randomFrom(partition2), randomAsciiOfLength(10))); - assertFalse(topology.disrupt(bridgeNode, randomAsciiOfLength(10))); + assertFalse(topology.disrupt(randomAlphaOfLength(10), randomFrom(partition1))); + assertFalse(topology.disrupt(randomAlphaOfLength(10), randomFrom(partition2))); + assertFalse(topology.disrupt(randomAlphaOfLength(10), bridgeNode)); + assertFalse(topology.disrupt(randomFrom(partition1), randomAlphaOfLength(10))); + assertFalse(topology.disrupt(randomFrom(partition2), randomAlphaOfLength(10))); + assertFalse(topology.disrupt(bridgeNode, randomAlphaOfLength(10))); } } @@ -110,7 +110,7 @@ private Set generateRandomStringSet(int minSize, int maxSize) { assert maxSize >= minSize; Set result = new HashSet<>(); for (int i = 0; i < minSize + randomInt(maxSize - minSize); i++) { - result.add(randomAsciiOfLength(10)); + result.add(randomAlphaOfLength(10)); } return result; } diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java index 0e5c86863f9d5..cdcdc3c99c37b 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java @@ -80,7 +80,7 @@ private static Map randomStringObjectMap(int depth) { Map result = new HashMap<>(); int entries = randomInt(10); for (int i = 0; i < entries; i++) { - String key = randomAsciiOfLengthBetween(5, 15); + String key = randomAlphaOfLengthBetween(5, 15); int suprise = randomIntBetween(0, 4); switch (suprise) { case 0: @@ -108,7 +108,7 @@ private static Map randomStringObjectMap(int depth) { } } if (depth > 0) { - result.put(randomAsciiOfLengthBetween(5, 15), randomStringObjectMap(depth - 1)); + result.put(randomAlphaOfLengthBetween(5, 15), randomStringObjectMap(depth - 1)); } return result; } @@ -123,6 +123,6 @@ public void testRandomUniqueTotallyUnique() { } public void testRandomUniqueNormalUsageAlwayMoreThanOne() { - assertThat(randomUnique(() -> randomAsciiOfLengthBetween(1, 20), 10), hasSize(greaterThan(0))); + assertThat(randomUnique(() -> randomAlphaOfLengthBetween(1, 20), 10), hasSize(greaterThan(0))); } }