Skip to content

Commit

Permalink
Cleanup SearchAsyncActionTests tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Mar 11, 2024
1 parent 899bd4b commit 531cdc9
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public void testSkipSearchShards() throws InterruptedException {
lookup.put(replicaNode.getId(), new MockConnection(replicaNode));
Map<String, AliasFilter> aliasFilters = Collections.singletonMap("_na_", new AliasFilter(null, Strings.EMPTY_ARRAY));
AtomicInteger numRequests = new AtomicInteger(0);
final SearchRequestOperationsListener searchRequestOperationsListener = new SearchRequestOperationsListener.CompositeListener(
List.of(assertingListener),
LogManager.getLogger()
);
AbstractSearchAsyncAction<TestSearchPhaseResult> asyncAction = new AbstractSearchAsyncAction<TestSearchPhaseResult>(
"test",
logger,
Expand All @@ -158,10 +162,7 @@ public void testSkipSearchShards() throws InterruptedException {
new ArraySearchPhaseResults<>(shardsIter.size()),
request.getMaxConcurrentShardRequests(),
SearchResponse.Clusters.EMPTY,
new SearchRequestContext(
new SearchRequestOperationsListener.CompositeListener(List.of(assertingListener), LogManager.getLogger()),
request
),
new SearchRequestContext(searchRequestOperationsListener, request),
NoopTracer.INSTANCE
) {

Expand Down Expand Up @@ -193,7 +194,7 @@ protected SearchPhase getNextPhase(SearchPhaseResults<TestSearchPhaseResult> res
@Override
public void run() {
assertTrue(searchPhaseDidRun.compareAndSet(false, true));
assertingListener.onPhaseEnd(new MockSearchPhaseContext(1, request, this), null);
searchRequestOperationsListener.onPhaseEnd(new MockSearchPhaseContext(1, request, this), null);
}
};
}
Expand Down Expand Up @@ -261,6 +262,10 @@ public void testLimitConcurrentShardRequests() throws InterruptedException {
Map<String, AliasFilter> aliasFilters = Collections.singletonMap("_na_", new AliasFilter(null, Strings.EMPTY_ARRAY));
CountDownLatch awaitInitialRequests = new CountDownLatch(1);
AtomicInteger numRequests = new AtomicInteger(0);
final SearchRequestOperationsListener searchRequestOperationsListener = new SearchRequestOperationsListener.CompositeListener(
List.of(assertingListener),
LogManager.getLogger()
);
AbstractSearchAsyncAction<TestSearchPhaseResult> asyncAction = new AbstractSearchAsyncAction<TestSearchPhaseResult>(
"test",
logger,
Expand All @@ -282,10 +287,7 @@ public void testLimitConcurrentShardRequests() throws InterruptedException {
new ArraySearchPhaseResults<>(shardsIter.size()),
request.getMaxConcurrentShardRequests(),
SearchResponse.Clusters.EMPTY,
new SearchRequestContext(
new SearchRequestOperationsListener.CompositeListener(List.of(assertingListener), LogManager.getLogger()),
request
),
new SearchRequestContext(searchRequestOperationsListener, request),
NoopTracer.INSTANCE
) {

Expand Down Expand Up @@ -324,7 +326,7 @@ protected SearchPhase getNextPhase(SearchPhaseResults<TestSearchPhaseResult> res
return new SearchPhase("test") {
@Override
public void run() {
assertingListener.onPhaseEnd(new MockSearchPhaseContext(1, request, this), null);
searchRequestOperationsListener.onPhaseEnd(new MockSearchPhaseContext(1, request, this), null);
assertTrue(searchPhaseDidRun.compareAndSet(false, true));
}
};
Expand Down Expand Up @@ -630,6 +632,10 @@ public void testAllowPartialResults() throws InterruptedException {
Map<String, AliasFilter> aliasFilters = Collections.singletonMap("_na_", new AliasFilter(null, Strings.EMPTY_ARRAY));
AtomicInteger numRequests = new AtomicInteger(0);
AtomicInteger numFailReplicas = new AtomicInteger(0);
final SearchRequestOperationsListener searchRequestOperationsListener = new SearchRequestOperationsListener.CompositeListener(
List.of(assertingListener),
LogManager.getLogger()
);
AbstractSearchAsyncAction<TestSearchPhaseResult> asyncAction = new AbstractSearchAsyncAction<TestSearchPhaseResult>(
"test",
logger,
Expand All @@ -651,10 +657,7 @@ public void testAllowPartialResults() throws InterruptedException {
new ArraySearchPhaseResults<>(shardsIter.size()),
request.getMaxConcurrentShardRequests(),
SearchResponse.Clusters.EMPTY,
new SearchRequestContext(
new SearchRequestOperationsListener.CompositeListener(List.of(assertingListener), LogManager.getLogger()),
request
),
new SearchRequestContext(searchRequestOperationsListener, request),
NoopTracer.INSTANCE
) {
@Override
Expand Down Expand Up @@ -688,7 +691,7 @@ protected SearchPhase getNextPhase(SearchPhaseResults<TestSearchPhaseResult> res
@Override
public void run() {
assertTrue(searchPhaseDidRun.compareAndSet(false, true));
assertingListener.onPhaseEnd(new MockSearchPhaseContext(1, request, this), null);
searchRequestOperationsListener.onPhaseEnd(new MockSearchPhaseContext(1, request, this), null);
}
};
}
Expand Down

0 comments on commit 531cdc9

Please sign in to comment.