Skip to content

Commit

Permalink
Backport Fix ClusterSearchShardsResponseTests#testSerialization (elas…
Browse files Browse the repository at this point in the history
  • Loading branch information
ldematte authored Nov 10, 2023
1 parent 4ab056e commit 6784f54
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit 6784f54

Please sign in to comment.