Skip to content

Commit 51fe66b

Browse files
committed
added ClusterStatsIT test for search node role
Signed-off-by: Vinay Krishna Pudyodu <[email protected]>
1 parent add23cf commit 51fe66b

File tree

1 file changed

+24
-1
lines changed
  • server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats

1 file changed

+24
-1
lines changed

server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,29 @@ public void testNodeRolesWithDataNodeLegacySettings() throws ExecutionException,
594594
assertEquals(expectedNodesRoles, Set.of(getNodeRoles(client, 0), getNodeRoles(client, 1)));
595595
}
596596

597+
public void testNodeRolesWithSearchNode() throws ExecutionException, InterruptedException {
598+
int total = 2;
599+
internalCluster().startClusterManagerOnlyNodes(1);
600+
internalCluster().startSearchOnlyNode();
601+
waitForNodes(total);
602+
603+
Map<String, Integer> expectedRoleCounts = getExpectedCounts(0, 1, 1, 0, 0, 0, 1, 0);
604+
605+
Client client = client();
606+
ClusterStatsResponse clusterStatsResponse = client.admin()
607+
.cluster()
608+
.prepareClusterStats()
609+
.useAggregatedNodeLevelResponses(randomBoolean())
610+
.get();
611+
assertCounts(clusterStatsResponse.getNodesStats().getCounts(), total, expectedRoleCounts);
612+
613+
Set<Set<String>> expectedNodesRoles = Set.of(
614+
Set.of(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName()),
615+
Set.of(DiscoveryNodeRole.SEARCH_ROLE.roleName())
616+
);
617+
assertEquals(expectedNodesRoles, Set.of(getNodeRoles(client, 0), getNodeRoles(client, 1)));
618+
}
619+
597620
public void testClusterStatsWithNodeMetricsFilter() {
598621
internalCluster().startNode();
599622
ensureGreen();
@@ -898,7 +921,7 @@ private Map<String, Integer> getExpectedCounts(
898921
expectedCounts.put(DiscoveryNodeRole.INGEST_ROLE.roleName(), ingestRoleCount);
899922
expectedCounts.put(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), remoteClusterClientRoleCount);
900923
expectedCounts.put(DiscoveryNodeRole.WARM_ROLE.roleName(), warmRoleCount);
901-
expectedCounts.put(DiscoveryNodeRole.SEARCH_ROLE.roleName(), warmRoleCount);
924+
expectedCounts.put(DiscoveryNodeRole.SEARCH_ROLE.roleName(), searchRoleCount);
902925
expectedCounts.put(ClusterStatsNodes.Counts.COORDINATING_ONLY, coordinatingOnlyCount);
903926
return expectedCounts;
904927
}

0 commit comments

Comments
 (0)