diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/UniqueTokenFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/UniqueTokenFilterTests.java index aa0cecbf06c92..99874363df72b 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/UniqueTokenFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/UniqueTokenFilterTests.java @@ -124,7 +124,7 @@ public void testOldVersionGetXUniqueTokenFilter() throws IOException { Settings settings = Settings.builder() .put( IndexMetadata.SETTING_VERSION_CREATED, - IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.UNIQUE_TOKEN_FILTER_POS_FIX) + IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.UNIQUE_TOKEN_FILTER_POS_FIX) ) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProviderTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProviderTests.java index 6f1ec12da75d4..bcacd1a064192 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProviderTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamIndexSettingsProviderTests.java @@ -59,7 +59,7 @@ public void setup() { im -> MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), im.getSettings(), im.getIndex().getName()) ); indexVersion = randomBoolean() - ? IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.TSID_CREATED_DURING_ROUTING) + ? IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.TSID_CREATED_DURING_ROUTING) : IndexVersionUtils.randomVersionBetween(IndexVersions.TSID_CREATED_DURING_ROUTING, IndexVersion.current()); indexDimensionsTsidStrategyEnabledSetting = usually(); expectedIndexDimensionsTsidOptimizationEnabled = indexDimensionsTsidStrategyEnabledSetting diff --git a/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/GeoBoundingBoxQueryLegacyGeoShapeIT.java b/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/GeoBoundingBoxQueryLegacyGeoShapeIT.java index d2dd5b7442dd2..9a3e40de1681e 100644 --- a/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/GeoBoundingBoxQueryLegacyGeoShapeIT.java +++ b/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/GeoBoundingBoxQueryLegacyGeoShapeIT.java @@ -45,6 +45,6 @@ public XContentBuilder getMapping() throws IOException { @Override public IndexVersion randomSupportedVersion() { - return IndexVersionUtils.randomCompatibleWriteVersion(random()); + return IndexVersionUtils.randomCompatibleWriteVersion(); } } diff --git a/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/LegacyGeoShapeIT.java b/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/LegacyGeoShapeIT.java index 73b7c07c45fe5..ef15b5f257d23 100644 --- a/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/LegacyGeoShapeIT.java +++ b/modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/LegacyGeoShapeIT.java @@ -41,7 +41,7 @@ protected void getGeoShapeMapping(XContentBuilder b) throws IOException { @Override protected IndexVersion randomSupportedVersion() { - return IndexVersionUtils.randomCompatibleWriteVersion(random()); + return IndexVersionUtils.randomCompatibleWriteVersion(); } @Override diff --git a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java index bd5b289abc588..2e5867bf0458a 100644 --- a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java +++ b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoJsonShapeParserTests.java @@ -388,7 +388,7 @@ public void testParse3DPolygon() throws IOException, ParseException { LinearRing shell = GEOMETRY_FACTORY.createLinearRing(shellCoordinates.toArray(new Coordinate[shellCoordinates.size()])); Polygon expected = GEOMETRY_FACTORY.createPolygon(shell, null); - final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); final LegacyGeoShapeFieldMapper mapperBuilder = new LegacyGeoShapeFieldMapper.Builder("test", version, false, true).build( MapperBuilderContext.root(false, false) ); diff --git a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoWKTShapeParserTests.java b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoWKTShapeParserTests.java index f944a368b2a6c..e280e57ee8d7a 100644 --- a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoWKTShapeParserTests.java +++ b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/GeoWKTShapeParserTests.java @@ -325,7 +325,7 @@ public void testParseMixedDimensionPolyWithHoleStoredZ() throws IOException { XContentParser parser = createParser(xContentBuilder); parser.nextToken(); - final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); final LegacyGeoShapeFieldMapper mapperBuilder = new LegacyGeoShapeFieldMapper.Builder("test", version, false, true).build( MapperBuilderContext.root(false, false) ); @@ -349,7 +349,7 @@ public void testParsePolyWithStoredZ() throws IOException { XContentParser parser = createParser(xContentBuilder); parser.nextToken(); - final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); final LegacyGeoShapeFieldMapper mapperBuilder = new LegacyGeoShapeFieldMapper.Builder("test", version, false, true).build( MapperBuilderContext.root(false, false) ); @@ -365,7 +365,7 @@ public void testParseOpenPolygon() throws IOException { XContentParser parser = createParser(xContentBuilder); parser.nextToken(); - final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + final IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); final LegacyGeoShapeFieldMapper defaultMapperBuilder = new LegacyGeoShapeFieldMapper.Builder("test", version, false, true).coerce( false ).build(MapperBuilderContext.root(false, false)); diff --git a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldMapperTests.java b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldMapperTests.java index 97f668d37e22d..a9c84a0b46b2c 100644 --- a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldMapperTests.java +++ b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldMapperTests.java @@ -111,7 +111,7 @@ protected boolean supportsMeta() { @Override protected IndexVersion getVersion() { - return IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + return IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); } public void testLegacySwitches() throws IOException { diff --git a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldTypeTests.java b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldTypeTests.java index f5e09f19c1a71..72bca20250099 100644 --- a/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldTypeTests.java +++ b/modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/mapper/LegacyGeoShapeFieldTypeTests.java @@ -37,7 +37,7 @@ public void testSetStrategyName() { } public void testFetchSourceValue() throws IOException { - IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); MappedFieldType mapper = new LegacyGeoShapeFieldMapper.Builder("field", version, false, true).build( MapperBuilderContext.root(false, false) ).fieldType(); diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/CandidateQueryTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/CandidateQueryTests.java index 9b285036d450e..7d65d1b22b191 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/CandidateQueryTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/CandidateQueryTests.java @@ -641,7 +641,7 @@ public void testRangeQueries() throws Exception { IndexSearcher shardSearcher = newSearcher(directoryReader); shardSearcher.setQueryCache(null); - IndexVersion v = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion v = IndexVersionUtils.randomCompatibleVersion(); MemoryIndex memoryIndex = MemoryIndex.fromDocument(Collections.singleton(new IntPoint("int_field", 3)), new WhitespaceAnalyzer()); IndexSearcher percolateSearcher = memoryIndex.createSearcher(); Query query = fieldType.percolateQuery( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CloneIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CloneIndexIT.java index 3402b7c47ff05..46578fc28e4ed 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CloneIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CloneIndexIT.java @@ -41,7 +41,7 @@ protected boolean forbidPrivateIndexSettings() { } public void testCreateCloneIndex() { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); int numPrimaryShards = randomIntBetween(1, 5); prepareCreate("source").setSettings( Settings.builder().put(indexSettings()).put("number_of_shards", numPrimaryShards).put("index.version.created", version) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java index ffa479bfe1ff2..1723af5138fd7 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java @@ -347,7 +347,7 @@ private static IndexMetadata indexMetadata(final Client client, final String ind } public void testCreateSplitIndex() { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); prepareCreate("source").setSettings( Settings.builder().put(indexSettings()).put("number_of_shards", 1).put("index.version.created", version) ).get(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterStateDiffIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterStateDiffIT.java index 67cead7b17371..cd7e0c54b1927 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterStateDiffIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterStateDiffIT.java @@ -236,7 +236,7 @@ private ClusterState.Builder randomCoordinationMetadata(ClusterState clusterStat } private DiscoveryNode randomNode(String nodeId) { - Version nodeVersion = VersionUtils.randomVersion(random()); + Version nodeVersion = VersionUtils.randomVersion(); IndexVersion indexVersion = randomVersion(); return DiscoveryNodeUtils.builder(nodeId) .roles(emptySet()) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java index 88cca3308ac4f..dce956be06e39 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java @@ -48,7 +48,7 @@ public void testCanRecoverFromStoreWithoutPeerRecoveryRetentionLease() throws Ex Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) - .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomCompatibleWriteVersion(random())) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomCompatibleWriteVersion()) ) ); ensureGreen(INDEX_NAME); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java index 6c67bd2a98606..9e93e812992b2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java @@ -56,7 +56,7 @@ protected boolean forbidPrivateIndexSettings() { return false; } - private final IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + private final IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); private IndexRequestBuilder indexCity(String idx, String name, String... latLons) throws Exception { XContentBuilder source = jsonBuilder().startObject().field("city", name); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java index 1e13bcd09373c..288c5a588d7ab 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java @@ -48,7 +48,7 @@ protected boolean forbidPrivateIndexSettings() { return false; } - private final IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + private final IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); static Map expectedDocCountsForGeoHash = null; static Map multiValuedExpectedDocCountsForGeoHash = null; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java index a55edf3782bcc..bec28b4411f13 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java @@ -748,7 +748,7 @@ public void testDateWithoutOrigin() throws Exception { } public void testManyDocsLin() throws Exception { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = jsonBuilder().startObject() .startObject("_doc") diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoBoundingBoxQueryGeoPointIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoBoundingBoxQueryGeoPointIT.java index 8104e4ed7a825..2a89cc0b6b131 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoBoundingBoxQueryGeoPointIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoBoundingBoxQueryGeoPointIT.java @@ -32,6 +32,6 @@ public XContentBuilder getMapping() throws IOException { @Override public IndexVersion randomSupportedVersion() { - return IndexVersionUtils.randomCompatibleWriteVersion(random()); + return IndexVersionUtils.randomCompatibleWriteVersion(); } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoDistanceIT.java index a309fa81f6dc1..3a0e38d6a5df7 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoDistanceIT.java @@ -96,7 +96,7 @@ protected boolean forbidPrivateIndexSettings() { @Before public void setupTestIndex() throws IOException { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoPolygonIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoPolygonIT.java index aadefd9bd8018..2f12819a5135d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoPolygonIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoPolygonIT.java @@ -39,7 +39,7 @@ protected boolean forbidPrivateIndexSettings() { @Override protected void setupSuiteScopeCluster() throws Exception { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceIT.java index f55d4505f3f58..61b4598008f37 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceIT.java @@ -45,7 +45,7 @@ protected boolean forbidPrivateIndexSettings() { } public void testDistanceSortingMVFields() throws Exception { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() @@ -237,7 +237,7 @@ public void testDistanceSortingMVFields() throws Exception { // Regression bug: // https://github.com/elastic/elasticsearch/issues/2851 public void testDistanceSortingWithMissingGeoPoint() throws Exception { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() @@ -299,7 +299,7 @@ public void testDistanceSortingWithMissingGeoPoint() throws Exception { } public void testDistanceSortingNestedFields() throws Exception { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() .startObject() @@ -551,7 +551,7 @@ public void testDistanceSortingNestedFields() throws Exception { * Issue 3073 */ public void testGeoDistanceFilter() throws IOException { - IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); double lat = 40.720611; double lon = -73.998776; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java index d53c90a5d1e28..16b768fa10cf6 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java @@ -60,7 +60,7 @@ public void testManyToManyGeoPoints() throws ExecutionException, InterruptedExce * |___________________________ * 1 2 3 4 5 6 7 */ - IndexVersion version = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); @@ -152,7 +152,7 @@ public void testSingeToManyAvgMedian() throws ExecutionException, InterruptedExc * d1 = (0, 1), (0, 4), (0, 10); so avg. distance is 5, median distance is 4 * d2 = (0, 1), (0, 5), (0, 6); so avg. distance is 4, median distance is 5 */ - IndexVersion version = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); @@ -225,7 +225,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept * |______________________ * 1 2 3 4 5 6 */ - IndexVersion version = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion version = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleWriteVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 33be6c39ffb9a..33309e364ae8d 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -238,7 +238,7 @@ public TestException(StreamInput in) throws IOException { } private T serialize(T exception) throws IOException { - return serialize(exception, TransportVersionUtils.randomCompatibleVersion(random())); + return serialize(exception, TransportVersionUtils.randomCompatibleVersion()); } private T serialize(T exception, TransportVersion version) throws IOException { @@ -252,7 +252,7 @@ private T serialize(T exception, TransportVersion version) } private T serializeOptional(T exception) throws IOException { - return serializeOptional(exception, TransportVersionUtils.randomCompatibleVersion(random())); + return serializeOptional(exception, TransportVersionUtils.randomCompatibleVersion()); } private T serializeOptional(T exception, TransportVersion version) throws IOException { @@ -379,7 +379,7 @@ public void testActionTransportException() throws IOException { public void testSearchContextMissingException() throws IOException { ShardSearchContextId contextId = new ShardSearchContextId(UUIDs.randomBase64UUID(), randomLong()); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); SearchContextMissingException ex = serialize(new SearchContextMissingException(contextId), version); assertThat(ex.contextId().getId(), equalTo(contextId.getId())); assertThat(ex.contextId().getSessionId(), equalTo(contextId.getSessionId())); @@ -388,7 +388,7 @@ public void testSearchContextMissingException() throws IOException { public void testCircuitBreakingException() throws IOException { CircuitBreakingException ex = serialize( new CircuitBreakingException("Too large", 0, 100, CircuitBreaker.Durability.TRANSIENT), - TransportVersionUtils.randomCompatibleVersion(random()) + TransportVersionUtils.randomCompatibleVersion() ); assertEquals("Too large", ex.getMessage()); assertEquals(100, ex.getByteLimit()); @@ -397,7 +397,7 @@ public void testCircuitBreakingException() throws IOException { } public void testTooManyBucketsException() throws IOException { - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); MultiBucketConsumerService.TooManyBucketsException ex = serialize( new MultiBucketConsumerService.TooManyBucketsException("Too many buckets", 100), version @@ -933,7 +933,7 @@ public void testElasticsearchRemoteException() throws IOException { public void testShardLockObtainFailedException() throws IOException { ShardId shardId = new ShardId("foo", "_na_", 1); ShardLockObtainFailedException orig = new ShardLockObtainFailedException(shardId, "boom"); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); ShardLockObtainFailedException ex = serialize(orig, version); assertEquals(orig.getMessage(), ex.getMessage()); assertEquals(orig.getShardId(), ex.getShardId()); @@ -941,7 +941,7 @@ public void testShardLockObtainFailedException() throws IOException { public void testSnapshotInProgressException() throws IOException { SnapshotInProgressException orig = new SnapshotInProgressException("boom"); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); SnapshotInProgressException ex = serialize(orig, version); assertEquals(orig.getMessage(), ex.getMessage()); } diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index 5e10a7d37aea1..41afa0c7c1c06 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -56,8 +56,8 @@ public void testVersionComparison() { public void testMin() { assertEquals(VersionUtils.getPreviousVersion(), Version.min(Version.CURRENT, VersionUtils.getPreviousVersion())); assertEquals(Version.fromString("1.0.1"), Version.min(Version.fromString("1.0.1"), Version.CURRENT)); - Version version = VersionUtils.randomVersion(random()); - Version version1 = VersionUtils.randomVersion(random()); + Version version = randomVersion(); + Version version1 = randomVersion(); if (version.id <= version1.id) { assertEquals(version, Version.min(version1, version)); } else { @@ -68,8 +68,8 @@ public void testMin() { public void testMax() { assertEquals(Version.CURRENT, Version.max(Version.CURRENT, VersionUtils.getPreviousVersion())); assertEquals(Version.CURRENT, Version.max(Version.fromString("1.0.1"), Version.CURRENT)); - Version version = VersionUtils.randomVersion(random()); - Version version1 = VersionUtils.randomVersion(random()); + Version version = randomVersion(); + Version version1 = randomVersion(); if (version.id >= version1.id) { assertEquals(version, Version.max(version1, version)); } else { @@ -81,7 +81,7 @@ public void testVersionConstantPresent() { assertThat(Version.CURRENT, sameInstance(Version.fromId(Version.CURRENT.id))); final int iters = scaledRandomIntBetween(20, 100); for (int i = 0; i < iters; i++) { - Version version = randomVersion(random()); + Version version = randomVersion(); assertThat(version, sameInstance(Version.fromId(version.id))); } } @@ -89,7 +89,7 @@ public void testVersionConstantPresent() { public void testCURRENTIsLatest() { final int iters = scaledRandomIntBetween(100, 1000); for (int i = 0; i < iters; i++) { - Version version = randomVersion(random()); + Version version = randomVersion(); if (version != Version.CURRENT) { assertThat( "Version: " + version + " should be before: " + Version.CURRENT + " but wasn't", @@ -103,7 +103,7 @@ public void testCURRENTIsLatest() { public void testVersionFromString() { final int iters = scaledRandomIntBetween(100, 1000); for (int i = 0; i < iters; i++) { - Version version = randomVersion(random()); + Version version = randomVersion(); assertThat(Version.fromString(version.toString()), sameInstance(version)); } } @@ -162,7 +162,7 @@ public void testToString() { public void testParseVersion() { final int iters = scaledRandomIntBetween(100, 1000); for (int i = 0; i < iters; i++) { - Version version = randomVersion(random()); + Version version = randomVersion(); if (random().nextBoolean()) { version = new Version(version.id); } @@ -239,8 +239,8 @@ public void testIsCompatible() { assertFalse(isCompatible(Version.fromId(5000099), Version.fromString("6.0.0"))); assertFalse(isCompatible(Version.fromId(5000099), Version.fromString("7.0.0"))); - Version a = randomVersion(random()); - Version b = randomVersion(random()); + Version a = randomVersion(); + Version b = randomVersion(); assertThat(a.isCompatible(b), equalTo(b.isCompatible(a))); } diff --git a/server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java b/server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java index 1db1b62facc9d..c58137e31091f 100644 --- a/server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java +++ b/server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java @@ -34,7 +34,7 @@ public void testOriginalIndicesSerialization() throws IOException { OriginalIndices originalIndices = randomOriginalIndices(); BytesStreamOutput out = new BytesStreamOutput(); - out.setTransportVersion(randomCompatibleVersion(random())); + out.setTransportVersion(randomCompatibleVersion()); OriginalIndices.writeOriginalIndices(originalIndices, out); StreamInput in = out.bytes().streamInput(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequestTests.java index 000516dbbf606..3f06a2f98404e 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequestTests.java @@ -39,7 +39,7 @@ public void testBWCSerialization() throws IOException { ); TransportVersion latest = TransportVersion.current(); - TransportVersion previous = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion previous = TransportVersionUtils.randomCompatibleVersion(); try (BytesStreamOutput out = new BytesStreamOutput()) { out.setTransportVersion(latest); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfoTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfoTests.java index 9d01f411d35aa..fe057a06ebbac 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfoTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfoTests.java @@ -47,7 +47,7 @@ public void testGetInfo() { Build.current(), DiscoveryNodeUtils.builder("test_node") .roles(emptySet()) - .version(VersionUtils.randomVersion(random()), IndexVersions.ZERO, IndexVersionUtils.randomCompatibleVersion(random())) + .version(VersionUtils.randomVersion(), IndexVersions.ZERO, IndexVersionUtils.randomCompatibleVersion()) .build(), null, null, diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalActionTests.java index 950135418fdcb..b769dca837721 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalActionTests.java @@ -72,7 +72,7 @@ private DiscoveryNode randomNode(String nodeName, String nodeId) { return DiscoveryNodeUtils.builder(nodeId) .name(nodeName) .roles(emptySet()) - .version(randomVersion(random()), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) + .version(randomVersion(), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) .build(); } } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java index 8cf659e013f45..93b280d2d072d 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java @@ -685,7 +685,7 @@ private static ShardStats createShardStats(ShardId shardId) { public static NodeStats createNodeStats() { DiscoveryNode node = DiscoveryNodeUtils.builder("test_node") .roles(emptySet()) - .version(VersionUtils.randomVersion(random()), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) + .version(VersionUtils.randomVersion(), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) .build(); NodeIndicesStats nodeIndicesStats = null; if (frequently()) { diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java index d4a3d29ea68f2..611b96e774b6e 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java @@ -45,7 +45,7 @@ public void testSerialization() throws Exception { request.routing(routings); } - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); try (BytesStreamOutput out = new BytesStreamOutput()) { out.setTransportVersion(version); request.writeTo(out); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java index 5f6b712586822..f7501256397e1 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java @@ -56,7 +56,7 @@ public void testSerialization() throws Exception { clusterSearchShardsGroups[i] = new ClusterSearchShardsGroup(shardId, new ShardRouting[] { shardRouting }); DiscoveryNodeUtils.Builder node = DiscoveryNodeUtils.builder(shardRouting.currentNodeId()) .address(new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF))) - .version(randomCompatibleVersion(random(), Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()); + .version(randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()); nodes.add(node.build()); AliasFilter aliasFilter; if (randomBoolean()) { @@ -76,7 +76,7 @@ public void testSerialization() throws Exception { List entries = new ArrayList<>(); entries.addAll(searchModule.getNamedWriteables()); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(entries); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); try (BytesStreamOutput out = new BytesStreamOutput()) { out.setTransportVersion(version); clusterSearchShardsResponse.writeTo(out); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java index 5b76990e5c2c4..405480b2c4023 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java @@ -38,7 +38,7 @@ public void testSerialization() throws Exception { .indices("testindex", "testindex2") .indicesOptions(indicesOptions); - TransportVersion testVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion testVersion = TransportVersionUtils.randomCompatibleVersion(); if (randomBoolean()) { clusterStateRequest.waitForMetadataVersion(randomLongBetween(1, Long.MAX_VALUE)); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java index 3839a7ea43eb5..a3e4c0d56d1f8 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/MappingStatsTests.java @@ -573,7 +573,7 @@ public void testChecksForCancellation() { public void testWriteTo() throws IOException { MappingStats instance = createTestInstance(); BytesStreamOutput out = new BytesStreamOutput(); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); out.setTransportVersion(version); instance.writeTo(out); StreamInput in = StreamInput.wrap(out.bytes().toBytesRef().bytes); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequestTests.java index c650dc0c08348..bd766c01bb1e0 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequestTests.java @@ -23,7 +23,7 @@ public void testGetIndexedScriptRequestSerialization() throws IOException { GetStoredScriptRequest request = new GetStoredScriptRequest(TEST_REQUEST_TIMEOUT, "id"); BytesStreamOutput out = new BytesStreamOutput(); - out.setTransportVersion(randomVersion(random())); + out.setTransportVersion(randomVersion()); request.writeTo(out); StreamInput in = out.bytes().streamInput(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzersResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzersResponseTests.java index 036d7273900a3..06e576ea323ac 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzersResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzersResponseTests.java @@ -130,7 +130,7 @@ public void testSerialization() throws IOException { response, writableRegistry(), ReloadAnalyzersResponse::new, - TransportVersionUtils.randomVersion(random()) + TransportVersionUtils.randomVersion() ); assertEquals(response.getReloadDetails(), copy.getReloadDetails()); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestTests.java index c872281134e76..15d59e06c38b2 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestTests.java @@ -42,7 +42,7 @@ public void testBwcSerialization() throws Exception { { final CloseIndexRequest request = randomRequest(); try (BytesStreamOutput out = new BytesStreamOutput()) { - out.setTransportVersion(TransportVersionUtils.randomCompatibleVersion(random())); + out.setTransportVersion(TransportVersionUtils.randomCompatibleVersion()); request.writeTo(out); try (StreamInput in = out.bytes().streamInput()) { @@ -60,7 +60,7 @@ public void testBwcSerialization() throws Exception { } { final CloseIndexRequest sample = randomRequest(); - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); try (BytesStreamOutput out = new BytesStreamOutput()) { out.setTransportVersion(version); sample.getParentTask().writeTo(out); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java index fed735a7ecd0f..af13f5bb6195e 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java @@ -202,9 +202,9 @@ public void setUp() throws Exception { threadPool = new TestThreadPool(getClass().getName()); DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node") .version( - VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + VersionUtils.randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ) .build(); clusterService = createClusterService(threadPool, discoveryNode); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java index fb2e8963614a3..bc8977b6d8553 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java @@ -90,9 +90,9 @@ public void setUp() throws Exception { super.setUp(); DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node") .version( - VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + VersionUtils.randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ) .build(); clusterService = createClusterService(threadPool, discoveryNode); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionTests.java index 8296d52900c98..6126c5c6da9e5 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionTests.java @@ -111,9 +111,9 @@ public void setUp() throws Exception { threadPool = new TestThreadPool(getClass().getName()); DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node") .version( - VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + VersionUtils.randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ) .build(); clusterService = createClusterService(threadPool, discoveryNode); diff --git a/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeResponseTests.java b/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeResponseTests.java index 76342bca17fcd..683780512439b 100644 --- a/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesNodeResponseTests.java @@ -111,7 +111,7 @@ public void testSerializeNodeResponseBetweenNewNodes() throws Exception { ); Randomness.shuffle(indexResponses); FieldCapabilitiesNodeResponse inNode = randomNodeResponse(indexResponses); - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final FieldCapabilitiesNodeResponse outNode = copyInstance(inNode, version); assertThat(outNode.getFailures().keySet(), equalTo(inNode.getFailures().keySet())); assertThat(outNode.getUnmatchedShardIds(), equalTo(inNode.getUnmatchedShardIds())); diff --git a/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java b/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java index 01de792ece29e..ed920a0b963cf 100644 --- a/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesResponseTests.java @@ -164,7 +164,7 @@ public void testSerializeCCSResponseBetweenNewClusters() throws Exception { ); Randomness.shuffle(indexResponses); FieldCapabilitiesResponse inResponse = randomCCSResponse(indexResponses); - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final FieldCapabilitiesResponse outResponse = copyInstance(inResponse, version); assertThat( outResponse.getFailures().stream().flatMap(f -> Arrays.stream(f.getIndices())).toList(), diff --git a/server/src/test/java/org/elasticsearch/action/fieldcaps/RequestDispatcherTests.java b/server/src/test/java/org/elasticsearch/action/fieldcaps/RequestDispatcherTests.java index 2365a5479d8f9..de34865af8130 100644 --- a/server/src/test/java/org/elasticsearch/action/fieldcaps/RequestDispatcherTests.java +++ b/server/src/test/java/org/elasticsearch/action/fieldcaps/RequestDispatcherTests.java @@ -117,7 +117,7 @@ public void testHappyCluster() throws Exception { DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); int numNodes = randomIntBetween(1, 10); for (int i = 0; i < numNodes; i++) { - discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(random()), IndexVersionUtils.randomVersion())); + discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(), IndexVersionUtils.randomVersion())); } ProjectMetadata.Builder metadata = ProjectMetadata.builder(projectId); for (String index : allIndices) { @@ -189,7 +189,7 @@ public void testRetryThenOk() throws Exception { DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); int numNodes = randomIntBetween(2, 10); for (int i = 0; i < numNodes; i++) { - discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(random()), IndexVersionUtils.randomVersion())); + discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(), IndexVersionUtils.randomVersion())); } ProjectMetadata.Builder metadata = ProjectMetadata.builder(projectId); for (String index : allIndices) { @@ -312,7 +312,7 @@ public void testRetryButFails() throws Exception { DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); int numNodes = randomIntBetween(1, 10); for (int i = 0; i < numNodes; i++) { - discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(random()), IndexVersionUtils.randomVersion())); + discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(), IndexVersionUtils.randomVersion())); } ProjectMetadata.Builder metadata = ProjectMetadata.builder(projectId); for (String index : allIndices) { @@ -437,7 +437,7 @@ public void testSuccessWithAnyMatch() throws Exception { DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); int numNodes = randomIntBetween(1, 10); for (int i = 0; i < numNodes; i++) { - discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(random()), IndexVersionUtils.randomVersion())); + discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(), IndexVersionUtils.randomVersion())); } ProjectMetadata.Builder metadata = ProjectMetadata.builder(projectId); for (String index : allIndices) { @@ -536,7 +536,7 @@ public void testStopAfterAllShardsUnmatched() throws Exception { DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); int numNodes = randomIntBetween(1, 10); for (int i = 0; i < numNodes; i++) { - discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(random()), IndexVersionUtils.randomVersion())); + discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(), IndexVersionUtils.randomVersion())); } ProjectMetadata.Builder metadata = ProjectMetadata.builder(projectId); for (String index : allIndices) { @@ -630,7 +630,7 @@ public void testFailWithSameException() throws Exception { DiscoveryNodes.Builder discoNodes = DiscoveryNodes.builder(); int numNodes = randomIntBetween(1, 10); for (int i = 0; i < numNodes; i++) { - discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(random()), IndexVersionUtils.randomVersion())); + discoNodes.add(newNode("node_" + i, VersionUtils.randomVersion(), IndexVersionUtils.randomVersion())); } ProjectMetadata.Builder metadata = ProjectMetadata.builder(projectId); for (String index : allIndices) { diff --git a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 22b9043e56d38..aab3a173987ee 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -237,7 +237,7 @@ public void testSerializeDynamicTemplates() throws Exception { if (randomBoolean()) { indexRequest.setDynamicTemplates(Map.of()); } - TransportVersion ver = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion ver = TransportVersionUtils.randomCompatibleVersion(); BytesStreamOutput out = new BytesStreamOutput(); out.setTransportVersion(ver); indexRequest.writeTo(out); @@ -252,7 +252,7 @@ public void testSerializeDynamicTemplates() throws Exception { .boxed() .collect(Collectors.toMap(n -> "field-" + n, n -> "name-" + n)); indexRequest.setDynamicTemplates(dynamicTemplates); - TransportVersion ver = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion ver = TransportVersionUtils.randomCompatibleVersion(); BytesStreamOutput out = new BytesStreamOutput(); out.setTransportVersion(ver); indexRequest.writeTo(out); @@ -271,7 +271,7 @@ public void testSerializeDynamicTemplateParams() throws Exception { if (randomBoolean()) { indexRequest.setDynamicTemplateParams(Map.of()); } - TransportVersion ver = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion ver = TransportVersionUtils.randomCompatibleVersion(); BytesStreamOutput out = new BytesStreamOutput(); out.setTransportVersion(ver); indexRequest.writeTo(out); @@ -283,10 +283,7 @@ public void testSerializeDynamicTemplateParams() throws Exception { // old version { indexRequest.setDynamicTemplateParams(createRandomDynamicTemplateParams(1, 10)); - TransportVersion ver = TransportVersionUtils.randomVersionNotSupporting( - random(), - IndexRequest.INGEST_REQUEST_DYNAMIC_TEMPLATE_PARAMS - ); + TransportVersion ver = TransportVersionUtils.randomVersionNotSupporting(IndexRequest.INGEST_REQUEST_DYNAMIC_TEMPLATE_PARAMS); BytesStreamOutput out = new BytesStreamOutput(); out.setTransportVersion(ver); indexRequest.writeTo(out); @@ -299,10 +296,7 @@ public void testSerializeDynamicTemplateParams() throws Exception { { Map> dynamicTemplateParams = createRandomDynamicTemplateParams(0, 10); indexRequest.setDynamicTemplateParams(dynamicTemplateParams); - TransportVersion ver = TransportVersionUtils.randomVersionSupporting( - random(), - IndexRequest.INGEST_REQUEST_DYNAMIC_TEMPLATE_PARAMS - ); + TransportVersion ver = TransportVersionUtils.randomVersionSupporting(IndexRequest.INGEST_REQUEST_DYNAMIC_TEMPLATE_PARAMS); BytesStreamOutput out = new BytesStreamOutput(); out.setTransportVersion(ver); indexRequest.writeTo(out); diff --git a/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java b/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java index d04ac4f0c6cab..fd3c209937b2b 100644 --- a/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/AbstractSearchAsyncActionTests.java @@ -317,7 +317,7 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod pointInTimeBuilder, results, new NamedWriteableRegistry(ClusterModule.getNamedWriteables()), - TransportVersionUtils.randomCompatibleVersion(random()), + TransportVersionUtils.randomCompatibleVersion(), searchTransportService, nodes, logger @@ -352,7 +352,7 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod pointInTimeBuilder, results, new NamedWriteableRegistry(ClusterModule.getNamedWriteables()), - TransportVersionUtils.randomCompatibleVersion(random()), + TransportVersionUtils.randomCompatibleVersion(), searchTransportService, nodes, logger @@ -395,7 +395,7 @@ public Transport.Connection getConnection(String clusterAlias, DiscoveryNode nod pointInTimeBuilder, results, new NamedWriteableRegistry(ClusterModule.getNamedWriteables()), - TransportVersionUtils.randomCompatibleVersion(random()), + TransportVersionUtils.randomCompatibleVersion(), searchTransportService, nodes, logger diff --git a/server/src/test/java/org/elasticsearch/action/search/SearchRequestTests.java b/server/src/test/java/org/elasticsearch/action/search/SearchRequestTests.java index f264989b44cf7..2f6eb779de9a8 100644 --- a/server/src/test/java/org/elasticsearch/action/search/SearchRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/SearchRequestTests.java @@ -125,7 +125,7 @@ private static RescoreVectorBuilder randomRescoreVectorBuilder() { public void testRandomVersionSerialization() throws IOException { SearchRequest searchRequest = createSearchRequest(); - TransportVersion version = TransportVersionUtils.randomVersion(random()); + TransportVersion version = TransportVersionUtils.randomVersion(); SearchRequest deserializedRequest = copyWriteable(searchRequest, namedWriteableRegistry, SearchRequest::new, version); assertEquals(searchRequest.isCcsMinimizeRoundtrips(), deserializedRequest.isCcsMinimizeRoundtrips()); assertEquals(searchRequest.getLocalClusterAlias(), deserializedRequest.getLocalClusterAlias()); diff --git a/server/src/test/java/org/elasticsearch/action/search/SearchShardsResponseTests.java b/server/src/test/java/org/elasticsearch/action/search/SearchShardsResponseTests.java index bacd25cea4191..a2a6ccce9b41c 100644 --- a/server/src/test/java/org/elasticsearch/action/search/SearchShardsResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/SearchShardsResponseTests.java @@ -120,11 +120,11 @@ protected SearchShardsResponse mutateInstance(SearchShardsResponse r) throws IOE public void testLegacyResponse() { DiscoveryNode node1 = DiscoveryNodeUtils.builder("node-1") .address(new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF))) - .version(randomCompatibleVersion(random(), Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) + .version(randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) .build(); DiscoveryNode node2 = DiscoveryNodeUtils.builder("node-2") .address(new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF))) - .version(randomCompatibleVersion(random(), Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) + .version(randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) .build(); final ClusterSearchShardsGroup[] groups = new ClusterSearchShardsGroup[2]; { @@ -158,7 +158,7 @@ public void testLegacyResponse() { assertThat(group2.reshardSplitShardCountSummary(), equalTo(SplitShardCountSummary.UNSET)); assertFalse(group2.preFiltered()); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); try (BytesStreamOutput out = new BytesStreamOutput()) { out.setTransportVersion(version); AssertionError error = expectThrows(AssertionError.class, () -> newResponse.writeTo(out)); diff --git a/server/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java b/server/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java index 87f5df26d2b5d..66cb2b010a329 100644 --- a/server/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/ShardSearchFailureTests.java @@ -162,7 +162,7 @@ public void testSerialization() throws IOException { testItem, writableRegistry(), ShardSearchFailure::new, - TransportVersionUtils.randomVersion(random()) + TransportVersionUtils.randomVersion() ); assertEquals(testItem.index(), deserializedInstance.index()); assertEquals(testItem.shard(), deserializedInstance.shard()); diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationSplitHelperTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationSplitHelperTests.java index 75c63a2548580..ed25f0b58a51c 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationSplitHelperTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/ReplicationSplitHelperTests.java @@ -59,7 +59,7 @@ public class ReplicationSplitHelperTests extends ESTestCase { public void testNeedsSplitCoordinationWithUnsetSummary() { final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata).reshardAddShards(2).build(); @@ -69,7 +69,7 @@ public void testNeedsSplitCoordinationWithUnsetSummary() { public void testNeedsSplitCoordinationWithMatchingSummary() { final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata) .reshardAddShards(2) @@ -86,7 +86,7 @@ public void testNeedsSplitCoordinationWithMatchingSummary() { public void testNeedsSplitCoordinationWithMismatchedSummary() { final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata) .reshardAddShards(2) @@ -117,7 +117,7 @@ public void testNewSplitRequestAllDocumentsToCurrentPrimary() throws Exception { final int numSourceShards = 2; var clusterService = mockClusterService(); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata).reshardAddShards(numSourceShards).build(); @@ -195,7 +195,7 @@ public void testNewSplitRequestAllDocumentsToTarget() throws Exception { final ShardId targetShardId = new ShardId(indexName, "test-uuid", 1); var clusterService = mockClusterService(); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata).reshardAddShards(2).build(); @@ -309,7 +309,7 @@ public void testNewSplitRequestSplitBetweenPrimaryAndTarget() throws Exception { final ShardId targetShardId = new ShardId(indexName, "test-uuid", 1); var clusterService = mockClusterService(); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata).reshardAddShards(2).build(); @@ -449,7 +449,7 @@ public void testNewSplitRequestCompletionOrder() throws Exception { final ShardId targetShardId = new ShardId(indexName, "test-uuid", 1); var clusterService = mockClusterService(); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); indexMetadata = IndexMetadata.builder(indexMetadata).reshardAddShards(2).build(); diff --git a/server/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java b/server/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java index 69be2c304d28b..cc8d65af5f718 100644 --- a/server/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java @@ -557,7 +557,7 @@ public void testFailedShardEntrySerialization() throws Exception { final Exception failure = randomBoolean() ? null : getSimulatedFailure(); final boolean markAsStale = randomBoolean(); - final TransportVersion version = randomFrom(randomCompatibleVersion(random())); + final TransportVersion version = randomFrom(randomCompatibleVersion()); final FailedShardEntry failedShardEntry = new FailedShardEntry(shardId, allocationId, primaryTerm, message, failure, markAsStale); try (StreamInput in = serialize(failedShardEntry, version).streamInput()) { in.setTransportVersion(version); @@ -584,7 +584,7 @@ public void testStartedShardEntrySerialization() throws Exception { final long primaryTerm = randomIntBetween(0, 100); final String message = randomRealisticUnicodeOfCodepointLengthBetween(10, 100); - final TransportVersion version = randomFrom(randomCompatibleVersion(random())); + final TransportVersion version = randomFrom(randomCompatibleVersion()); final ShardLongFieldRange timestampRange = ShardLongFieldRangeWireTests.randomRange(); final ShardLongFieldRange eventIngestedRange = ShardLongFieldRangeWireTests.randomRange(); var startedShardEntry = new StartedShardEntry(shardId, allocationId, primaryTerm, message, timestampRange, eventIngestedRange); diff --git a/server/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java b/server/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java index b399d2bea015d..c0179d287b5ce 100644 --- a/server/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/block/ClusterBlockTests.java @@ -35,7 +35,7 @@ public class ClusterBlockTests extends ESTestCase { public void testSerialization() throws Exception { int iterations = randomIntBetween(5, 20); for (int i = 0; i < iterations; i++) { - TransportVersion version = randomVersion(random()); + TransportVersion version = randomVersion(); ClusterBlock clusterBlock = randomClusterBlock(); BytesStreamOutput out = new BytesStreamOutput(); diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/NodeJoinExecutorTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/NodeJoinExecutorTests.java index f573133277c51..cf9323b353319 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/NodeJoinExecutorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/NodeJoinExecutorTests.java @@ -308,7 +308,7 @@ public void testJoinClusterWithReadOnlyCompatibleIndices() { public void testPreventJoinClusterWithUnsupportedNodeVersions() { DiscoveryNodes.Builder builder = DiscoveryNodes.builder(); - final Version version = randomCompatibleVersion(random(), Version.CURRENT); + final Version version = randomCompatibleVersion(Version.CURRENT); builder.add( DiscoveryNodeUtils.builder(UUIDs.base64UUID()) .version(version, IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) @@ -316,7 +316,7 @@ public void testPreventJoinClusterWithUnsupportedNodeVersions() { ); builder.add( DiscoveryNodeUtils.builder(UUIDs.base64UUID()) - .version(randomCompatibleVersion(random(), version), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) + .version(randomCompatibleVersion(version), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) .build() ); DiscoveryNodes nodes = builder.build(); @@ -335,7 +335,7 @@ public void testPreventJoinClusterWithUnsupportedNodeVersions() { final Version oldVersion = randomValueOtherThanMany( v -> v.onOrAfter(minNodeVersion), - () -> rarely() ? Version.fromId(minNodeVersion.id - 1) : randomVersion(random()) + () -> rarely() ? Version.fromId(minNodeVersion.id - 1) : randomVersion() ); expectThrows(IllegalStateException.class, () -> NodeJoinExecutor.ensureVersionBarrier(oldVersion, minNodeVersion)); @@ -670,7 +670,7 @@ public void testSuccess() { public static Settings.Builder randomCompatibleVersionSettings() { Settings.Builder builder = Settings.builder(); if (randomBoolean()) { - IndexVersion createdVersion = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion createdVersion = IndexVersionUtils.randomCompatibleVersion(); builder.put(IndexMetadata.SETTING_VERSION_CREATED, createdVersion); if (randomBoolean()) { builder.put( @@ -680,7 +680,7 @@ public static Settings.Builder randomCompatibleVersionSettings() { } } else { builder.put(IndexMetadata.SETTING_VERSION_CREATED, randomFrom(Version.fromString("5.0.0"), Version.fromString("6.0.0"))); - builder.put(IndexMetadata.SETTING_VERSION_COMPATIBILITY, IndexVersionUtils.randomCompatibleVersion(random()).id()); + builder.put(IndexMetadata.SETTING_VERSION_COMPATIBILITY, IndexVersionUtils.randomCompatibleVersion().id()); } return builder; } diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/PublicationTransportHandlerTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/PublicationTransportHandlerTests.java index bda33e2746bf3..bb56bd3ce4bf6 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/PublicationTransportHandlerTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/PublicationTransportHandlerTests.java @@ -227,13 +227,13 @@ public RecyclerBytesStreamOutput newNetworkBytesStream() { while (allNodes.size() < 10) { var node = DiscoveryNodeUtils.builder("node-" + allNodes.size()) .version( - VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + VersionUtils.randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ) .build(); allNodes.add(node); - nodeTransports.put(node, TransportVersionUtils.randomCompatibleVersion(random())); + nodeTransports.put(node, TransportVersionUtils.randomCompatibleVersion()); } final DiscoveryNodes.Builder prevNodes = DiscoveryNodes.builder(); @@ -359,9 +359,9 @@ public void testIncludesLastCommittedFieldsInDiffSerialization() { final var localNode = DiscoveryNodeUtils.create("localNode"); final var otherNode = DiscoveryNodeUtils.builder("otherNode") .version( - VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + VersionUtils.randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ) .build(); for (final var discoveryNode : List.of(localNode, otherNode)) { diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataVerifierTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataVerifierTests.java index bb62cfeacfc3f..90a2b26572cb4 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataVerifierTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataVerifierTests.java @@ -341,7 +341,7 @@ public static IndexMetadata newSystemIndexMeta(String name, Settings indexSettin } private static IndexMetadata.Builder newIndexMetaBuilder(String name, Settings indexSettings) { - final Settings settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), between(1, 5), between(0, 5)).put( + final Settings settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), between(1, 5), between(0, 5)).put( IndexMetadata.SETTING_CREATION_DATE, randomNonNegativeLong() ).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())).put(indexSettings).build(); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java index 0e9fac4becaef..b733ac9c0fd0f 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java @@ -1609,7 +1609,7 @@ public void testDeprecateTranslogRetentionSettings() { } else { settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), between(1, 128) + "mb"); } - settings.put(SETTING_VERSION_CREATED, IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0)); + settings.put(SETTING_VERSION_CREATED, IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0)); request.settings(settings.build()); aggregateIndexSettings( ClusterState.builder(ClusterState.EMPTY_STATE).putProjectMetadata(ProjectMetadata.builder(projectId).build()).build(), @@ -1674,7 +1674,7 @@ public void testClusterStateCreateIndexWithClusterBlockTransformer() { assertThat(updatedClusterState.routingTable(projectId).index("test"), is(notNullValue())); } { - var minTransportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + var minTransportVersion = TransportVersionUtils.randomCompatibleVersion(); var emptyClusterState = ClusterState.builder(ClusterState.EMPTY_STATE) .putProjectMetadata(ProjectMetadata.builder(projectId)) .nodes(DiscoveryNodes.builder().add(DiscoveryNodeUtils.create("_node_id")).build()) @@ -1712,7 +1712,7 @@ public void testClusterStateCreateIndexWithClusterBlockTransformer() { public void testCreateClusterBlocksTransformerForIndexCreation() { boolean isStateless = randomBoolean(); boolean useRefreshBlock = randomBoolean(); - var minTransportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + var minTransportVersion = TransportVersionUtils.randomCompatibleVersion(); var applier = MetadataCreateIndexService.createClusterBlocksTransformerForIndexCreation( Settings.builder() diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java index 43832d22372aa..0affcef79be65 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java @@ -1165,11 +1165,7 @@ public void testProjectLookupWithMultipleProjects() { public void testOldestIndexVersionAllProjects() { final int numProjects = between(1, 5); - final List indexVersions = randomList( - numProjects, - numProjects, - () -> IndexVersionUtils.randomCompatibleVersion(random()) - ); + final List indexVersions = randomList(numProjects, numProjects, () -> IndexVersionUtils.randomCompatibleVersion()); final Map projectMetadataMap = new HashMap<>(); for (int i = 0; i < numProjects; i++) { diff --git a/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java b/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java index 5101064f293e4..1144c01df61af 100644 --- a/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodesTests.java @@ -482,7 +482,7 @@ public void accept(Consumer update, long expectedGenerat final var node0 = nodeVersionFactory.apply( 0, - new VersionInformation(VersionUtils.randomVersion(random()), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) + new VersionInformation(VersionUtils.randomVersion(), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()) ); testHarness.accept(builder -> builder.add(node0), 0L); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/SplitShardCountSummaryTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/SplitShardCountSummaryTests.java index 59d9b5008613d..c1b58d4b8334d 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/SplitShardCountSummaryTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/SplitShardCountSummaryTests.java @@ -24,7 +24,7 @@ public class SplitShardCountSummaryTests extends ESTestCase { // Test that the ReshardSplitShardCount is calculated correctly w.r.t the current state of resharding-split operation public void testReshardShardCountCalculation() { final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), 1, 0).build(); + var settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), 1, 0).build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName).settings(settings).build(); IndexReshardingMetadata reshardingMetadata = indexMetadata.getReshardingMetadata(); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java index 32119f1c3dfac..50a9ae9654227 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedNodeRoutingTests.java @@ -228,9 +228,9 @@ protected DiscoveryNode createNode(DiscoveryNodeRole... mustHaveRoles) { .name(id) .roles(roles) .version( - VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + VersionUtils.randomCompatibleVersion(Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ) .build(); } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java index d9580c71ae1e9..578ed959f7ca1 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java @@ -223,7 +223,7 @@ public void testRandom() { nodes.add(newNode("node" + (nodeIdx++), Version.CURRENT, IndexVersion.current())); } } else { - nodes.add(newNode("node" + (nodeIdx++), VersionUtils.randomVersion(random()), IndexVersion.current())); + nodes.add(newNode("node" + (nodeIdx++), VersionUtils.randomVersion(), IndexVersion.current())); } } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/NodeBalanceStatsTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/NodeBalanceStatsTests.java index b6ce0fed2d86f..dc8e36a0c1dcf 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/NodeBalanceStatsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/NodeBalanceStatsTests.java @@ -61,7 +61,7 @@ protected ClusterBalanceStats.NodeBalanceStats mutateInstance(ClusterBalanceStat public void testSerializationWithTransportVersionNodeWeightsAddedToNodeBalanceStats() throws IOException { ClusterBalanceStats.NodeBalanceStats instance = createTestInstance(); // Serialization changes based on this version - final var oldVersion = TransportVersionUtils.randomVersionSupporting(random(), NODE_WEIGHTS_ADDED_TO_NODE_BALANCE_STATS); + final var oldVersion = TransportVersionUtils.randomVersionSupporting(NODE_WEIGHTS_ADDED_TO_NODE_BALANCE_STATS); ClusterBalanceStats.NodeBalanceStats deserialized = copyInstance(instance, oldVersion); // Assert the values are as expected diff --git a/server/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java b/server/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java index 9423748b4a158..b9f5a28b93d5d 100644 --- a/server/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java @@ -173,7 +173,7 @@ public void testRoutingTableSerialization() throws Exception { } public void testSnapshotDeletionsInProgressSerialization() throws Exception { - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); boolean includeRestore = randomBoolean(); diff --git a/server/src/test/java/org/elasticsearch/cluster/version/CompatibilityVersionsTests.java b/server/src/test/java/org/elasticsearch/cluster/version/CompatibilityVersionsTests.java index ce008b26b80ed..808d02cd1cfff 100644 --- a/server/src/test/java/org/elasticsearch/cluster/version/CompatibilityVersionsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/version/CompatibilityVersionsTests.java @@ -33,7 +33,7 @@ public void testEmptyVersionsList() { public void testMinimumTransportVersions() { TransportVersion version1 = TransportVersion.minimumCompatible(); - TransportVersion version2 = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version2 = TransportVersionUtils.randomCompatibleVersion(); CompatibilityVersions compatibilityVersions1 = new CompatibilityVersions(version1, Map.of()); CompatibilityVersions compatibilityVersions2 = new CompatibilityVersions(version2, Map.of()); @@ -76,7 +76,7 @@ public void testMinimumMappingsVersions() { */ public void testMinimumsAreMerged() { TransportVersion version1 = TransportVersion.minimumCompatible(); - TransportVersion version2 = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version2 = TransportVersionUtils.randomCompatibleVersion(); SystemIndexDescriptor.MappingsVersion v1 = new SystemIndexDescriptor.MappingsVersion(1, 1); SystemIndexDescriptor.MappingsVersion v2 = new SystemIndexDescriptor.MappingsVersion(2, 2); @@ -93,7 +93,7 @@ public void testMinimumsAreMerged() { public void testPreventJoinClusterWithUnsupportedTransportVersion() { List transportVersions = IntStream.range(0, randomIntBetween(2, 10)) - .mapToObj(i -> TransportVersionUtils.randomCompatibleVersion(random(), false)) + .mapToObj(i -> TransportVersionUtils.randomCompatibleVersion(false)) .toList(); TransportVersion min = Collections.min(transportVersions); List compatibilityVersions = transportVersions.stream() diff --git a/server/src/test/java/org/elasticsearch/common/io/stream/DelayableWriteableTests.java b/server/src/test/java/org/elasticsearch/common/io/stream/DelayableWriteableTests.java index 308a9035f3704..ed53dd2bb70f3 100644 --- a/server/src/test/java/org/elasticsearch/common/io/stream/DelayableWriteableTests.java +++ b/server/src/test/java/org/elasticsearch/common/io/stream/DelayableWriteableTests.java @@ -153,7 +153,7 @@ public void testRoundTripFromDelayedFromOldVersionWithNamedWriteable() throws IO } public void testSerializesWithRemoteVersion() throws IOException { - TransportVersion remoteVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion remoteVersion = TransportVersionUtils.randomCompatibleVersion(); DelayableWriteable original = DelayableWriteable.referencing(new SneakOtherSideVersionOnWire()); assertThat(roundTrip(original, SneakOtherSideVersionOnWire::new, remoteVersion).expand().version, equalTo(remoteVersion)); } @@ -202,6 +202,6 @@ protected NamedWriteableRegistry writableRegistry() { } private static TransportVersion randomOldVersion() { - return TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + return TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); } } diff --git a/server/src/test/java/org/elasticsearch/common/io/stream/VersionCheckingStreamOutputTests.java b/server/src/test/java/org/elasticsearch/common/io/stream/VersionCheckingStreamOutputTests.java index dcabcb4dc269f..979a51231a794 100644 --- a/server/src/test/java/org/elasticsearch/common/io/stream/VersionCheckingStreamOutputTests.java +++ b/server/src/test/java/org/elasticsearch/common/io/stream/VersionCheckingStreamOutputTests.java @@ -35,7 +35,7 @@ public TransportVersion getMinimalSupportedVersion() { } public void testCheckVersionCompatibility() throws IOException { - TransportVersion streamVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + TransportVersion streamVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); try (VersionCheckingStreamOutput out = new VersionCheckingStreamOutput(streamVersion)) { out.writeNamedWriteable(QueryBuilders.matchAllQuery()); diff --git a/server/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java b/server/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java index e6aa6bea8d0bd..b344e9b535e12 100644 --- a/server/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java +++ b/server/src/test/java/org/elasticsearch/common/lucene/LuceneTests.java @@ -560,19 +560,14 @@ public void testSortFieldSerialization() throws IOException { sortFieldTuple.v1(), Lucene::writeSortField, Lucene::readSortField, - TransportVersionUtils.randomVersion(random()) + TransportVersionUtils.randomVersion() ); assertEquals(sortFieldTuple.v2(), deserialized); } public void testSortValueSerialization() throws IOException { Object sortValue = randomSortValue(); - Object deserialized = copyInstance( - sortValue, - Lucene::writeSortValue, - Lucene::readSortValue, - TransportVersionUtils.randomVersion(random()) - ); + Object deserialized = copyInstance(sortValue, Lucene::writeSortValue, Lucene::readSortValue, TransportVersionUtils.randomVersion()); assertEquals(sortValue, deserialized); } diff --git a/server/src/test/java/org/elasticsearch/common/util/FeatureFlagTests.java b/server/src/test/java/org/elasticsearch/common/util/FeatureFlagTests.java index b0f080c5fca32..ba2a8cfec03c7 100644 --- a/server/src/test/java/org/elasticsearch/common/util/FeatureFlagTests.java +++ b/server/src/test/java/org/elasticsearch/common/util/FeatureFlagTests.java @@ -82,11 +82,11 @@ private static Build randomBuild(boolean isSnapshot) { randomFrom(Build.Type.values()), Hex.encodeHexString(randomByteArrayOfLength(20)), Instant.now().toString(), - VersionUtils.randomVersion(random()).toString(), + VersionUtils.randomVersion().toString(), randomFrom(random(), null, "alpha1", "beta1", "rc2"), isSnapshot, - VersionUtils.randomVersion(random()).toString(), - VersionUtils.randomVersion(random()).toString(), + VersionUtils.randomVersion().toString(), + VersionUtils.randomVersion().toString(), randomAlphaOfLength(10) ); } diff --git a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java index 9c824e21a5340..65a1ddb893988 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java @@ -35,7 +35,7 @@ public class NodeMetadataTests extends ESTestCase { // (Index)VersionUtils.randomVersion() only returns known versions, which are necessarily no later than (Index)Version.CURRENT; // however we want to also consider our behaviour with all versions, so occasionally pick up a truly random version. private Version randomVersion() { - return rarely() ? Version.fromId(randomNonNegativeInt()) : VersionUtils.randomVersion(random()); + return rarely() ? Version.fromId(randomNonNegativeInt()) : VersionUtils.randomVersion(); } private BuildVersion randomBuildVersion() { diff --git a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java index 7b5ea2137300e..062a71d081ad2 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java @@ -784,7 +784,7 @@ public void testUpdateSoftDeletesFails() { public void testSoftDeletesDefaultSetting() { // enabled by default on 7.0+ or later - IndexVersion createdVersion = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion createdVersion = IndexVersionUtils.randomCompatibleVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, createdVersion).build(); assertTrue(IndexSettings.INDEX_SOFT_DELETES_SETTING.get(settings)); } diff --git a/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java b/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java index db780f0640986..17c35becc47e0 100644 --- a/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java +++ b/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java @@ -197,7 +197,7 @@ public void testNameClashNormalizer() throws IOException { } public void testOverrideDefaultIndexAnalyzerIsUnsupported() { - IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleVersion(); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); AnalyzerProvider defaultIndex = new PreBuiltAnalyzerProvider("default_index", AnalyzerScope.INDEX, new EnglishAnalyzer()); IllegalArgumentException e = expectThrows( diff --git a/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java b/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java index 7f3399cb24a15..d8851eb1cbf06 100644 --- a/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java +++ b/server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java @@ -71,7 +71,7 @@ public void testThatInstancesAreCachedAndReused() { assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(v), PreBuiltAnalyzers.STANDARD.getAnalyzer(v)); assertNotSame( PreBuiltAnalyzers.STANDARD.getAnalyzer(IndexVersion.current()), - PreBuiltAnalyzers.STANDARD.getAnalyzer(IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersion.current())) + PreBuiltAnalyzers.STANDARD.getAnalyzer(IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersion.current())) ); // Same Lucene version should be cached: diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DynamicTemplatesTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DynamicTemplatesTests.java index 5aa74c3bf10f8..9b5db268f0b71 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DynamicTemplatesTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DynamicTemplatesTests.java @@ -1395,7 +1395,7 @@ public void testMalformedDynamicMapping_v7() throws IOException { assertThat(ex.getMessage(), containsString("dynamic template [my_template] has invalid content")); // the previous exception should be ignored by indices with v7 index versions - IndexVersion indexVersion = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + IndexVersion indexVersion = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); Settings settings = Settings.builder().put("number_of_shards", 1).put("index.version.created", indexVersion).build(); MapperService mapperService = createMapperService(indexVersion, settings, () -> randomBoolean()); merge(mapperService, mapping); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java index bcbd40677a46c..b3ce5e77e41d1 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldNamesFieldMapperTests.java @@ -86,7 +86,7 @@ public void testUsingEnabledSettingThrows() { */ public void testUsingEnabledBefore8() throws Exception { DocumentMapper docMapper = createDocumentMapper( - IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0), + IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0), topMapping(b -> b.startObject("_field_names").field("enabled", false).endObject()) ); @@ -103,7 +103,7 @@ public void testUsingEnabledBefore8() throws Exception { */ public void testMergingMappingsBefore8() throws Exception { MapperService mapperService = createMapperService( - IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0), + IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0), mapping(b -> {}) ); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java b/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java index c89753214b6a9..79986d376cd23 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java @@ -307,7 +307,7 @@ public void testMappingRecoverySkipFieldNameLengthLimit() throws Throwable { } public void testIsMetadataField() throws IOException { - IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleVersion(); CheckedFunction initMapperService = (indexMode) -> { Settings.Builder settingsBuilder = Settings.builder() diff --git a/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java index 0e6dff7cac2e0..f9db010ceb24b 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/NestedObjectMapperTests.java @@ -1041,7 +1041,7 @@ public void testLimitNestedDocsMultipleNestedFields() throws Exception { public void testReorderParent() throws IOException { - IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleVersion(); DocumentMapper docMapper = createDocumentMapper( version, @@ -2018,7 +2018,7 @@ public void testNestedLimitDefaults() throws IOException { // defaults previous to IndexVersions.NESTED_PATH_LIMIT { - var version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.NESTED_PATH_LIMIT); + var version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.NESTED_PATH_LIMIT); var mapperService = createMapperService(version, Settings.builder().build(), mapping(b -> {})); assertThat( MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING.get(mapperService.getIndexSettings().getSettings()), diff --git a/server/src/test/java/org/elasticsearch/index/mapper/SkipperSettingsTests.java b/server/src/test/java/org/elasticsearch/index/mapper/SkipperSettingsTests.java index 4f443bdab5ab3..a465a56f90dc2 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/SkipperSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/SkipperSettingsTests.java @@ -52,7 +52,6 @@ public void testTSDBSkipperSettingDefaults() { } { IndexVersion nonSkipperVersion = IndexVersionUtils.randomPreviousCompatibleVersion( - random(), IndexVersions.SKIPPERS_ENABLED_BY_DEFAULT ); IndexSettings indexSettings = settings(nonSkipperVersion, b -> { @@ -71,7 +70,6 @@ public void testTSDBSkipperSettingDefaults() { } { IndexVersion nonSkipperVersion = IndexVersionUtils.randomPreviousCompatibleVersion( - random(), IndexVersions.STATELESS_SKIPPERS_ENABLED_FOR_TSDB ); IndexSettings indexSettings = settings(nonSkipperVersion, b -> { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TsidExtractingIdFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TsidExtractingIdFieldMapperTests.java index 54fc2903e65ab..1c1cb931e15d0 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/TsidExtractingIdFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/TsidExtractingIdFieldMapperTests.java @@ -855,7 +855,7 @@ private Settings indexSettings(IndexVersion version, boolean indexDimensions) { } private MapperService mapperService(boolean indexDimensions) throws IOException { - IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleVersion(); return createMapperService(indexSettings(version, indexDimensions), mapping(b -> { b.startObject("r1").field("type", "keyword").field("time_series_dimension", true).endObject(); b.startObject("r2").field("type", "keyword").field("time_series_dimension", true).endObject(); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java index d29733f9b9e00..acbbce5c98d07 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java @@ -87,7 +87,7 @@ public void testMultiFieldWithinMultiField() throws IOException { Map fieldNodeCopy = XContentHelper.convertToMap(BytesReference.bytes(mapping), true, mapping.contentType()).v2(); IndexVersion version = IndexVersionUtils.randomVersionBetween(IndexVersions.V_8_0_0, IndexVersion.current()); - TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(); MappingParserContext context = new MappingParserContext( null, type -> typeParser, diff --git a/server/src/test/java/org/elasticsearch/index/mapper/vectors/BinaryDenseVectorScriptDocValuesTests.java b/server/src/test/java/org/elasticsearch/index/mapper/vectors/BinaryDenseVectorScriptDocValuesTests.java index e9eac173e2198..a12f01550de2e 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/vectors/BinaryDenseVectorScriptDocValuesTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/vectors/BinaryDenseVectorScriptDocValuesTests.java @@ -34,7 +34,7 @@ public void testFloatGetVectorValueAndGetMagnitude() throws IOException { float[][] vectors = { { 1, 1, 1 }, { 1, 1, 2 }, { 1, 1, 3 } }; float[] expectedMagnitudes = { 1.7320f, 2.4495f, 3.3166f }; - for (IndexVersion indexVersion : List.of(IndexVersionUtils.randomCompatibleVersion(random()), IndexVersion.current())) { + for (IndexVersion indexVersion : List.of(IndexVersionUtils.randomCompatibleVersion(), IndexVersion.current())) { BinaryDocValues docValues = wrap(vectors, ElementType.FLOAT, indexVersion); DenseVectorDocValuesField field = new BinaryDenseVectorDocValuesField(docValues, "test", ElementType.FLOAT, dims, indexVersion); DenseVectorScriptDocValues scriptDocValues = field.toScriptDocValues(); diff --git a/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java b/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java index 1f82d7998257e..0dc52c9a60b47 100644 --- a/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java +++ b/server/src/test/java/org/elasticsearch/index/replication/RetentionLeasesReplicationTests.java @@ -147,7 +147,7 @@ protected void syncRetentionLeases(ShardId id, RetentionLeases leases, ActionLis public void testTurnOffTranslogRetentionAfterAllShardStarted() throws Exception { final Settings.Builder settings = Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true); if (randomBoolean()) { - settings.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomCompatibleWriteVersion(random())); + settings.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomCompatibleWriteVersion()); } try (ReplicationGroup group = createGroup(between(1, 2), settings.build())) { group.startAll(); diff --git a/server/src/test/java/org/elasticsearch/index/store/StoreTests.java b/server/src/test/java/org/elasticsearch/index/store/StoreTests.java index 1dbf761a5a378..6e2eb6c689f57 100644 --- a/server/src/test/java/org/elasticsearch/index/store/StoreTests.java +++ b/server/src/test/java/org/elasticsearch/index/store/StoreTests.java @@ -950,7 +950,7 @@ public int numNonExtraFiles(Store store) throws IOException { public void testMetadataSnapshotStreaming() throws Exception { Store.MetadataSnapshot outMetadataSnapshot = createMetadataSnapshot(); - TransportVersion targetVersion = randomVersion(random()); + TransportVersion targetVersion = randomVersion(); ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer); @@ -972,7 +972,7 @@ public void testMetadataSnapshotStreaming() throws Exception { public void testEmptyMetadataSnapshotStreaming() throws Exception { var outMetadataSnapshot = randomBoolean() ? Store.MetadataSnapshot.EMPTY : new Store.MetadataSnapshot(emptyMap(), emptyMap(), 0L); - var targetVersion = randomCompatibleVersion(random()); + var targetVersion = randomCompatibleVersion(); var outBuffer = new ByteArrayOutputStream(); var out = new OutputStreamStreamOutput(outBuffer); @@ -1033,7 +1033,7 @@ public void testStreamStoreFilesMetadata() throws Exception { new TransportNodesListShardStoreMetadata.StoreFilesMetadata(metadataSnapshot, peerRecoveryRetentionLeases); ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer); - TransportVersion targetVersion = randomCompatibleVersion(random()); + TransportVersion targetVersion = randomCompatibleVersion(); out.setTransportVersion(targetVersion); outStoreFileMetadata.writeTo(out); ByteArrayInputStream inBuffer = new ByteArrayInputStream(outBuffer.toByteArray()); @@ -1053,7 +1053,7 @@ public void testStreamEmptyStoreFilesMetadata() throws Exception { : new TransportNodesListShardStoreMetadata.StoreFilesMetadata(Store.MetadataSnapshot.EMPTY, emptyList()); var outBuffer = new ByteArrayOutputStream(); var out = new OutputStreamStreamOutput(outBuffer); - var targetVersion = randomCompatibleVersion(random()); + var targetVersion = randomCompatibleVersion(); out.setTransportVersion(targetVersion); outStoreFileMetadata.writeTo(out); diff --git a/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java index 0e2d7d3899596..7bab2809738b5 100644 --- a/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java +++ b/server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java @@ -3471,7 +3471,7 @@ public void testTranslogOpSerialization() throws Exception { Engine.IndexResult eIndexResult = new Engine.IndexResult(1, randomPrimaryTerm, randomSeqNum, true, eIndex.id()); Translog.Index index = new Translog.Index(eIndex, eIndexResult); - TransportVersion wireVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion wireVersion = TransportVersionUtils.randomCompatibleVersion(); BytesStreamOutput out = new BytesStreamOutput(); out.setTransportVersion(wireVersion); index.writeTo(out); diff --git a/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java b/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java index 3304e5fbb5d25..8bdfd69ef8ad6 100644 --- a/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java +++ b/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java @@ -60,7 +60,7 @@ abstract class Streamer extends Thread { final Version streamVersion; Streamer(AtomicBoolean shouldStop, T source) { - this(shouldStop, source, randomVersion(random())); + this(shouldStop, source, randomVersion()); } Streamer(AtomicBoolean shouldStop, T source, Version streamVersion) { diff --git a/server/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java b/server/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java index f56b2ced6a7a0..d18f237eee875 100644 --- a/server/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java +++ b/server/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java @@ -31,8 +31,8 @@ public class StartRecoveryRequestTests extends ESTestCase { public void testSerialization() throws Exception { - final Version targetNodeVersion = randomVersion(random()); - TransportVersion serializationVersion = TransportVersionUtils.randomVersion(random()); + final Version targetNodeVersion = randomVersion(); + TransportVersion serializationVersion = TransportVersionUtils.randomVersion(); Store.MetadataSnapshot metadataSnapshot = randomBoolean() ? Store.MetadataSnapshot.EMPTY : new Store.MetadataSnapshot( diff --git a/server/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java b/server/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java index ace8499d8ffd0..9ae3203c8348d 100644 --- a/server/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java +++ b/server/src/test/java/org/elasticsearch/nodesinfo/NodeInfoStreamingTests.java @@ -117,7 +117,7 @@ private static NodeInfo createNodeInfo() { Build build = Build.current(); DiscoveryNode node = DiscoveryNodeUtils.builder("test_node") .roles(emptySet()) - .version(VersionUtils.randomVersion(random()), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) + .version(VersionUtils.randomVersion(), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) .build(); Settings settings = randomBoolean() ? null : Settings.builder().put("test", "setting").build(); OsInfo osInfo = null; @@ -242,7 +242,7 @@ private static NodeInfo createNodeInfo() { } return new NodeInfo( randomAlphaOfLengthBetween(6, 32), - new CompatibilityVersions(TransportVersionUtils.randomVersion(random()), Map.of()), + new CompatibilityVersions(TransportVersionUtils.randomVersion(), Map.of()), IndexVersionUtils.randomVersion(), componentVersions, build, diff --git a/server/src/test/java/org/elasticsearch/persistent/BasePersistentTasksCustomMetadataTests.java b/server/src/test/java/org/elasticsearch/persistent/BasePersistentTasksCustomMetadataTests.java index d225b1cb0933c..5e197e7093efe 100644 --- a/server/src/test/java/org/elasticsearch/persistent/BasePersistentTasksCustomMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/persistent/BasePersistentTasksCustomMetadataTests.java @@ -198,7 +198,7 @@ public void testBuilder() { @SuppressWarnings("unchecked") public void testMinVersionSerialization() throws IOException { PersistentTasks.Builder tasks = builder(); - TransportVersion streamVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + TransportVersion streamVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); tasks.addTask( "test_compatible_version", TestPersistentTasksPlugin.TestPersistentTasksExecutor.NAME, diff --git a/server/src/test/java/org/elasticsearch/search/SearchHitTests.java b/server/src/test/java/org/elasticsearch/search/SearchHitTests.java index 25a71d04b321d..133a5f43f655b 100644 --- a/server/src/test/java/org/elasticsearch/search/SearchHitTests.java +++ b/server/src/test/java/org/elasticsearch/search/SearchHitTests.java @@ -279,7 +279,7 @@ public void testSerializeShardTarget() throws Exception { SearchHits hits = new SearchHits(new SearchHit[] { hit1, hit2 }, new TotalHits(2, TotalHits.Relation.EQUAL_TO), 1f); try { - TransportVersion version = TransportVersionUtils.randomVersion(random()); + TransportVersion version = TransportVersionUtils.randomVersion(); SearchHits results = copyWriteable( hits, getNamedWriteableRegistry(), diff --git a/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java b/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java index a74ad525fa67e..7817d0d3012e0 100644 --- a/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java +++ b/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java @@ -228,9 +228,9 @@ public void testChannelVersion() throws Exception { int iterations = between(0, 5); // New version for (int i = 0; i < iterations; i++) { - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); if (Optional.ofNullable(request.source()).map(SearchSourceBuilder::knnSearch).map(List::size).orElse(0) > 1) { - version = TransportVersionUtils.randomCompatibleVersion(random()); + version = TransportVersionUtils.randomCompatibleVersion(); } request = copyWriteable(request, namedWriteableRegistry, ShardSearchRequest::new, version); channelVersion = TransportVersion.min(channelVersion, version); diff --git a/server/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java b/server/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java index 919515b730915..d14ffa695c78b 100644 --- a/server/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/sort/FieldSortBuilderTests.java @@ -692,7 +692,7 @@ protected FieldSortBuilder fromXContent(XContentParser parser, String fieldName) public void testIntRewritesToLong() throws IOException { assertIntegerSortRewrite( - IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.INDEX_INT_SORT_INT_TYPE_8_19), + IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.INDEX_INT_SORT_INT_TYPE_8_19), SortField.Type.LONG ); assertIntegerSortRewrite( diff --git a/server/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java b/server/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java index a847d36108063..21e29311e37a5 100644 --- a/server/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java +++ b/server/src/test/java/org/elasticsearch/search/suggest/SuggestTests.java @@ -293,7 +293,7 @@ public void testMergingSuggestionOptions() { } public void testSerialization() throws IOException { - TransportVersion bwcVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion bwcVersion = TransportVersionUtils.randomCompatibleVersion(); final Suggest suggest = createTestItem(); final Suggest bwcSuggest; diff --git a/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java b/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java index ea937573add8b..4f7905b5c80df 100644 --- a/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java +++ b/server/src/test/java/org/elasticsearch/transport/InboundDecoderTests.java @@ -175,7 +175,7 @@ public void testClientChannelTypeFailsDecodingRequests() throws Exception { final var isHandshake = randomBoolean(); final var version = isHandshake ? randomFrom(TransportHandshaker.ALLOWED_HANDSHAKE_VERSIONS) - : TransportVersionUtils.randomCompatibleVersion(random()); + : TransportVersionUtils.randomCompatibleVersion(); logger.info("--> version = {}", version); try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) { @@ -224,7 +224,7 @@ public void testServerChannelTypeFailsDecodingResponses() throws Exception { final var isHandshake = randomBoolean(); final var version = isHandshake ? randomFrom(TransportHandshaker.ALLOWED_HANDSHAKE_VERSIONS) - : TransportVersionUtils.randomCompatibleVersion(random()); + : TransportVersionUtils.randomCompatibleVersion(); try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) { final BytesReference bytes = OutboundHandler.serialize( @@ -367,7 +367,7 @@ public void testVersionIncompatibilityDecodeException() throws IOException { public void testCheckVersionCompatibility() { try { - InboundDecoder.checkVersionCompatibility(TransportVersionUtils.randomCompatibleVersion(random())); + InboundDecoder.checkVersionCompatibility(TransportVersionUtils.randomCompatibleVersion()); } catch (IllegalStateException e) { throw new AssertionError(e); } diff --git a/server/src/test/java/org/elasticsearch/transport/OutboundHandlerTests.java b/server/src/test/java/org/elasticsearch/transport/OutboundHandlerTests.java index 9b7c2366b63f1..d76d4491a2b5d 100644 --- a/server/src/test/java/org/elasticsearch/transport/OutboundHandlerTests.java +++ b/server/src/test/java/org/elasticsearch/transport/OutboundHandlerTests.java @@ -142,7 +142,7 @@ public void testSendRequest() throws IOException { boolean isHandshake = randomBoolean(); TransportVersion version = isHandshake ? randomFrom(TransportHandshaker.ALLOWED_HANDSHAKE_VERSIONS) - : TransportVersionUtils.randomCompatibleVersion(random()); + : TransportVersionUtils.randomCompatibleVersion(); boolean compress = randomBoolean(); String value = "message"; threadContext.putHeader("header", "header_value"); @@ -215,7 +215,7 @@ public void testSendResponse() throws IOException { boolean isHandshake = randomBoolean(); TransportVersion version = isHandshake ? randomFrom(TransportHandshaker.ALLOWED_HANDSHAKE_VERSIONS) - : TransportVersionUtils.randomCompatibleVersion(random()); + : TransportVersionUtils.randomCompatibleVersion(); boolean compress = randomBoolean(); String value = "message"; @@ -274,7 +274,7 @@ public void onResponseSent(long requestId, String action) { public void testErrorResponse() throws IOException { ThreadContext threadContext = threadPool.getThreadContext(); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); String action = "not-a-handshake"; long requestId = randomLongBetween(0, 300); threadContext.putHeader("header", "header_value"); @@ -327,7 +327,7 @@ public void onResponseSent(long requestId, String action, Exception error) { } public void testSendErrorAfterFailToSendResponse() throws Exception { - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); String action = randomAlphaOfLength(10); long requestId = randomLongBetween(0, 300); var response = new ReleasbleTestResponse(randomAlphaOfLength(10)) { diff --git a/server/src/test/java/org/elasticsearch/transport/SniffConnectionStrategyTests.java b/server/src/test/java/org/elasticsearch/transport/SniffConnectionStrategyTests.java index 468c3a8c6d2da..ad220deba76cd 100644 --- a/server/src/test/java/org/elasticsearch/transport/SniffConnectionStrategyTests.java +++ b/server/src/test/java/org/elasticsearch/transport/SniffConnectionStrategyTests.java @@ -1123,7 +1123,7 @@ public void testGetNodePredicateNodeRoles() { public void testGetNodePredicateNodeVersion() { TransportAddress address = new TransportAddress(TransportAddress.META_ADDRESS, 0); Predicate nodePredicate = SniffConnectionStrategySettings.getNodePredicate(Settings.EMPTY); - Version version = VersionUtils.randomVersion(random()); + Version version = VersionUtils.randomVersion(); DiscoveryNode node = DiscoveryNodeUtils.builder("id") .address(address) .version(version, IndexVersions.ZERO, IndexVersion.current()) diff --git a/server/src/test/java/org/elasticsearch/transport/TransportHandshakerRawMessageTests.java b/server/src/test/java/org/elasticsearch/transport/TransportHandshakerRawMessageTests.java index 58ca2cbab9530..0fb057cd23695 100644 --- a/server/src/test/java/org/elasticsearch/transport/TransportHandshakerRawMessageTests.java +++ b/server/src/test/java/org/elasticsearch/transport/TransportHandshakerRawMessageTests.java @@ -39,7 +39,7 @@ public class TransportHandshakerRawMessageTests extends ESSingleNodeTestCase { public void testV8Handshake() throws Exception { final BytesRef handshakeRequestBytes; final var requestId = randomNonNegativeLong(); - final var requestNodeTransportVersionId = TransportVersionUtils.randomCompatibleVersion(random()).id(); + final var requestNodeTransportVersionId = TransportVersionUtils.randomCompatibleVersion().id(); try (var outputStream = new BytesStreamOutput()) { outputStream.setTransportVersion(TransportHandshaker.V8_HANDSHAKE_VERSION); outputStream.writeLong(requestId); @@ -91,7 +91,7 @@ public void testV8Handshake() throws Exception { public void testV9Handshake() throws Exception { final BytesRef handshakeRequestBytes; final var requestId = randomNonNegativeLong(); - final var requestNodeTransportVersionId = TransportVersionUtils.randomCompatibleVersion(random()).id(); + final var requestNodeTransportVersionId = TransportVersionUtils.randomCompatibleVersion().id(); try (var outputStream = new BytesStreamOutput()) { outputStream.setTransportVersion(TransportHandshaker.V9_HANDSHAKE_VERSION); outputStream.writeLong(requestId); diff --git a/server/src/test/java/org/elasticsearch/transport/TransportHandshakerTests.java b/server/src/test/java/org/elasticsearch/transport/TransportHandshakerTests.java index c8d7e9d0be09c..f581d4301713a 100644 --- a/server/src/test/java/org/elasticsearch/transport/TransportHandshakerTests.java +++ b/server/src/test/java/org/elasticsearch/transport/TransportHandshakerTests.java @@ -184,7 +184,7 @@ public void testHandshakeResponseFromOlderNode() throws Exception { assertFalse(versionFuture.isDone()); - final var remoteVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final var remoteVersion = TransportVersionUtils.randomCompatibleVersion(); handler.handleResponse(new TransportHandshaker.HandshakeResponse(remoteVersion, randomIdentifier())); assertTrue(versionFuture.isDone()); @@ -333,7 +333,7 @@ public void testHandshakeRequestFutureVersionsCompatibility() throws IOException } public void testReadV8HandshakeRequest() throws IOException { - final var transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final var transportVersion = TransportVersionUtils.randomCompatibleVersion(); final var requestPayloadStreamOutput = new BytesStreamOutput(); requestPayloadStreamOutput.setTransportVersion(TransportHandshaker.V8_HANDSHAKE_VERSION); @@ -353,7 +353,7 @@ public void testReadV8HandshakeRequest() throws IOException { } public void testReadV8HandshakeResponse() throws IOException { - final var transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final var transportVersion = TransportVersionUtils.randomCompatibleVersion(); final var responseBytesStreamOutput = new BytesStreamOutput(); responseBytesStreamOutput.setTransportVersion(TransportHandshaker.V8_HANDSHAKE_VERSION); @@ -368,7 +368,7 @@ public void testReadV8HandshakeResponse() throws IOException { } public void testReadV9HandshakeRequest() throws IOException { - final var transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final var transportVersion = TransportVersionUtils.randomCompatibleVersion(); final var releaseVersion = randomIdentifier(); final var requestPayloadStreamOutput = new BytesStreamOutput(); @@ -390,7 +390,7 @@ public void testReadV9HandshakeRequest() throws IOException { } public void testReadV9HandshakeResponse() throws IOException { - final var transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final var transportVersion = TransportVersionUtils.randomCompatibleVersion(); final var releaseVersion = randomIdentifier(); final var responseBytesStreamOutput = new BytesStreamOutput(); diff --git a/server/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java b/server/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java index d9016f391f207..3553a897fcf51 100644 --- a/server/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java +++ b/server/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java @@ -126,7 +126,7 @@ public void testConnectToNodeLight() { TransportService transportServiceB = startServices( "TS_B", settings, - TransportVersionUtils.randomCompatibleVersion(random()), + TransportVersionUtils.randomCompatibleVersion(), new VersionInformation( VersionUtils.randomVersionBetween(Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT), IndexVersions.MINIMUM_COMPATIBLE, diff --git a/test/framework/src/integTest/java/org/elasticsearch/test/test/InternalClusterForbiddenSettingIT.java b/test/framework/src/integTest/java/org/elasticsearch/test/test/InternalClusterForbiddenSettingIT.java index 2033743354f34..d522f927e2283 100644 --- a/test/framework/src/integTest/java/org/elasticsearch/test/test/InternalClusterForbiddenSettingIT.java +++ b/test/framework/src/integTest/java/org/elasticsearch/test/test/InternalClusterForbiddenSettingIT.java @@ -26,7 +26,7 @@ protected boolean forbidPrivateIndexSettings() { } public void testRestart() throws Exception { - IndexVersion version = IndexVersionUtils.randomPreviousCompatibleWriteVersion(random(), IndexVersion.current()); + IndexVersion version = IndexVersionUtils.randomPreviousCompatibleWriteVersion(IndexVersion.current()); // create / delete an index with forbidden setting prepareCreate("test").setSettings(settings(version).build()).get(); indicesAdmin().prepareDelete("test").get(); @@ -38,7 +38,7 @@ public void testRestart() throws Exception { } public void testRollingRestart() throws Exception { - IndexVersion version = IndexVersionUtils.randomPreviousCompatibleWriteVersion(random(), IndexVersion.current()); + IndexVersion version = IndexVersionUtils.randomPreviousCompatibleWriteVersion(IndexVersion.current()); // create / delete an index with forbidden setting prepareCreate("test").setSettings(settings(version).build()).get(); indicesAdmin().prepareDelete("test").get(); diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java index 3d05b5c127719..34dd1a9aad371 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java @@ -1869,10 +1869,7 @@ protected boolean supportsDocValuesSkippers() { public void testDocValuesSkippers() throws IOException { assumeTrue("Mapper does not support doc values skippers", supportsDocValuesSkippers()); - IndexVersion preSkipperVersion = IndexVersionUtils.randomPreviousCompatibleVersion( - random(), - IndexVersions.STANDARD_INDEXES_USE_SKIPPERS - ); + IndexVersion preSkipperVersion = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.STANDARD_INDEXES_USE_SKIPPERS); IndexVersion withSkipperVersion = IndexVersions.STANDARD_INDEXES_USE_SKIPPERS; Settings skippersDisabled = Settings.builder().put(IndexSettings.USE_DOC_VALUES_SKIPPER.getKey(), false).build(); @@ -1907,7 +1904,6 @@ public void testDocValuesSkippers() throws IOException { Settings statelessSkipperDefault = Settings.builder().put(DiscoveryNode.STATELESS_ENABLED_SETTING_NAME, true).build(); IndexVersion statelessNoSkipperVersion = IndexVersionUtils.randomPreviousCompatibleVersion( - random(), IndexVersions.STANDARD_INDEXES_USE_SKIPPERS ); { diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MetadataMapperTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MetadataMapperTestCase.java index e3ef6887cfb11..7217e4c51700b 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MetadataMapperTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MetadataMapperTestCase.java @@ -109,7 +109,7 @@ public final void testUpdates() throws IOException { public final void testUnsupportedParametersAreRejected() throws IOException { assumeTrue("Metadata field " + fieldName() + " isn't configurable", isConfigurable()); - IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleVersion(); assumeTrue("Metadata field " + fieldName() + " is not supported on version " + version, isSupportedOn(version)); MapperService mapperService = createMapperService(version, mapping(xContentBuilder -> {})); String mappingAsString = "{\n" @@ -133,7 +133,7 @@ public final void testUnsupportedParametersAreRejected() throws IOException { public final void testFixedMetaFieldsAreNotConfigurable() throws IOException { assumeFalse("Metadata field " + fieldName() + " is configurable", isConfigurable()); - IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion version = IndexVersionUtils.randomCompatibleVersion(); assumeTrue("Metadata field " + fieldName() + " is not supported on version " + version, isSupportedOn(version)); MapperService mapperService = createMapperService(version, mapping(xContentBuilder -> {})); String mappingAsString = "{\n" + " \"_doc\" : {\n" + " \"" + fieldName() + "\" : {\n" + " }\n" + " }\n" + "}"; diff --git a/test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/AbstractSignificanceHeuristicTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/AbstractSignificanceHeuristicTestCase.java index a3c03526c9b93..417f0a6447980 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/AbstractSignificanceHeuristicTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/aggregations/bucket/AbstractSignificanceHeuristicTestCase.java @@ -72,7 +72,7 @@ public abstract class AbstractSignificanceHeuristicTestCase extends ESTestCase { protected abstract SignificanceHeuristic getHeuristic(); protected TransportVersion randomVersion() { - return TransportVersionUtils.randomVersion(random()); + return TransportVersionUtils.randomVersion(); } // test that stream output can actually be read - does not replace bwc test diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java index 8872fe8a52665..526efa7b2a0dd 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java @@ -234,7 +234,7 @@ protected static String createUniqueRandomName() { protected Settings createTestIndexSettings() { // we have to prefer CURRENT since with the range of versions we support it's rather unlikely to get the current actually. - IndexVersion indexVersionCreated = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleVersion(random()); + IndexVersion indexVersionCreated = randomBoolean() ? IndexVersion.current() : IndexVersionUtils.randomCompatibleVersion(); return Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, indexVersionCreated).build(); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/TransportVersionUtils.java b/test/framework/src/main/java/org/elasticsearch/test/TransportVersionUtils.java index 19535277cbd65..125d2fb802843 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TransportVersionUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TransportVersionUtils.java @@ -15,7 +15,6 @@ import java.util.Collections; import java.util.NavigableSet; -import java.util.Random; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; @@ -51,25 +50,20 @@ public static TransportVersion randomVersion(Set ignore) { return ESTestCase.randomFrom(allReleasedVersions().stream().filter(v -> ignore.contains(v) == false).collect(Collectors.toList())); } - /** Returns a random {@link TransportVersion} from all available versions. */ - public static TransportVersion randomVersion(Random random) { - return RandomPicks.randomFrom(random, allReleasedVersions()); - } - /** * Returns a random {@link TransportVersion} which supports the given version. Effectively, this returns a version equal to, or "later" * than the given version. */ - public static TransportVersion randomVersionSupporting(Random random, TransportVersion minVersion) { - return RandomPicks.randomFrom(random, RELEASED_VERSIONS.stream().filter(v -> v.supports(minVersion)).toList()); + public static TransportVersion randomVersionSupporting(TransportVersion minVersion) { + return RandomPicks.randomFrom(random(), RELEASED_VERSIONS.stream().filter(v -> v.supports(minVersion)).toList()); } /** * Returns a random {@link TransportVersion} which does not supports the given version. Effectively, this returns a version "before" * the given version. */ - public static TransportVersion randomVersionNotSupporting(Random random, TransportVersion version) { - return RandomPicks.randomFrom(random, RELEASED_VERSIONS.stream().filter(v -> v.supports(version) == false).toList()); + public static TransportVersion randomVersionNotSupporting(TransportVersion version) { + return RandomPicks.randomFrom(random(), RELEASED_VERSIONS.stream().filter(v -> v.supports(version) == false).toList()); } public static TransportVersion getPreviousVersion(TransportVersion version) { @@ -113,14 +107,14 @@ public static TransportVersion getNextVersion(TransportVersion version, boolean } /** Returns a random {@code TransportVersion} that is compatible with {@link TransportVersion#current()} */ - public static TransportVersion randomCompatibleVersion(Random random) { - return randomCompatibleVersion(random, true); + public static TransportVersion randomCompatibleVersion() { + return randomCompatibleVersion(true); } /** Returns a random {@code TransportVersion} that is compatible with {@link TransportVersion#current()} */ - public static TransportVersion randomCompatibleVersion(Random random, boolean includePatches) { + public static TransportVersion randomCompatibleVersion(boolean includePatches) { return RandomPicks.randomFrom( - random, + random(), (includePatches ? RELEASED_VERSIONS : NON_PATCH_VERSIONS).stream().filter(TransportVersion::isCompatible).toList() ); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/VersionUtils.java b/test/framework/src/main/java/org/elasticsearch/test/VersionUtils.java index 256633c08a045..c60f8edf94031 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/VersionUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/VersionUtils.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.List; import java.util.NavigableSet; -import java.util.Random; import java.util.TreeSet; import static org.apache.lucene.tests.util.LuceneTestCase.random; @@ -77,23 +76,18 @@ public static Version getFirstVersion() { } /** Returns a random {@link Version} from all available versions. */ - public static Version randomVersion(Random random) { - return randomFrom(random, ALL_VERSIONS); + public static Version randomVersion() { + return randomFrom(ALL_VERSIONS); } /** Returns a random {@link Version} from all available versions, that is compatible with the given version. */ - public static Version randomCompatibleVersion(Random random, Version version) { + public static Version randomCompatibleVersion(Version version) { final List compatible = ALL_VERSIONS.stream().filter(version::isCompatible).toList(); - return compatible.get(random.nextInt(compatible.size())); + return compatible.get(random().nextInt(compatible.size())); } /** Returns a random {@link Version} between minVersion and maxVersion (inclusive). */ public static Version randomVersionBetween(@Nullable Version minVersion, @Nullable Version maxVersion) { - return randomVersionBetween(random(), minVersion, maxVersion); - } - - /** Returns a random {@link Version} between minVersion and maxVersion (inclusive). */ - public static Version randomVersionBetween(Random random, @Nullable Version minVersion, @Nullable Version maxVersion) { if (minVersion != null && maxVersion != null && maxVersion.before(minVersion)) { throw new IllegalArgumentException("maxVersion [" + maxVersion + "] cannot be less than minVersion [" + minVersion + "]"); } @@ -112,7 +106,7 @@ public static Version randomVersionBetween(Random random, @Nullable Version minV versions = versions.headSet(maxVersion, true); } - return randomFrom(random, versions); + return randomFrom(versions); } /** Returns the maximum {@link Version} that is compatible with the given version. */ @@ -120,7 +114,7 @@ public static Version maxCompatibleVersion(Version version) { return ALL_VERSIONS.tailSet(version, true).descendingSet().stream().filter(version::isCompatible).findFirst().orElseThrow(); } - public static > T randomFrom(Random random, NavigableSet set) { - return RandomPicks.randomFrom(random, set); + public static > T randomFrom(NavigableSet set) { + return RandomPicks.randomFrom(random(), set); } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/index/IndexVersionUtils.java b/test/framework/src/main/java/org/elasticsearch/test/index/IndexVersionUtils.java index af69aaee9e8a1..dcc1b33cf7b35 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/index/IndexVersionUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/index/IndexVersionUtils.java @@ -17,12 +17,9 @@ import org.elasticsearch.test.VersionUtils; import java.util.NavigableSet; -import java.util.Random; import java.util.Set; import java.util.stream.Collectors; -import static org.apache.lucene.tests.util.LuceneTestCase.random; - public class IndexVersionUtils { private static final NavigableSet ALL_VERSIONS = KnownIndexVersions.ALL_VERSIONS; @@ -45,12 +42,12 @@ public static IndexVersion getLowestWriteCompatibleVersion() { /** Returns a random {@link IndexVersion} from all available versions. */ public static IndexVersion randomVersion() { - return VersionUtils.randomFrom(random(), ALL_VERSIONS); + return VersionUtils.randomFrom(ALL_VERSIONS); } /** Returns a random {@link IndexVersion} from all versions that can be written to. */ public static IndexVersion randomWriteVersion() { - return VersionUtils.randomFrom(random(), ALL_WRITE_VERSIONS); + return VersionUtils.randomFrom(ALL_WRITE_VERSIONS); } /** Returns a random {@link IndexVersion} from all available versions without the ignore set */ @@ -60,11 +57,6 @@ public static IndexVersion randomVersion(Set ignore) { /** Returns a random {@link IndexVersion} between minVersion and maxVersion (inclusive). */ public static IndexVersion randomVersionBetween(@Nullable IndexVersion minVersion, @Nullable IndexVersion maxVersion) { - return randomVersionBetween(random(), minVersion, maxVersion); - } - - /** Returns a random {@link IndexVersion} between minVersion and maxVersion (inclusive). */ - public static IndexVersion randomVersionBetween(Random random, @Nullable IndexVersion minVersion, @Nullable IndexVersion maxVersion) { if (minVersion != null && maxVersion != null && maxVersion.before(minVersion)) { throw new IllegalArgumentException("maxVersion [" + maxVersion + "] cannot be less than minVersion [" + minVersion + "]"); } @@ -83,7 +75,7 @@ public static IndexVersion randomVersionBetween(Random random, @Nullable IndexVe versions = versions.headSet(maxVersion, true); } - return VersionUtils.randomFrom(random, versions); + return VersionUtils.randomFrom(versions); } public static IndexVersion getPreviousVersion() { @@ -113,22 +105,22 @@ public static IndexVersion getNextVersion(IndexVersion version) { } /** Returns a random {@code IndexVersion} that is compatible with {@link IndexVersion#current()} */ - public static IndexVersion randomCompatibleVersion(Random random) { - return randomVersionBetween(random, IndexVersions.MINIMUM_READONLY_COMPATIBLE, IndexVersion.current()); + public static IndexVersion randomCompatibleVersion() { + return randomVersionBetween(IndexVersions.MINIMUM_READONLY_COMPATIBLE, IndexVersion.current()); } /** Returns a random {@code IndexVersion} that is compatible with {@link IndexVersion#current()} and can be written to */ - public static IndexVersion randomCompatibleWriteVersion(Random random) { - return randomVersionBetween(random, IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()); + public static IndexVersion randomCompatibleWriteVersion() { + return randomVersionBetween(IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current()); } /** Returns a random {@code IndexVersion} that is compatible with the previous version to {@code version} */ - public static IndexVersion randomPreviousCompatibleVersion(Random random, IndexVersion version) { - return randomVersionBetween(random, IndexVersions.MINIMUM_READONLY_COMPATIBLE, getPreviousVersion(version)); + public static IndexVersion randomPreviousCompatibleVersion(IndexVersion version) { + return randomVersionBetween(IndexVersions.MINIMUM_READONLY_COMPATIBLE, getPreviousVersion(version)); } /** Returns a random {@code IndexVersion} that is compatible with the previous version to {@code version} and can be written to */ - public static IndexVersion randomPreviousCompatibleWriteVersion(Random random, IndexVersion version) { - return randomVersionBetween(random, IndexVersions.MINIMUM_COMPATIBLE, getPreviousVersion(version)); + public static IndexVersion randomPreviousCompatibleWriteVersion(IndexVersion version) { + return randomVersionBetween(IndexVersions.MINIMUM_COMPATIBLE, getPreviousVersion(version)); } } diff --git a/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java b/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java index e47622d8ce14d..c9095fd1e1549 100644 --- a/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java @@ -2342,7 +2342,7 @@ public void testHandshakeWithIncompatVersion() { public void testHandshakeUpdatesVersion() { assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport); - TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(); try ( MockTransportService service = buildService( "TS_C", diff --git a/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/VersionRangeTests.java b/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/VersionRangeTests.java index 86d1ae2d61f9f..f09d8b58aba9f 100644 --- a/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/VersionRangeTests.java +++ b/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/VersionRangeTests.java @@ -31,7 +31,7 @@ public class VersionRangeTests extends AbstractClientYamlTestFragmentParserTestCase { public void testParseVersionNoLowerBound() { - Version version = VersionUtils.randomVersion(random()); + Version version = VersionUtils.randomVersion(); String versionRangeString = Strings.format(" - %s", version); var versionRange = VersionRange.parseVersionRanges(versionRangeString); @@ -43,7 +43,7 @@ public void testParseVersionNoLowerBound() { } public void testParseVersionNoUpperBound() { - Version version = VersionUtils.randomVersion(random()); + Version version = VersionUtils.randomVersion(); String versionRangeString = Strings.format("%s - ", version); var versionRange = VersionRange.parseVersionRanges(versionRangeString); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java index 0730b2ae4dc46..77d92caf78022 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java @@ -2466,7 +2466,7 @@ private static ClusterState createRemoteClusterState( ) { Settings.Builder indexSettings; if (enableSoftDeletes == false) { - indexSettings = settings(IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0)).put( + indexSettings = settings(IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0)).put( IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false ); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataConversionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataConversionTests.java index d287743a9773b..a5d0acd27b2ef 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataConversionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataConversionTests.java @@ -103,7 +103,7 @@ public void testRemoveSingleTierAllocationFilters() { } public static IndexMetadata newIndexMeta(String name, Settings indexSettings) { - final Settings settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(random()), between(1, 5), between(0, 5)).put( + final Settings settings = indexSettings(IndexVersionUtils.randomCompatibleVersion(), between(1, 5), between(0, 5)).put( IndexMetadata.SETTING_CREATION_DATE, randomNonNegativeLong() ).put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())).put(indexSettings).build(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java index aba9fe5e4d3ad..b6bc72dddb30b 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ClientHelperTests.java @@ -422,7 +422,7 @@ public void testGetPersistableSafeSecurityHeaders() throws IOException { } // Rewritten for older version - final TransportVersion previousVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + final TransportVersion previousVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); when(clusterState.getMinTransportVersion()).thenReturn(previousVersion); final Map headers2; if (randomBoolean()) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadataTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadataTests.java index b8ff4bbe64f85..85ad44bf0e0a0 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadataTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/LifecycleOperationMetadataTests.java @@ -53,7 +53,7 @@ protected Metadata.ProjectCustom mutateInstance(Metadata.ProjectCustom instance) public void testMinimumSupportedVersion() { TransportVersion min = createTestInstance().getMinimalSupportedVersion(); - assertTrue(TransportVersionUtils.randomCompatibleVersion(random()).supports(min)); + assertTrue(TransportVersionUtils.randomCompatibleVersion().supports(min)); } public void testcontext() { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStepTests.java index a435006549859..f268fe4b65955 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStepTests.java @@ -601,7 +601,7 @@ private VersionInformation randomOldVersionInformation() { version, IndexVersions.MINIMUM_COMPATIBLE, IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/StartDataFrameAnalyticsActionTaskParamsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/StartDataFrameAnalyticsActionTaskParamsTests.java index d227c47ff0f88..688f9199e5003 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/StartDataFrameAnalyticsActionTaskParamsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/StartDataFrameAnalyticsActionTaskParamsTests.java @@ -24,11 +24,7 @@ protected StartDataFrameAnalyticsAction.TaskParams doParseInstance(XContentParse @Override protected StartDataFrameAnalyticsAction.TaskParams createTestInstance() { - return new StartDataFrameAnalyticsAction.TaskParams( - randomAlphaOfLength(10), - MlConfigVersionUtils.randomVersion(random()), - randomBoolean() - ); + return new StartDataFrameAnalyticsAction.TaskParams(randomAlphaOfLength(10), MlConfigVersionUtils.randomVersion(), randomBoolean()); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdateTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdateTests.java index 6d81793117ae0..23e94eb53555b 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdateTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdateTests.java @@ -269,7 +269,7 @@ public void testMergeWithJob() { updateBuilder.setPerPartitionCategorizationConfig(new PerPartitionCategorizationConfig(true, randomBoolean())); updateBuilder.setCustomSettings(customSettings); updateBuilder.setModelSnapshotId(randomAlphaOfLength(10)); - updateBuilder.setJobVersion(MlConfigVersionUtils.randomCompatibleVersion(random())); + updateBuilder.setJobVersion(MlConfigVersionUtils.randomCompatibleVersion()); updateBuilder.setModelPruneWindow(TimeValue.timeValueDays(randomIntBetween(1, 100))); JobUpdate update = updateBuilder.build(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlConfigVersionUtils.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlConfigVersionUtils.java index afdb07ca9b788..f34fa92d90b88 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlConfigVersionUtils.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlConfigVersionUtils.java @@ -14,10 +14,11 @@ import java.util.Collections; import java.util.List; -import java.util.Random; import java.util.Set; import java.util.stream.Collectors; +import static org.apache.lucene.tests.util.LuceneTestCase.random; + public class MlConfigVersionUtils { private static final List ALL_VERSIONS = KnownMlConfigVersions.ALL_VERSIONS; @@ -31,17 +32,8 @@ public static MlConfigVersion randomVersion(Set ignore) { return ESTestCase.randomFrom(ALL_VERSIONS.stream().filter(v -> ignore.contains(v) == false).collect(Collectors.toList())); } - /** Returns a random {@link MlConfigVersion} from all available versions. */ - public static MlConfigVersion randomVersion(Random random) { - return ALL_VERSIONS.get(random.nextInt(ALL_VERSIONS.size())); - } - /** Returns a random {@link MlConfigVersion} between minVersion and maxVersion (inclusive). */ - public static MlConfigVersion randomVersionBetween( - Random random, - @Nullable MlConfigVersion minVersion, - @Nullable MlConfigVersion maxVersion - ) { + public static MlConfigVersion randomVersionBetween(@Nullable MlConfigVersion minVersion, @Nullable MlConfigVersion maxVersion) { if (minVersion != null && maxVersion != null && maxVersion.before(minVersion)) { throw new IllegalArgumentException("maxVersion [" + maxVersion + "] cannot be less than minVersion [" + minVersion + "]"); } @@ -61,7 +53,7 @@ public static MlConfigVersion randomVersionBetween( } else { // minVersionIndex is inclusive so need to add 1 to this index int range = maxVersionIndex + 1 - minVersionIndex; - return ALL_VERSIONS.get(minVersionIndex + random.nextInt(range)); + return ALL_VERSIONS.get(minVersionIndex + random().nextInt(range)); } } @@ -85,7 +77,7 @@ public static MlConfigVersion getPreviousVersion(MlConfigVersion version) { } /** Returns a random {@code MlConfigVersion} that is compatible with {@link MlConfigVersion#CURRENT} */ - public static MlConfigVersion randomCompatibleVersion(Random random) { - return randomVersionBetween(random, MlConfigVersion.FIRST_ML_VERSION, MlConfigVersion.CURRENT); + public static MlConfigVersion randomCompatibleVersion() { + return randomVersionBetween(MlConfigVersion.FIRST_ML_VERSION, MlConfigVersion.CURRENT); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/apikey/InvalidateApiKeyRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/apikey/InvalidateApiKeyRequestTests.java index afde4af9572fc..634d8659e39cd 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/apikey/InvalidateApiKeyRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/apikey/InvalidateApiKeyRequestTests.java @@ -174,7 +174,7 @@ public void testSerialization() throws IOException { final boolean ownedByAuthenticatedUser = true; InvalidateApiKeyRequest invalidateApiKeyRequest = InvalidateApiKeyRequest.usingApiKeyId(apiKeyId, ownedByAuthenticatedUser); { - TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(); ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer); out.setTransportVersion(transportVersion); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java index e507b63b55471..22b2876586fcb 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java @@ -66,7 +66,7 @@ public void testSerialization() throws IOException { } public void testSerializationForCurrentVersion() throws Exception { - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final boolean canIncludeRemoteCluster = version.supports(ROLE_REMOTE_CLUSTER_PRIVS); final GetUserPrivilegesResponse original = randomResponse(canIncludeRemoteCluster); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/HasPrivilegesRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/HasPrivilegesRequestTests.java index 7b3bf57899a30..ecc3387869de8 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/HasPrivilegesRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/HasPrivilegesRequestTests.java @@ -31,7 +31,7 @@ public class HasPrivilegesRequestTests extends ESTestCase { public void testSerializationCurrentVersion() throws IOException { final HasPrivilegesRequest original = randomRequest(); - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final HasPrivilegesRequest copy = serializeAndDeserialize(original, version); assertThat(copy.username(), equalTo(original.username())); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java index e6ac337e221c1..ff9c05cd0b224 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java @@ -113,10 +113,7 @@ public void testWriteToWithCloudApiKeyThrowsOnUnsupportedVersion() { ); try (BytesStreamOutput out = new BytesStreamOutput()) { - final TransportVersion version = TransportVersionUtils.randomVersionNotSupporting( - random(), - SECURITY_CLOUD_API_KEY_REALM_AND_TYPE - ); + final TransportVersion version = TransportVersionUtils.randomVersionNotSupporting(SECURITY_CLOUD_API_KEY_REALM_AND_TYPE); out.setTransportVersion(version); final var ex = expectThrows(IllegalArgumentException.class, () -> authentication.writeTo(out)); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java index 0d7b4ded1b218..ebf28f85337b6 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java @@ -856,7 +856,7 @@ public void testBwcWithStoredAuthenticationHeaders() throws IOException { assertThat(authenticationV6.encode(), equalTo(headerV6)); // Rewrite for a different version - final TransportVersion newVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion newVersion = TransportVersionUtils.randomCompatibleVersion(); final Authentication rewrittenAuthentication = authenticationV6.maybeRewriteForOlderVersion(newVersion); assertThat(rewrittenAuthentication.getEffectiveSubject().getTransportVersion(), equalTo(newVersion)); assertThat(rewrittenAuthentication.getEffectiveSubject().getUser(), equalTo(authenticationV6.getEffectiveSubject().getUser())); @@ -904,7 +904,6 @@ public void testMaybeRewriteMetadataForCrossClusterAccessAuthentication() throws .build(); // pick a version before that of the authentication instance to force a rewrite final TransportVersion olderVersion = TransportVersionUtils.randomVersionNotSupporting( - random(), authentication.getEffectiveSubject().getTransportVersion() ); @@ -945,8 +944,8 @@ public void testCopyWithFilteredMetadataFields() { } public void testMaybeRewriteForOlderVersionDoesNotEraseDomainForVersionsAfterDomains() { - final TransportVersion olderVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); - TransportVersion transportVersion = TransportVersionUtils.randomVersionSupporting(random(), olderVersion); + final TransportVersion olderVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); + TransportVersion transportVersion = TransportVersionUtils.randomVersionSupporting(olderVersion); final Authentication authentication = AuthenticationTestHelper.builder() .realm() // randomize to test both when realm is null on the original auth and non-null, instead of setting `underDomain` // Use CURRENT to force newer version in case randomVersionSupporting above picks olderVersion diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java index 288a2f0296e2e..3ae8cd6756b0a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java @@ -617,7 +617,7 @@ public void testParsingFieldPermissionsUsesCache() throws IOException { } public void testSerializationForCurrentVersion() throws Exception { - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final boolean canIncludeRemoteClusters = version.supports(ROLE_REMOTE_CLUSTER_PRIVS); final boolean canIncludeDescription = version.supports(SECURITY_ROLE_DESCRIPTION); logger.info("Testing serialization with version {}", version); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParamsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParamsTests.java index 865f41267e3ab..a954ee6b917af 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParamsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParamsTests.java @@ -21,7 +21,7 @@ public class TransformTaskParamsTests extends AbstractSerializingTransformTestCa private static TransformTaskParams randomTransformTaskParams() { return new TransformTaskParams( randomAlphaOfLengthBetween(1, 10), - randomBoolean() ? TransformConfigVersionUtils.randomVersion(random()) : null, + randomBoolean() ? TransformConfigVersionUtils.randomVersion() : null, randomBoolean() ? Instant.ofEpochMilli(randomLongBetween(0, 1_000_000_000_000L)) : null, randomBoolean() ? TimeValue.timeValueSeconds(randomLongBetween(1, 24 * 60 * 60)) : null, randomBoolean() diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/utils/TransformConfigVersionUtils.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/utils/TransformConfigVersionUtils.java index 405caee2ab039..c31432f3be0e9 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/utils/TransformConfigVersionUtils.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/utils/TransformConfigVersionUtils.java @@ -14,7 +14,6 @@ import java.util.Collections; import java.util.List; -import java.util.Random; import java.util.Set; import java.util.stream.Collectors; @@ -33,22 +32,8 @@ public static TransformConfigVersion randomVersion(Set i return ESTestCase.randomFrom(ALL_VERSIONS.stream().filter(v -> ignore.contains(v) == false).collect(Collectors.toList())); } - /** Returns a random {@link TransformConfigVersion} from all available versions. */ - public static TransformConfigVersion randomVersion(Random random) { - return ALL_VERSIONS.get(random.nextInt(ALL_VERSIONS.size())); - } - - /** Returns a random {@link TransformConfigVersion} between minVersion and maxVersion (inclusive). */ - public static TransformConfigVersion randomVersionBetween( - @Nullable TransformConfigVersion minVersion, - @Nullable TransformConfigVersion maxVersion - ) { - return randomVersionBetween(random(), minVersion, maxVersion); - } - /** Returns a random {@link TransformConfigVersion} between minVersion and maxVersion (inclusive). */ public static TransformConfigVersion randomVersionBetween( - Random random, @Nullable TransformConfigVersion minVersion, @Nullable TransformConfigVersion maxVersion ) { @@ -71,7 +56,7 @@ public static TransformConfigVersion randomVersionBetween( } else { // minVersionIndex is inclusive so need to add 1 to this index int range = maxVersionIndex + 1 - minVersionIndex; - return ALL_VERSIONS.get(minVersionIndex + random.nextInt(range)); + return ALL_VERSIONS.get(minVersionIndex + random().nextInt(range)); } } @@ -95,7 +80,7 @@ public static TransformConfigVersion getPreviousVersion(TransformConfigVersion v } /** Returns a random {@code TransformConfigVersion} that is compatible with {@link TransformConfigVersion#CURRENT} */ - public static TransformConfigVersion randomCompatibleVersion(Random random) { - return randomVersionBetween(random, TransformConfigVersion.FIRST_TRANSFORM_VERSION, TransformConfigVersion.CURRENT); + public static TransformConfigVersion randomCompatibleVersion() { + return randomVersionBetween(TransformConfigVersion.FIRST_TRANSFORM_VERSION, TransformConfigVersion.CURRENT); } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockSerializationTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockSerializationTests.java index 4aa40fd0f6cde..cfbcb3ffb8373 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockSerializationTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BlockSerializationTests.java @@ -423,7 +423,7 @@ public void testCompositeBlock() throws Exception { try ( CompositeBlock deserBlock = serializeDeserializeBlockWithVersion( origBlock, - TransportVersionUtils.randomVersionSupporting(random(), Block.ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK) + TransportVersionUtils.randomVersionSupporting(Block.ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK) ) ) { assertThat(deserBlock.getBlockCount(), equalTo(numBlocks)); @@ -485,7 +485,7 @@ public void testAggregateMetricDouble() throws IOException { try ( AggregateMetricDoubleBlock deserBlock = serializeDeserializeBlockWithVersion( origBlock, - TransportVersionUtils.randomVersionSupporting(random(), Block.ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK) + TransportVersionUtils.randomVersionSupporting(Block.ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK) ) ) { assertThat(deserBlock, equalTo(origBlock)); diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/SerializationTestCase.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/SerializationTestCase.java index 9e420bdab6590..09c27454d193c 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/SerializationTestCase.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/SerializationTestCase.java @@ -54,7 +54,7 @@ BlockStreamInput blockStreamInput(BytesStreamOutput out) { } T serializeDeserializeBlock(T origBlock) throws IOException { - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); return serializeDeserializeBlockWithVersion(origBlock, version); } diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java index 93e0319a0ca82..1f2a1d0ced280 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java @@ -526,7 +526,7 @@ public Object max(FieldName field) { public static final Configuration TEST_CFG = configuration(new QueryPragmas(Settings.EMPTY)); public static TransportVersion randomMinimumVersion() { - return TransportVersionUtils.randomCompatibleVersion(ESTestCase.random()); + return TransportVersionUtils.randomCompatibleVersion(); } // TODO: make this even simpler, remove the enrichResolution for tests that do not require it (most tests) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/analysis/MutableAnalyzerContext.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/analysis/MutableAnalyzerContext.java index eddf6a6046074..e75956ce3ad79 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/analysis/MutableAnalyzerContext.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/analysis/MutableAnalyzerContext.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.esql.analysis; import org.elasticsearch.TransportVersion; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.TransportVersionUtils; import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; import org.elasticsearch.xpack.esql.index.IndexResolution; @@ -62,7 +61,7 @@ public TransportVersion minimumVersion() { public RestoreTransportVersion setTemporaryTransportVersionOnOrAfter(TransportVersion minVersion) { TransportVersion oldVersion = this.currentVersion; // Set to a random version between minVersion and current - this.currentVersion = TransportVersionUtils.randomVersionSupporting(ESTestCase.random(), minVersion); + this.currentVersion = TransportVersionUtils.randomVersionSupporting(minVersion); return new RestoreTransportVersion(oldVersion); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java index 04b7bf6a626d0..bdd1ccdc895ad 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java @@ -50,11 +50,11 @@ public class PlanStreamOutputTests extends ESTestCase { public void testTransportVersion() throws IOException { BytesStreamOutput out = new BytesStreamOutput(); - TransportVersion v1 = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion v1 = TransportVersionUtils.randomCompatibleVersion(); out.setTransportVersion(v1); PlanStreamOutput planOut = new PlanStreamOutput(out, randomBoolean() ? null : randomConfiguration()); assertThat(planOut.getTransportVersion(), equalTo(v1)); - TransportVersion v2 = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion v2 = TransportVersionUtils.randomCompatibleVersion(); planOut.setTransportVersion(v2); assertThat(planOut.getTransportVersion(), equalTo(v2)); assertThat(out.getTransportVersion(), equalTo(v2)); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java index 1e0497486e840..e8a2eae8b8f2e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LocalPhysicalPlanOptimizerTests.java @@ -1161,7 +1161,7 @@ private static Object randomQueryValue(DataType dataType) { case KEYWORD -> randomAlphaOfLength(5); case IP -> NetworkAddress.format(randomIp(randomBoolean())); case TEXT -> randomAlphaOfLength(50); - case VERSION -> VersionUtils.randomVersion(random()).toString(); + case VERSION -> VersionUtils.randomVersion().toString(); default -> throw new IllegalArgumentException("Unexpected type: " + dataType); }; } diff --git a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/DeleteSamlServiceProviderRequestTests.java b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/DeleteSamlServiceProviderRequestTests.java index 4757b463ca0e6..8cd74a747353f 100644 --- a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/DeleteSamlServiceProviderRequestTests.java +++ b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/DeleteSamlServiceProviderRequestTests.java @@ -26,7 +26,7 @@ public void testSerialization() throws IOException { randomAlphaOfLengthBetween(1, 100), randomFrom(WriteRequest.RefreshPolicy.values()) ); - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final DeleteSamlServiceProviderRequest read = copyWriteable( request, new NamedWriteableRegistry(List.of()), diff --git a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/PutSamlServiceProviderRequestTests.java b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/PutSamlServiceProviderRequestTests.java index 7c39a48c2223e..1bb4d262f4070 100644 --- a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/PutSamlServiceProviderRequestTests.java +++ b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/PutSamlServiceProviderRequestTests.java @@ -84,7 +84,7 @@ public void testValidateRequiredFields() { public void testSerialization() throws IOException { final SamlServiceProviderDocument doc = SamlServiceProviderTestUtils.randomDocument(); final PutSamlServiceProviderRequest request = new PutSamlServiceProviderRequest(doc, RefreshPolicy.NONE); - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final PutSamlServiceProviderRequest read = copyWriteable( request, new NamedWriteableRegistry(List.of()), diff --git a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/SamlInitiateSingleSignOnRequestTests.java b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/SamlInitiateSingleSignOnRequestTests.java index 8480d7d6b562b..19673a10152ed 100644 --- a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/SamlInitiateSingleSignOnRequestTests.java +++ b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/action/SamlInitiateSingleSignOnRequestTests.java @@ -44,7 +44,7 @@ public void testSerializationCurrentVersion() throws Exception { assertThat("An invalid request is not guaranteed to serialize correctly", request.validate(), nullValue()); final BytesStreamOutput out = new BytesStreamOutput(); if (randomBoolean()) { - out.setTransportVersion(TransportVersionUtils.randomVersionSupporting(random(), IDP_CUSTOM_SAML_ATTRIBUTES)); + out.setTransportVersion(TransportVersionUtils.randomVersionSupporting(IDP_CUSTOM_SAML_ATTRIBUTES)); } request.writeTo(out); diff --git a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderDocumentTests.java b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderDocumentTests.java index 3cf7eb458be92..d156f1ed8f8f5 100644 --- a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderDocumentTests.java +++ b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/sp/SamlServiceProviderDocumentTests.java @@ -180,7 +180,7 @@ private SamlServiceProviderDocument assertXContentRoundTrip(SamlServiceProviderD } private SamlServiceProviderDocument assertSerializationRoundTrip(SamlServiceProviderDocument doc) throws IOException { - final TransportVersion version = TransportVersionUtils.randomVersionSupporting(random(), IDP_CUSTOM_SAML_ATTRIBUTES_ALLOW_LIST); + final TransportVersion version = TransportVersionUtils.randomVersionSupporting(IDP_CUSTOM_SAML_ATTRIBUTES_ALLOW_LIST); final SamlServiceProviderDocument read = copyWriteable( doc, new NamedWriteableRegistry(List.of()), diff --git a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/support/SamlAuthenticationStateTests.java b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/support/SamlAuthenticationStateTests.java index b48d3b8f270a7..be35ce76dbd84 100644 --- a/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/support/SamlAuthenticationStateTests.java +++ b/x-pack/plugin/identity-provider/src/test/java/org/elasticsearch/xpack/idp/saml/support/SamlAuthenticationStateTests.java @@ -88,7 +88,7 @@ private SamlAuthenticationState assertXContentRoundTrip(SamlAuthenticationState } private SamlAuthenticationState assertSerializationRoundTrip(SamlAuthenticationState state) throws IOException { - final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); final SamlAuthenticationState read = copyWriteable( state, new NamedWriteableRegistry(List.of()), diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java index 3755e93909265..8e8167fc58927 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleMetadataTests.java @@ -172,7 +172,7 @@ protected Reader> diffReader() { public void testMinimumSupportedVersion() { TransportVersion min = createTestInstance().getMinimalSupportedVersion(); - assertTrue(TransportVersionUtils.randomCompatibleVersion(random()).supports(min)); + assertTrue(TransportVersionUtils.randomCompatibleVersion().supports(min)); } public void testcontext() { diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java index e90889c48c832..04af0071e592a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticInferenceMetadataFieldsMapperTests.java @@ -96,7 +96,7 @@ public void testIsEnabledByDefault() { settings = Settings.builder() .put( IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), - IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT) + IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.INFERENCE_METADATA_FIELDS_BACKPORT) ) .build(); assertFalse(InferenceMetadataFieldsMapper.isEnabled(settings)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/AbstractInterceptedInferenceQueryBuilderTestCase.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/AbstractInterceptedInferenceQueryBuilderTestCase.java index 1d9f83aada4cf..99efd8b243ec3 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/AbstractInterceptedInferenceQueryBuilderTestCase.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/AbstractInterceptedInferenceQueryBuilderTestCase.java @@ -164,7 +164,7 @@ public void testSerialization() throws Exception { public void testBwCSerialization() throws Exception { for (int i = 0; i < 100; i++) { - TransportVersion transportVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + TransportVersion transportVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); serializationTestCase(transportVersion); } } @@ -267,7 +267,7 @@ public void testCcsBwCSerialization() throws Exception { final T nonInferenceFieldQuery = createQueryBuilder("non_inference_field"); for (int i = 0; i < 100; i++) { - TransportVersion transportVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + TransportVersion transportVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); QueryRewriteContext queryRewriteContext = createQueryRewriteContext( Map.of("local-index", Map.of(inferenceField, SPARSE_INFERENCE_ID)), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilderTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilderTests.java index 99da4e44bda5b..abb635e7e85df 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilderTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilderTests.java @@ -439,7 +439,7 @@ public void testSerializationBwc() throws IOException { }; for (int i = 0; i < 100; i++) { - TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(); assertSingleInferenceResult.accept(inferenceResults1, transportVersion); } @@ -486,7 +486,7 @@ public void testSerializationBwc() throws IOException { }; for (int i = 0; i < 100; i++) { - TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion transportVersion = TransportVersionUtils.randomCompatibleVersion(); assertMultipleInferenceResults.accept(List.of(inferenceResults1, inferenceResults2), transportVersion); } } @@ -501,7 +501,7 @@ public void testSerializationCcsBwc() throws Exception { SemanticQueryBuilder originalQuery = new SemanticQueryBuilder(randomAlphaOfLength(5), randomAlphaOfLength(5), null, Map.of(), true); for (int i = 0; i < 100; i++) { - TransportVersion transportVersion = TransportVersionUtils.randomVersionNotSupporting(random(), TransportVersion.current()); + TransportVersion transportVersion = TransportVersionUtils.randomVersionNotSupporting(TransportVersion.current()); if (transportVersion.supports(SEMANTIC_SEARCH_CCS_SUPPORT)) { QueryBuilder deserializedQuery = copyNamedWriteable( diff --git a/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricDoubleFieldMapperTests.java b/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricDoubleFieldMapperTests.java index a8229a48e7269..f3278833afc78 100644 --- a/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricDoubleFieldMapperTests.java +++ b/x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricDoubleFieldMapperTests.java @@ -668,7 +668,7 @@ public void testIndexTypes() throws Exception { assertIndexType(ft, IndexType.skippers()); } { - var oldVersion = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.AGG_METRIC_DOUBLE_REMOVE_POINTS); + var oldVersion = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.AGG_METRIC_DOUBLE_REMOVE_POINTS); MapperService mapperService = createMapperService(oldVersion, fieldMapping(this::minimalMapping)); MappedFieldType ft = mapperService.fieldType("field"); assertIndexType(ft, IndexType.points(true, true)); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/heuristic/PValueScoreTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/heuristic/PValueScoreTests.java index 5119e81e18675..e6abddf5b44e8 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/heuristic/PValueScoreTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/heuristic/PValueScoreTests.java @@ -34,7 +34,7 @@ public class PValueScoreTests extends AbstractNXYSignificanceHeuristicTestCase { @Override protected TransportVersion randomVersion() { - return TransportVersionUtils.randomCompatibleVersion(random()); + return TransportVersionUtils.randomCompatibleVersion(); } @Override diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringInfoTransportActionTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringInfoTransportActionTests.java index 9fc62d1ecf6fd..7caeb2e1d6574 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringInfoTransportActionTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MonitoringInfoTransportActionTests.java @@ -57,7 +57,7 @@ public void testMonitoringEnabledByDefault() { } public void testUsage() throws Exception { - TransportVersion serializedVersion = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion serializedVersion = TransportVersionUtils.randomCompatibleVersion(); final boolean collectionEnabled = randomBoolean(); int localCount = randomIntBetween(0, 5); List exporterList = new ArrayList<>(); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java index e210ea9d6b2db..c7c0019ac3359 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkResponseTests.java @@ -65,7 +65,7 @@ public void testSerialization() throws IOException { response = new MonitoringBulkResponse(Math.abs(randomLong()), new MonitoringBulkResponse.Error(exception)); } - TransportVersion version = TransportVersionUtils.randomVersion(random()); + TransportVersion version = TransportVersionUtils.randomVersion(); BytesStreamOutput output = new BytesStreamOutput(); output.setTransportVersion(version); response.writeTo(output); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java index f78ba44be775e..99f8b52cd65fb 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/VersionHttpResourceTests.java @@ -36,7 +36,7 @@ public class VersionHttpResourceTests extends ESTestCase { private final ActionListener publishListener = mockPublishResultActionListener(); public void testDoCheckAndPublishSuccess() { - final Version minimumVersion = VersionUtils.randomVersion(random()); + final Version minimumVersion = VersionUtils.randomVersion(); final Version version = randomFrom(minimumVersion, Version.CURRENT); final Response response = responseForVersion(version); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java index 917b30f7e3625..24fed79fcac26 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java @@ -527,7 +527,7 @@ public void testJoinValidatorOnDisabledSecurity() throws Exception { public void testJoinValidatorForFIPSOnAllowedLicense() throws Exception { DiscoveryNode node = DiscoveryNodeUtils.builder("foo") - .version(VersionUtils.randomVersion(random()), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) + .version(VersionUtils.randomVersion(), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) .build(); Metadata.Builder builder = Metadata.builder(); License license = TestUtils.generateSignedLicense( @@ -552,7 +552,7 @@ public void testJoinValidatorForFIPSOnAllowedLicense() throws Exception { public void testJoinValidatorForFIPSOnForbiddenLicense() throws Exception { DiscoveryNode node = DiscoveryNodeUtils.builder("foo") - .version(VersionUtils.randomVersion(random()), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) + .version(VersionUtils.randomVersion(), IndexVersions.ZERO, IndexVersionUtils.randomVersion()) .build(); Metadata.Builder builder = Metadata.builder(); final String forbiddenLicenseType = randomFrom( diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java index c783722e051c3..21ccd929cadc4 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ApiKeyServiceTests.java @@ -3108,7 +3108,7 @@ public void testValidateOwnerUserRoleDescriptorsWithWorkflowsRestriction() { ); final ClusterState clusterState = mock(ClusterState.class); when(clusterService.state()).thenReturn(clusterState); - final TransportVersion minTransportVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion minTransportVersion = TransportVersionUtils.randomCompatibleVersion(); when(clusterState.getMinTransportVersion()).thenReturn(minTransportVersion); final ApiKeyService service = new ApiKeyService( Settings.EMPTY, diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java index 19286ebf58dc6..a1451361c9606 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/support/mapper/ExpressionRoleMappingTests.java @@ -407,7 +407,7 @@ public void testToXContentWithTemplates() throws Exception { public void testSerialization() throws Exception { final ExpressionRoleMapping original = randomRoleMapping(true); - TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random()); + TransportVersion version = TransportVersionUtils.randomCompatibleVersion(); BytesStreamOutput output = new BytesStreamOutput(); output.setTransportVersion(version); original.writeTo(output); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java index 77ba711f4c7ea..17600f118c7b4 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationUtilsTests.java @@ -183,6 +183,6 @@ private void assertSwitchBasedOnOriginAndExecute(String origin, User user, Trans } private TransportVersion randomTransportVersion() { - return TransportVersionUtils.randomCompatibleVersion(random()); + return TransportVersionUtils.randomCompatibleVersion(); } } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/SearchRequestCacheDisablingInterceptorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/SearchRequestCacheDisablingInterceptorTests.java index d35b02b24bab0..e6d2acc639a3c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/SearchRequestCacheDisablingInterceptorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/interceptor/SearchRequestCacheDisablingInterceptorTests.java @@ -76,7 +76,7 @@ private void configureMinMondeVersion(Version version) { } public void testRequestCacheWillBeDisabledWhenSearchRemoteIndices() { - configureMinMondeVersion(VersionUtils.randomVersion(random())); + configureMinMondeVersion(VersionUtils.randomVersion()); final SearchRequest searchRequest = mock(SearchRequest.class); when(searchRequest.source()).thenReturn(SearchSourceBuilder.searchSource()); RequestInfo requestInfo = new RequestInfo( diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/QueryableBuiltInRolesSynchronizerTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/QueryableBuiltInRolesSynchronizerTests.java index cf06d16d223ca..9327c9433526b 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/QueryableBuiltInRolesSynchronizerTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/support/QueryableBuiltInRolesSynchronizerTests.java @@ -592,7 +592,7 @@ private DiscoveryNodes mixedVersionNodes() { VersionInformation oldVersion = new VersionInformation( VersionUtils.randomVersionBetween(null, VersionUtils.getPreviousVersion()), IndexVersions.MINIMUM_COMPATIBLE, - IndexVersionUtils.randomCompatibleVersion(random()) + IndexVersionUtils.randomCompatibleVersion() ); return nodes(randomIntBetween(1, 3), true).add( DiscoveryNodeUtils.builder("old-data-node") diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java index 8b3c4b2059dbc..98ca0e4092bea 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java @@ -406,7 +406,7 @@ public void sendRequest( final AsyncSender sender = interceptor.interceptSender(intercepted); Transport.Connection connection = mock(Transport.Connection.class); - final TransportVersion connectionVersion = TransportVersionUtils.randomCompatibleVersion(random()); + final TransportVersion connectionVersion = TransportVersionUtils.randomCompatibleVersion(); when(connection.getTransportVersion()).thenReturn(connectionVersion); sender.sendRequest(connection, "indices:foo[s]", null, null, null); diff --git a/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java b/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java index 6e7f2d82cfb1d..a176180935fd2 100644 --- a/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java +++ b/x-pack/plugin/snapshot-based-recoveries/src/test/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerServiceTests.java @@ -211,7 +211,7 @@ public void testLogicallyEquivalentSnapshotIsUsedEvenIfFilesAreDifferent() throw final IndexVersion snapshotVersion; final Version luceneVersion; if (compatibleVersion) { - snapshotVersion = IndexVersionUtils.randomCompatibleVersion(random()); + snapshotVersion = IndexVersionUtils.randomCompatibleVersion(); luceneVersion = snapshotVersion.luceneVersion(); } else { snapshotVersion = IndexVersion.fromId(Integer.MAX_VALUE); diff --git a/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/CartesianShapeIT.java b/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/CartesianShapeIT.java index eb4515a897118..7be476b6bda2c 100644 --- a/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/CartesianShapeIT.java +++ b/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/CartesianShapeIT.java @@ -36,7 +36,7 @@ protected void getGeoShapeMapping(XContentBuilder b) throws IOException { @Override protected IndexVersion randomSupportedVersion() { - return IndexVersionUtils.randomCompatibleWriteVersion(random()); + return IndexVersionUtils.randomCompatibleWriteVersion(); } @Override diff --git a/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoBoundingBoxQueryGeoShapeWithDocValuesIT.java b/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoBoundingBoxQueryGeoShapeWithDocValuesIT.java index 4a6fa5d545bef..fc56d42655a2c 100644 --- a/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoBoundingBoxQueryGeoShapeWithDocValuesIT.java +++ b/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoBoundingBoxQueryGeoShapeWithDocValuesIT.java @@ -40,6 +40,6 @@ public XContentBuilder getMapping() throws IOException { @Override public IndexVersion randomSupportedVersion() { - return IndexVersionUtils.randomCompatibleWriteVersion(random()); + return IndexVersionUtils.randomCompatibleWriteVersion(); } } diff --git a/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoShapeWithDocValuesIT.java b/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoShapeWithDocValuesIT.java index 0857b078be579..26d63ea405a5a 100644 --- a/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoShapeWithDocValuesIT.java +++ b/x-pack/plugin/spatial/src/internalClusterTest/java/org/elasticsearch/xpack/spatial/search/GeoShapeWithDocValuesIT.java @@ -60,7 +60,7 @@ protected void getGeoShapeMapping(XContentBuilder b) throws IOException { @Override protected IndexVersion randomSupportedVersion() { - return IndexVersionUtils.randomCompatibleWriteVersion(random()); + return IndexVersionUtils.randomCompatibleWriteVersion(); } @Override diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java index a64482df8fec0..f6af27b661b7c 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapperTests.java @@ -325,7 +325,7 @@ public void testGeoShapeLegacyParametersParsing() throws Exception { }; // indices created before 8 should allow parameters but issue a warning - IndexVersion pre8version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + IndexVersion pre8version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); MapperService m = createMapperService( pre8version, fieldMapping(b -> b.field("type", getFieldName()).field(deprecatedParam, value)) @@ -359,7 +359,7 @@ public void testGeoShapeLegacyParametersParsing() throws Exception { } // indices created after 8 should throw an error - IndexVersion post8version = IndexVersionUtils.randomCompatibleWriteVersion(random()); + IndexVersion post8version = IndexVersionUtils.randomCompatibleWriteVersion(); Exception ex = expectThrows( MapperParsingException.class, () -> createMapperService(post8version, fieldMapping(b -> b.field("type", getFieldName()).field(deprecatedParam, value))) @@ -376,7 +376,7 @@ public void testGeoShapeLegacyParametersParsing() throws Exception { } public void testGeoShapeLegacyMerge() throws Exception { - IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); MapperService m = createMapperService(version, fieldMapping(b -> b.field("type", getFieldName()))); Exception e = expectThrows( IllegalArgumentException.class, @@ -393,7 +393,7 @@ public void testGeoShapeLegacyMerge() throws Exception { } public void testGeoShapeLegacyCircle() throws Exception { - IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(random(), IndexVersions.V_8_0_0); + IndexVersion version = IndexVersionUtils.randomPreviousCompatibleVersion(IndexVersions.V_8_0_0); MapperService mapperService = createMapperService(version, fieldMapping(b -> { b.field("type", getFieldName()); b.field("strategy", "recursive");