@@ -39,7 +39,7 @@ public Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
39
39
.build ();
40
40
}
41
41
42
- public void testNodeSelection () {
42
+ public void testNodeSelection () throws Exception {
43
43
// We grab a client directly to avoid using a randomizing client that might set a search preference.
44
44
Client client = internalCluster ().coordOnlyNodeClient ();
45
45
@@ -76,14 +76,16 @@ public void testNodeSelection() {
76
76
assertNotNull (nodeStats );
77
77
assertEquals (3 , nodeStats .getAdaptiveSelectionStats ().getComputedStats ().size ());
78
78
79
- assertResponse (client .prepareSearch ().setQuery (matchAllQuery ()), response -> {
80
- String selectedNodeId = response .getHits ().getAt (0 ).getShard ().getNodeId ();
81
- double selectedRank = nodeStats .getAdaptiveSelectionStats ().getRanks ().get (selectedNodeId );
79
+ assertBusy (() -> {
80
+ assertResponse (client .prepareSearch ().setQuery (matchAllQuery ()), response -> {
81
+ String selectedNodeId = response .getHits ().getAt (0 ).getShard ().getNodeId ();
82
+ double selectedRank = nodeStats .getAdaptiveSelectionStats ().getRanks ().get (selectedNodeId );
82
83
83
- for (Map .Entry <String , Double > entry : nodeStats .getAdaptiveSelectionStats ().getRanks ().entrySet ()) {
84
- double rank = entry .getValue ();
85
- assertThat (rank , greaterThanOrEqualTo (selectedRank ));
86
- }
84
+ for (Map .Entry <String , Double > entry : nodeStats .getAdaptiveSelectionStats ().getRanks ().entrySet ()) {
85
+ double rank = entry .getValue ();
86
+ assertThat (rank , greaterThanOrEqualTo (selectedRank ));
87
+ }
88
+ });
87
89
});
88
90
}
89
91
}
0 commit comments