Skip to content

Commit 7aa103a

Browse files
committed
Fixed failing unit tests
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
1 parent 2d44cb9 commit 7aa103a

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import java.util.stream.Collectors;
6363
import java.util.stream.Stream;
6464

65+
import static org.opensearch.cluster.node.DiscoveryNodeRole.SEARCH_ROLE;
6566
import static org.opensearch.node.NodeRoleSettings.NODE_ROLES_SETTING;
6667
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_NODE_ATTRIBUTE_KEY_PREFIX;
6768
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.isClusterStateRepoConfigured;
@@ -494,7 +495,7 @@ public boolean isWarmNode() {
494495
* @return true if the node contains a search role, false otherwise
495496
*/
496497
public boolean isSearchNode() {
497-
return roles.contains(DiscoveryNodeRole.SEARCH_ROLE);
498+
return roles.contains(SEARCH_ROLE);
498499
}
499500

500501
/**

server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public void validateRole(List<DiscoveryNodeRole> roles) {
342342
* The built-in node roles.
343343
*/
344344
public static SortedSet<DiscoveryNodeRole> BUILT_IN_ROLES = Collections.unmodifiableSortedSet(
345-
new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, CLUSTER_MANAGER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE, WARM_ROLE))
345+
new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, CLUSTER_MANAGER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE, WARM_ROLE, SEARCH_ROLE))
346346
);
347347

348348
/**

server/src/test/java/org/opensearch/cluster/routing/allocation/FailedShardsRoutingTests.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,13 @@ public void testPreferReplicaOnRemoteNodeForPrimaryPromotion() {
860860
REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY,
861861
"REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_VALUE"
862862
);
863+
Set<DiscoveryNodeRole> nodeRoles = new HashSet<>(DiscoveryNodeRole.BUILT_IN_ROLES);
864+
nodeRoles.remove(DiscoveryNodeRole.SEARCH_ROLE);
863865
DiscoveryNode remoteNode1 = new DiscoveryNode(
864866
UUIDs.base64UUID(),
865867
buildNewFakeTransportAddress(),
866868
remoteStoreNodeAttributes,
867-
DiscoveryNodeRole.BUILT_IN_ROLES,
869+
nodeRoles,
868870
Version.CURRENT
869871
);
870872
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(remoteNode1)).build();
@@ -881,18 +883,30 @@ public void testPreferReplicaOnRemoteNodeForPrimaryPromotion() {
881883
UUIDs.base64UUID(),
882884
buildNewFakeTransportAddress(),
883885
remoteStoreNodeAttributes,
884-
DiscoveryNodeRole.BUILT_IN_ROLES,
886+
nodeRoles,
885887
Version.CURRENT
886888
);
887889
DiscoveryNode remoteNode3 = new DiscoveryNode(
888890
UUIDs.base64UUID(),
889891
buildNewFakeTransportAddress(),
890892
remoteStoreNodeAttributes,
891-
DiscoveryNodeRole.BUILT_IN_ROLES,
893+
nodeRoles,
894+
Version.CURRENT
895+
);
896+
DiscoveryNode nonRemoteNode1 = new DiscoveryNode(
897+
UUIDs.base64UUID(),
898+
buildNewFakeTransportAddress(),
899+
Map.of(),
900+
nodeRoles,
901+
Version.CURRENT
902+
);
903+
DiscoveryNode nonRemoteNode2 = new DiscoveryNode(
904+
UUIDs.base64UUID(),
905+
buildNewFakeTransportAddress(),
906+
Map.of(),
907+
nodeRoles,
892908
Version.CURRENT
893909
);
894-
DiscoveryNode nonRemoteNode1 = new DiscoveryNode(UUIDs.base64UUID(), buildNewFakeTransportAddress(), Version.CURRENT);
895-
DiscoveryNode nonRemoteNode2 = new DiscoveryNode(UUIDs.base64UUID(), buildNewFakeTransportAddress(), Version.CURRENT);
896910
List<DiscoveryNode> replicaShardNodes = List.of(remoteNode2, remoteNode3, nonRemoteNode1, nonRemoteNode2);
897911

898912
for (int i = 0; i < 4; i++) {

0 commit comments

Comments
 (0)