From 7a3ae726b4d137470233bb6ec15d62f35748949b Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Fri, 10 Nov 2023 06:59:47 -0500 Subject: [PATCH] Fixing test failure due to inferred index version (#101984) Does what it says on the tin. closes: #101964 --- .../search/SearchShardsResponseTests.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 450cbdba85473..6d9f3dfaefcf0 100644 --- a/server/src/test/java/org/elasticsearch/action/search/SearchShardsResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/SearchShardsResponseTests.java @@ -9,6 +9,7 @@ package org.elasticsearch.action.search; import org.elasticsearch.TransportVersion; +import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsGroup; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -23,6 +24,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.util.iterable.Iterables; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.query.RandomQueryBuilder; import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.index.shard.ShardId; @@ -30,7 +32,6 @@ import org.elasticsearch.search.internal.AliasFilter; import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.test.TransportVersionUtils; -import org.elasticsearch.test.VersionUtils; import java.io.IOException; import java.util.ArrayList; @@ -39,6 +40,7 @@ import java.util.List; import java.util.Map; +import static org.elasticsearch.test.VersionUtils.randomCompatibleVersion; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; @@ -109,16 +111,14 @@ protected SearchShardsResponse mutateInstance(SearchShardsResponse r) throws IOE } public void testLegacyResponse() { - DiscoveryNode node1 = DiscoveryNodeUtils.create( - "node-1", - new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF)), - VersionUtils.randomVersion(random()) - ); - DiscoveryNode node2 = DiscoveryNodeUtils.create( - "node-2", - new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF)), - VersionUtils.randomVersion(random()) - ); + DiscoveryNode node1 = DiscoveryNodeUtils.builder("node-1") + .address(new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF))) + .version(randomCompatibleVersion(random(), Version.CURRENT), IndexVersion.MINIMUM_COMPATIBLE, IndexVersion.current()) + .build(); + DiscoveryNode node2 = DiscoveryNodeUtils.builder("node-2") + .address(new TransportAddress(TransportAddress.META_ADDRESS, randomInt(0xFFFF))) + .version(randomCompatibleVersion(random(), Version.CURRENT), IndexVersion.MINIMUM_COMPATIBLE, IndexVersion.current()) + .build(); final ClusterSearchShardsGroup[] groups = new ClusterSearchShardsGroup[2]; { ShardId shardId = new ShardId("index-1", "uuid-1", 0);