Skip to content

Commit 50c16f7

Browse files
Wait on async stats before asserting on statsResponse
Signed-off-by: Finn Carroll <[email protected]>
1 parent 259eaef commit 50c16f7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/java/org/opensearch/search/asynchronous/request/SubmitAsynchronousSearchRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SubmitAsynchronousSearchRequest extends ActionRequest {
4242
private TimeValue waitForCompletionTimeout = DEFAULT_WAIT_FOR_COMPLETION_TIMEOUT;
4343

4444
/**
45-
* Determines whether the resource resource should be kept on completion or failure (defaults to false).
45+
* Determines whether the resource should be kept on completion or failure (defaults to false).
4646
*/
4747
@Nullable
4848
private Boolean keepOnCompletion = DEFAULT_KEEP_ON_COMPLETION;

src/test/java/org/opensearch/search/asynchronous/integTests/AsynchronousSearchStatsIT.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,15 @@ public void testStatsAcrossNodes() throws InterruptedException, ExecutionExcepti
166166
TestThreadPool finalThreadPool = threadPool;
167167
threads.forEach(t -> finalThreadPool.generic().execute(t));
168168
latch.await();
169-
AsynchronousSearchStatsResponse statsResponse = client().execute(AsynchronousSearchStatsAction.INSTANCE,
170-
new AsynchronousSearchStatsRequest()).get();
169+
171170
AtomicLong actualNumSuccesses = new AtomicLong();
172171
AtomicLong actualNumFailures = new AtomicLong();
173172
AtomicLong actualNumPersisted = new AtomicLong();
173+
174+
AsynchronousSearchStatsResponse statsResponse = client().execute(AsynchronousSearchStatsAction.INSTANCE,
175+
new AsynchronousSearchStatsRequest()).get();
176+
waitForAsyncSearchTasksToComplete();
177+
174178
for (AsynchronousSearchStats node : statsResponse.getNodes()) {
175179
AsynchronousSearchCountStats asCountStats = node.getAsynchronousSearchCountStats();
176180
assertEquals(asCountStats.getRunningCount(), 0);
@@ -188,7 +192,6 @@ public void testStatsAcrossNodes() throws InterruptedException, ExecutionExcepti
188192
assertEquals(expectedNumPersisted.get(), actualNumPersisted.get());
189193
assertEquals(expectedNumFailures.get(), actualNumFailures.get());
190194
assertEquals(expectedNumSuccesses.get(), actualNumSuccesses.get());
191-
waitForAsyncSearchTasksToComplete();
192195
} finally {
193196
ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
194197
}

0 commit comments

Comments
 (0)