@@ -90,7 +90,7 @@ private void waitForNodes(int numNodes) {
90
90
public void testNodeCounts () {
91
91
int total = 1 ;
92
92
internalCluster ().startNode ();
93
- Map <String , Integer > expectedCounts = getExpectedCounts (1 , 1 , 1 , 1 , 1 , 0 , 0 );
93
+ Map <String , Integer > expectedCounts = getExpectedCounts (1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 );
94
94
int numNodes = randomIntBetween (1 , 5 );
95
95
96
96
ClusterStatsResponse response = client ().admin ()
@@ -159,7 +159,7 @@ public void testNodeCountsWithDeprecatedMasterRole() throws ExecutionException,
159
159
internalCluster ().startNode (settings );
160
160
waitForNodes (total );
161
161
162
- Map <String , Integer > expectedCounts = getExpectedCounts (0 , 1 , 1 , 0 , 0 , 0 , 0 );
162
+ Map <String , Integer > expectedCounts = getExpectedCounts (0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 );
163
163
164
164
Client client = client ();
165
165
ClusterStatsResponse response = client .admin ()
@@ -484,7 +484,7 @@ public void testNodeRolesWithMasterLegacySettings() throws ExecutionException, I
484
484
internalCluster ().startNodes (legacyMasterSettings );
485
485
waitForNodes (total );
486
486
487
- Map <String , Integer > expectedCounts = getExpectedCounts (0 , 1 , 1 , 0 , 1 , 0 , 0 );
487
+ Map <String , Integer > expectedCounts = getExpectedCounts (0 , 1 , 1 , 0 , 1 , 0 , 0 , 0 );
488
488
489
489
Client client = client ();
490
490
ClusterStatsResponse clusterStatsResponse = client .admin ()
@@ -518,7 +518,7 @@ public void testNodeRolesWithClusterManagerRole() throws ExecutionException, Int
518
518
internalCluster ().startNodes (clusterManagerNodeRoleSettings );
519
519
waitForNodes (total );
520
520
521
- Map <String , Integer > expectedCounts = getExpectedCounts (0 , 1 , 1 , 0 , 1 , 0 , 0 );
521
+ Map <String , Integer > expectedCounts = getExpectedCounts (0 , 1 , 1 , 0 , 1 , 0 , 0 , 0 );
522
522
523
523
Client client = client ();
524
524
ClusterStatsResponse clusterStatsResponse = client .admin ()
@@ -546,7 +546,7 @@ public void testNodeRolesWithSeedDataNodeLegacySettings() throws ExecutionExcept
546
546
internalCluster ().startNodes (legacySeedDataNodeSettings );
547
547
waitForNodes (total );
548
548
549
- Map <String , Integer > expectedRoleCounts = getExpectedCounts (1 , 1 , 1 , 0 , 1 , 0 , 0 );
549
+ Map <String , Integer > expectedRoleCounts = getExpectedCounts (1 , 1 , 1 , 0 , 1 , 0 , 0 , 0 );
550
550
551
551
Client client = client ();
552
552
ClusterStatsResponse clusterStatsResponse = client .admin ()
@@ -577,7 +577,7 @@ public void testNodeRolesWithDataNodeLegacySettings() throws ExecutionException,
577
577
internalCluster ().startNodes (legacyDataNodeSettings );
578
578
waitForNodes (total );
579
579
580
- Map <String , Integer > expectedRoleCounts = getExpectedCounts (1 , 1 , 1 , 0 , 1 , 0 , 0 );
580
+ Map <String , Integer > expectedRoleCounts = getExpectedCounts (1 , 1 , 1 , 0 , 1 , 0 , 0 , 0 );
581
581
582
582
Client client = client ();
583
583
ClusterStatsResponse clusterStatsResponse = client .admin ()
@@ -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 ();
@@ -887,6 +910,7 @@ private Map<String, Integer> getExpectedCounts(
887
910
int clusterManagerRoleCount ,
888
911
int ingestRoleCount ,
889
912
int remoteClusterClientRoleCount ,
913
+ int warmRoleCount ,
890
914
int searchRoleCount ,
891
915
int coordinatingOnlyCount
892
916
) {
@@ -896,7 +920,8 @@ private Map<String, Integer> getExpectedCounts(
896
920
expectedCounts .put (DiscoveryNodeRole .CLUSTER_MANAGER_ROLE .roleName (), clusterManagerRoleCount );
897
921
expectedCounts .put (DiscoveryNodeRole .INGEST_ROLE .roleName (), ingestRoleCount );
898
922
expectedCounts .put (DiscoveryNodeRole .REMOTE_CLUSTER_CLIENT_ROLE .roleName (), remoteClusterClientRoleCount );
899
- expectedCounts .put (DiscoveryNodeRole .WARM_ROLE .roleName (), searchRoleCount );
923
+ expectedCounts .put (DiscoveryNodeRole .WARM_ROLE .roleName (), warmRoleCount );
924
+ expectedCounts .put (DiscoveryNodeRole .SEARCH_ROLE .roleName (), searchRoleCount );
900
925
expectedCounts .put (ClusterStatsNodes .Counts .COORDINATING_ONLY , coordinatingOnlyCount );
901
926
return expectedCounts ;
902
927
}
0 commit comments