@@ -166,11 +166,15 @@ public void testStatsAcrossNodes() throws InterruptedException, ExecutionExcepti
166
166
TestThreadPool finalThreadPool = threadPool ;
167
167
threads .forEach (t -> finalThreadPool .generic ().execute (t ));
168
168
latch .await ();
169
- AsynchronousSearchStatsResponse statsResponse = client ().execute (AsynchronousSearchStatsAction .INSTANCE ,
170
- new AsynchronousSearchStatsRequest ()).get ();
169
+
171
170
AtomicLong actualNumSuccesses = new AtomicLong ();
172
171
AtomicLong actualNumFailures = new AtomicLong ();
173
172
AtomicLong actualNumPersisted = new AtomicLong ();
173
+
174
+ AsynchronousSearchStatsResponse statsResponse = client ().execute (AsynchronousSearchStatsAction .INSTANCE ,
175
+ new AsynchronousSearchStatsRequest ()).get ();
176
+ waitForAsyncSearchTasksToComplete ();
177
+
174
178
for (AsynchronousSearchStats node : statsResponse .getNodes ()) {
175
179
AsynchronousSearchCountStats asCountStats = node .getAsynchronousSearchCountStats ();
176
180
assertEquals (asCountStats .getRunningCount (), 0 );
@@ -188,7 +192,6 @@ public void testStatsAcrossNodes() throws InterruptedException, ExecutionExcepti
188
192
assertEquals (expectedNumPersisted .get (), actualNumPersisted .get ());
189
193
assertEquals (expectedNumFailures .get (), actualNumFailures .get ());
190
194
assertEquals (expectedNumSuccesses .get (), actualNumSuccesses .get ());
191
- waitForAsyncSearchTasksToComplete ();
192
195
} finally {
193
196
ThreadPool .terminate (threadPool , 10 , TimeUnit .SECONDS );
194
197
}
0 commit comments