From 6b8cb583edc579b596fca347d8a98929a1d12ff2 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Thu, 17 Aug 2023 11:37:50 +0100 Subject: [PATCH] Update allowed inferred versions to include 8.10 (#98578) Update some tests that could pass CURRENT to infer versions to real versions --- .../cluster/node/VersionInformation.java | 2 +- .../action/bulk/TransportBulkActionTests.java | 8 +++++++- .../action/bulk/TransportBulkActionTookTests.java | 8 +++++++- .../PublicationTransportHandlerTests.java | 14 ++++++++++++-- .../allocation/AllocationCommandsTests.java | 6 +++--- .../routing/allocation/FailedNodeRoutingTests.java | 7 ++++++- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/node/VersionInformation.java b/server/src/main/java/org/elasticsearch/cluster/node/VersionInformation.java index 84b5946c8e19f..631280663fcb0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/node/VersionInformation.java +++ b/server/src/main/java/org/elasticsearch/cluster/node/VersionInformation.java @@ -32,7 +32,7 @@ public static VersionInformation inferVersions(Version nodeVersion) { return null; } else if (nodeVersion.equals(Version.CURRENT)) { return CURRENT; - } else if (nodeVersion.before(Version.V_8_10_0)) { + } else if (nodeVersion.onOrBefore(Version.V_8_10_0)) { return new VersionInformation( nodeVersion, IndexVersion.fromId(nodeVersion.minimumIndexCompatibilityVersion().id), 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 d92387dc818e2..03229e14d724a 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.IndexingPressure; import org.elasticsearch.index.VersionType; import org.elasticsearch.indices.EmptySystemIndices; @@ -40,6 +41,7 @@ import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.test.transport.CapturingTransport; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; @@ -107,7 +109,11 @@ public void setUp() throws Exception { super.setUp(); threadPool = new TestThreadPool(getClass().getName()); DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node") - .version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT)) + .version( + VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + IndexVersion.MINIMUM_COMPATIBLE, + IndexVersionUtils.randomCompatibleVersion(random()) + ) .build(); clusterService = createClusterService(threadPool, discoveryNode); CapturingTransport capturingTransport = new CapturingTransport(); 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 d13fe14416631..7e9556be18f6d 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java @@ -29,11 +29,13 @@ import org.elasticsearch.common.util.concurrent.AtomicArray; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.IndexingPressure; import org.elasticsearch.indices.EmptySystemIndices; import org.elasticsearch.tasks.Task; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.test.transport.CapturingTransport; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; @@ -77,7 +79,11 @@ public static void afterClass() { public void setUp() throws Exception { super.setUp(); DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node") - .version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT)) + .version( + VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + IndexVersion.MINIMUM_COMPATIBLE, + IndexVersionUtils.randomCompatibleVersion(random()) + ) .build(); clusterService = createClusterService(threadPool, discoveryNode); } 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 98af9283d7863..7e11d33a2a396 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/PublicationTransportHandlerTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/PublicationTransportHandlerTests.java @@ -36,11 +36,13 @@ import org.elasticsearch.common.util.concurrent.DeterministicTaskQueue; import org.elasticsearch.core.IOUtils; import org.elasticsearch.core.Nullable; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.TransportVersionUtils; import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.test.transport.MockTransport; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; @@ -224,7 +226,11 @@ public RecyclerBytesStreamOutput newNetworkBytesStream() { final List allNodes = new ArrayList<>(); while (allNodes.size() < 10) { var node = DiscoveryNodeUtils.builder("node-" + allNodes.size()) - .version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT)) + .version( + VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + IndexVersion.MINIMUM_COMPATIBLE, + IndexVersionUtils.randomCompatibleVersion(random()) + ) .build(); allNodes.add(node); nodeTransports.put( @@ -355,7 +361,11 @@ public void testIncludesLastCommittedFieldsInDiffSerialization() { final var localNode = DiscoveryNodeUtils.create("localNode"); final var otherNode = DiscoveryNodeUtils.builder("otherNode") - .version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT)) + .version( + VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + IndexVersion.MINIMUM_COMPATIBLE, + IndexVersionUtils.randomCompatibleVersion(random()) + ) .build(); for (final var discoveryNode : List.of(localNode, otherNode)) { final var transport = new MockTransport() { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java index b51889170b904..958532011b281 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java @@ -713,9 +713,9 @@ public void testCanceledShardIsInitializedRespectingAllocationDeciders() { ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) .nodes( DiscoveryNodes.builder() - .add(newNode("node-0", Version.V_8_10_0)) - .add(newNode("node-1", Version.V_8_9_0)) - .add(newNode("node-2", Version.V_8_9_0)) + .add(newNode("node-0", Version.V_8_10_0, IndexVersion.V_8_10_0)) + .add(newNode("node-1", Version.V_8_9_0, IndexVersion.V_8_9_0)) + .add(newNode("node-2", Version.V_8_9_0, IndexVersion.V_8_9_0)) ) .metadata(Metadata.builder().put(indexMetadata, false)) .routingTable(RoutingTable.builder().add(IndexRoutingTable.builder(shardId.getIndex()).addShard(primary).addShard(replica))) 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 f8b61f3dbd1ec..1d796c931270b 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 @@ -36,6 +36,7 @@ import org.elasticsearch.index.IndexVersion; import org.elasticsearch.indices.cluster.ClusterStateChanges; import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; @@ -224,7 +225,11 @@ protected DiscoveryNode createNode(DiscoveryNodeRole... mustHaveRoles) { return DiscoveryNodeUtils.builder(id) .name(id) .roles(roles) - .version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT)) + .version( + VersionUtils.randomCompatibleVersion(random(), Version.CURRENT), + IndexVersion.MINIMUM_COMPATIBLE, + IndexVersionUtils.randomCompatibleVersion(random()) + ) .build(); }