@@ -39,7 +39,7 @@ public Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
3939 .build ();
4040 }
4141
42- public void testNodeSelection () {
42+ public void testNodeSelection () throws Exception {
4343 // We grab a client directly to avoid using a randomizing client that might set a search preference.
4444 Client client = internalCluster ().coordOnlyNodeClient ();
4545
@@ -76,14 +76,16 @@ public void testNodeSelection() {
7676 assertNotNull (nodeStats );
7777 assertEquals (3 , nodeStats .getAdaptiveSelectionStats ().getComputedStats ().size ());
7878
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 );
8283
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+ });
8789 });
8890 }
8991}
0 commit comments