Tests: Add addtional logging to SearchCancellationIT tests
This commit is contained in:
parent
f11a217546
commit
d731a330aa
|
@ -28,8 +28,11 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.search.SearchScrollAction;
|
import org.elasticsearch.action.search.SearchScrollAction;
|
||||||
import org.elasticsearch.action.support.WriteRequest;
|
import org.elasticsearch.action.support.WriteRequest;
|
||||||
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.plugins.PluginsService;
|
import org.elasticsearch.plugins.PluginsService;
|
||||||
import org.elasticsearch.plugins.ScriptPlugin;
|
import org.elasticsearch.plugins.ScriptPlugin;
|
||||||
|
@ -58,6 +61,9 @@ import static org.hamcrest.Matchers.hasSize;
|
||||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
|
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
|
||||||
public class SearchCancellationIT extends ESIntegTestCase {
|
public class SearchCancellationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
|
private static final ToXContent.Params FORMAT_PARAMS = new ToXContent.MapParams(Collections.singletonMap("pretty", "false"));
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||||
return Collections.singleton(ScriptedBlockPlugin.class);
|
return Collections.singleton(ScriptedBlockPlugin.class);
|
||||||
|
@ -65,15 +71,17 @@ public class SearchCancellationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
return Settings.builder().put(SearchService.LOW_LEVEL_CANCELLATION_SETTING.getKey(), randomBoolean()).build();
|
boolean lowLevelCancellation = randomBoolean();
|
||||||
|
logger.info("Using lowLevelCancellation: {}", lowLevelCancellation);
|
||||||
|
return Settings.builder().put(SearchService.LOW_LEVEL_CANCELLATION_SETTING.getKey(), lowLevelCancellation).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void indexTestData() {
|
private void indexTestData() {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
// Make sure we have a few segments
|
// Make sure we have a few segments
|
||||||
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
for(int j=0; j<10; j++) {
|
for (int j = 0; j < 20; j++) {
|
||||||
bulkRequestBuilder.add(client().prepareIndex("test", "type", Integer.toString(i*10 + j)).setSource("field", "value"));
|
bulkRequestBuilder.add(client().prepareIndex("test", "type", Integer.toString(i * 5 + j)).setSource("field", "value"));
|
||||||
}
|
}
|
||||||
assertNoFailures(bulkRequestBuilder.get());
|
assertNoFailures(bulkRequestBuilder.get());
|
||||||
}
|
}
|
||||||
|
@ -145,6 +153,7 @@ public class SearchCancellationIT extends ESIntegTestCase {
|
||||||
awaitForBlock(plugins);
|
awaitForBlock(plugins);
|
||||||
cancelSearch(SearchAction.NAME);
|
cancelSearch(SearchAction.NAME);
|
||||||
disableBlocks(plugins);
|
disableBlocks(plugins);
|
||||||
|
logger.info("Segments {}", XContentHelper.toString(client().admin().indices().prepareSegments("test").get(), FORMAT_PARAMS));
|
||||||
ensureSearchWasCancelled(searchResponse);
|
ensureSearchWasCancelled(searchResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +171,7 @@ public class SearchCancellationIT extends ESIntegTestCase {
|
||||||
awaitForBlock(plugins);
|
awaitForBlock(plugins);
|
||||||
cancelSearch(SearchAction.NAME);
|
cancelSearch(SearchAction.NAME);
|
||||||
disableBlocks(plugins);
|
disableBlocks(plugins);
|
||||||
|
logger.info("Segments {}", XContentHelper.toString(client().admin().indices().prepareSegments("test").get(), FORMAT_PARAMS));
|
||||||
ensureSearchWasCancelled(searchResponse);
|
ensureSearchWasCancelled(searchResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +232,7 @@ public class SearchCancellationIT extends ESIntegTestCase {
|
||||||
disableBlocks(plugins);
|
disableBlocks(plugins);
|
||||||
|
|
||||||
SearchResponse response = ensureSearchWasCancelled(scrollResponse);
|
SearchResponse response = ensureSearchWasCancelled(scrollResponse);
|
||||||
if (response != null){
|
if (response != null) {
|
||||||
// The response didn't fail completely - update scroll id
|
// The response didn't fail completely - update scroll id
|
||||||
scrollId = response.getScrollId();
|
scrollId = response.getScrollId();
|
||||||
}
|
}
|
||||||
|
@ -285,6 +295,7 @@ public class SearchCancellationIT extends ESIntegTestCase {
|
||||||
public class NativeTestScriptedBlock extends AbstractSearchScript {
|
public class NativeTestScriptedBlock extends AbstractSearchScript {
|
||||||
@Override
|
@Override
|
||||||
public Object run() {
|
public Object run() {
|
||||||
|
Loggers.getLogger(SearchCancellationIT.class).info("Blocking on the document {}", doc().get("_uid"));
|
||||||
hits.incrementAndGet();
|
hits.incrementAndGet();
|
||||||
try {
|
try {
|
||||||
awaitBusy(() -> shouldBlock.get() == false);
|
awaitBusy(() -> shouldBlock.get() == false);
|
||||||
|
|
Loading…
Reference in New Issue