From 6784f540235a9940823f1acd8248b7f4c648419e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dematt=C3=A9?= Date: Fri, 10 Nov 2023 14:05:38 +0100 Subject: [PATCH] Backport Fix ClusterSearchShardsResponseTests#testSerialization (#102005) --- .../shards/ClusterSearchShardsResponseTests.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 1922aa4042ebd..e919b4aedf38b 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 @@ -9,6 +9,7 @@ package org.elasticsearch.action.admin.cluster.shards; import org.elasticsearch.TransportVersion; +import org.elasticsearch.Version; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.routing.ShardRouting; @@ -20,13 +21,13 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.query.RandomQueryBuilder; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.internal.AliasFilter; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.TransportVersionUtils; -import org.elasticsearch.test.VersionUtils; import java.util.ArrayList; import java.util.Collections; @@ -36,6 +37,8 @@ import java.util.Map; import java.util.Set; +import static org.elasticsearch.test.VersionUtils.randomCompatibleVersion; + public class ClusterSearchShardsResponseTests extends ESTestCase { public void testSerialization() throws Exception { @@ -49,12 +52,10 @@ public void testSerialization() throws Exception { String nodeId = randomAlphaOfLength(10); ShardRouting shardRouting = TestShardRouting.newShardRouting(shardId, nodeId, randomBoolean(), ShardRoutingState.STARTED); clusterSearchShardsGroups[i] = new ClusterSearchShardsGroup(shardId, new ShardRouting[] { shardRouting }); - DiscoveryNode node = DiscoveryNodeUtils.create( - shardRouting.currentNodeId(), - new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF)), - VersionUtils.randomVersion(random()) - ); - nodes.add(node); + DiscoveryNodeUtils.Builder node = DiscoveryNodeUtils.builder(shardRouting.currentNodeId()) + .address(new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF))) + .version(randomCompatibleVersion(random(), Version.CURRENT), IndexVersion.MINIMUM_COMPATIBLE, IndexVersion.current()); + nodes.add(node.build()); AliasFilter aliasFilter; if (randomBoolean()) { aliasFilter = AliasFilter.of(RandomQueryBuilder.createQuery(random()), "alias-" + index);