Skip to content

Commit

Permalink
Wait on async stats before asserting on statsResponse (#617)
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll authored Sep 17, 2024
1 parent 259eaef commit a4cf835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SubmitAsynchronousSearchRequest extends ActionRequest {
private TimeValue waitForCompletionTimeout = DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT;

/**
* Determines whether the resource resource should be kept on completion or failure (defaults to false).
* Determines whether the resource should be kept on completion or failure (defaults to false).
*/
@Nullable
private Boolean keepOnCompletion = DEFAULT_KEEP_ON_COMPLETION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ public void testStatsAcrossNodes() throws InterruptedException, ExecutionExcepti
TestThreadPool finalThreadPool = threadPool;
threads.forEach(t -> finalThreadPool.generic().execute(t));
latch.await();
AsynchronousSearchStatsResponse statsResponse = client().execute(AsynchronousSearchStatsAction.INSTANCE,
new AsynchronousSearchStatsRequest()).get();

AtomicLong actualNumSuccesses = new AtomicLong();
AtomicLong actualNumFailures = new AtomicLong();
AtomicLong actualNumPersisted = new AtomicLong();

AsynchronousSearchStatsResponse statsResponse = client().execute(AsynchronousSearchStatsAction.INSTANCE,
new AsynchronousSearchStatsRequest()).get();
waitForAsyncSearchTasksToComplete();

for (AsynchronousSearchStats node : statsResponse.getNodes()) {
AsynchronousSearchCountStats asCountStats = node.getAsynchronousSearchCountStats();
assertEquals(asCountStats.getRunningCount(), 0);
Expand All @@ -188,7 +192,6 @@ public void testStatsAcrossNodes() throws InterruptedException, ExecutionExcepti
assertEquals(expectedNumPersisted.get(), actualNumPersisted.get());
assertEquals(expectedNumFailures.get(), actualNumFailures.get());
assertEquals(expectedNumSuccesses.get(), actualNumSuccesses.get());
waitForAsyncSearchTasksToComplete();
} finally {
ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
}
Expand Down

0 comments on commit a4cf835

Please sign in to comment.