@@ -594,6 +594,29 @@ public void testNodeRolesWithDataNodeLegacySettings() throws ExecutionException,
594
594
assertEquals (expectedNodesRoles , Set .of (getNodeRoles (client , 0 ), getNodeRoles (client , 1 )));
595
595
}
596
596
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
+
597
620
public void testClusterStatsWithNodeMetricsFilter () {
598
621
internalCluster ().startNode ();
599
622
ensureGreen ();
@@ -898,7 +921,7 @@ private Map<String, Integer> getExpectedCounts(
898
921
expectedCounts .put (DiscoveryNodeRole .INGEST_ROLE .roleName (), ingestRoleCount );
899
922
expectedCounts .put (DiscoveryNodeRole .REMOTE_CLUSTER_CLIENT_ROLE .roleName (), remoteClusterClientRoleCount );
900
923
expectedCounts .put (DiscoveryNodeRole .WARM_ROLE .roleName (), warmRoleCount );
901
- expectedCounts .put (DiscoveryNodeRole .SEARCH_ROLE .roleName (), warmRoleCount );
924
+ expectedCounts .put (DiscoveryNodeRole .SEARCH_ROLE .roleName (), searchRoleCount );
902
925
expectedCounts .put (ClusterStatsNodes .Counts .COORDINATING_ONLY , coordinatingOnlyCount );
903
926
return expectedCounts ;
904
927
}
0 commit comments