[TEST] rename AsyncSearchActionTests to IT and move it out of unit tests (#54520)

`AsyncSearchActionTests` currently fails quite often. That is since the introduction of `RestSubmitAsyncSearchActionTests` which indirectly manipulates the channels being tracked in `RestCancellableNodeClient`. There are channels left in the map after `RestSubmitAsyncSearchActionTests`  is run, and later `AsyncSearchActionTests` checks that there are no channels in the map which makes each test method fail. This is particularily hard to reproduce as the order in which tests are run appears to be platform dependent.

The test cluster assertion that there are no channels in the map only makes sense in the context of internal cluster tests, while there may be collisions with unit tests that register http channels as part of their testing.

This can be solved by renaming `AsyncSearchActionTests` to `AsyncSearchActionIT`. This way it won't be run as part of unit tests but rather within another JVM where the number of channels is `0` and such assumption holds, because there are no expected manual manipulation of the channels.

Relates to #54180
This commit is contained in:
Luca Cavanna 2020-04-01 11:21:42 +02:00
parent 74eeecf91b
commit d75571ff0f
3 changed files with 18 additions and 7 deletions

View File

@ -18,8 +18,6 @@ archivesBaseName = 'x-pack-async-search'
compileJava.options.compilerArgs << "-Xlint:-rawtypes" compileJava.options.compilerArgs << "-Xlint:-rawtypes"
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes" compileTestJava.options.compilerArgs << "-Xlint:-rawtypes"
integTest.enabled = false
// add all sub-projects of the qa sub-project // add all sub-projects of the qa sub-project
gradle.projectsEvaluated { gradle.projectsEvaluated {
project.subprojects project.subprojects
@ -40,3 +38,16 @@ dependencies {
dependencyLicenses { dependencyLicenses {
ignoreSha 'x-pack-core' ignoreSha 'x-pack-core'
} }
integTest.enabled = false
// Instead we create a separate task to run the
// tests based on ESIntegTestCase
task internalClusterTest(type: Test) {
description = 'Java fantasy integration tests'
mustRunAfter test
include '**/*IT.class'
}
check.dependsOn internalClusterTest

View File

@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.lessThanOrEqualTo;
// TODO: add tests for keepAlive and expiration // TODO: add tests for keepAlive and expiration
public class AsyncSearchActionTests extends AsyncSearchIntegTestCase { public class AsyncSearchActionIT extends AsyncSearchIntegTestCase {
private String indexName; private String indexName;
private int numShards; private int numShards;

View File

@ -72,10 +72,10 @@ public class RestSubmitAsyncSearchActionTests extends ESTestCase {
dispatchRequest(submitAsyncRestRequest); dispatchRequest(submitAsyncRestRequest);
SubmitAsyncSearchRequest submitRequest = (SubmitAsyncSearchRequest) lastCapturedRequest; SubmitAsyncSearchRequest submitRequest = (SubmitAsyncSearchRequest) lastCapturedRequest;
assertEquals(TimeValue.timeValueSeconds(1), submitRequest.getWaitForCompletionTimeout()); assertEquals(TimeValue.timeValueSeconds(1), submitRequest.getWaitForCompletionTimeout());
assertEquals(false, submitRequest.isKeepOnCompletion()); assertFalse(submitRequest.isKeepOnCompletion());
assertEquals(TimeValue.timeValueDays(5), submitRequest.getKeepAlive()); assertEquals(TimeValue.timeValueDays(5), submitRequest.getKeepAlive());
// check parameters we implicitly set in the SubmitAsyncSearchRequest ctor // check parameters we implicitly set in the SubmitAsyncSearchRequest ctor
assertEquals(false, submitRequest.getSearchRequest().isCcsMinimizeRoundtrips()); assertFalse(submitRequest.getSearchRequest().isCcsMinimizeRoundtrips());
assertEquals(5, submitRequest.getSearchRequest().getBatchedReduceSize()); assertEquals(5, submitRequest.getSearchRequest().getBatchedReduceSize());
assertEquals(true, submitRequest.getSearchRequest().requestCache()); assertEquals(true, submitRequest.getSearchRequest().requestCache());
assertEquals(1, submitRequest.getSearchRequest().getPreFilterShardSize().intValue()); assertEquals(1, submitRequest.getSearchRequest().getPreFilterShardSize().intValue());
@ -92,8 +92,8 @@ public class RestSubmitAsyncSearchActionTests extends ESTestCase {
boolean requestCache = randomBoolean(); boolean requestCache = randomBoolean();
doTestParameter("request_cache", Boolean.toString(requestCache), requestCache, doTestParameter("request_cache", Boolean.toString(requestCache), requestCache,
r -> r.getSearchRequest().requestCache()); r -> r.getSearchRequest().requestCache());
Integer batchReduceSize = randomIntBetween(2, 50); int batchedReduceSize = randomIntBetween(2, 50);
doTestParameter("batched_reduce_size", Integer.toString(batchReduceSize), batchReduceSize, doTestParameter("batched_reduce_size", Integer.toString(batchedReduceSize), batchedReduceSize,
r -> r.getSearchRequest().getBatchedReduceSize()); r -> r.getSearchRequest().getBatchedReduceSize());
} }