Add proper descriptions to reindex, update-by-query and delete-by-query tasks.
Related to #21768
This commit is contained in:
parent
bb9317253a
commit
c391b3fff6
|
@ -446,4 +446,8 @@ public abstract class AbstractBulkByScrollRequest<Self extends AbstractBulkByScr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.index.shard.IndexingOperationListener;
|
||||||
import org.elasticsearch.ingest.IngestTestPlugin;
|
import org.elasticsearch.ingest.IngestTestPlugin;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.tasks.TaskInfo;
|
import org.elasticsearch.tasks.TaskInfo;
|
||||||
|
import org.hamcrest.Matcher;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -77,7 +78,8 @@ public class CancelTests extends ReindexTestCase {
|
||||||
/**
|
/**
|
||||||
* Executes the cancellation test
|
* Executes the cancellation test
|
||||||
*/
|
*/
|
||||||
private void testCancel(String action, AbstractBulkByScrollRequestBuilder<?, ?> builder, CancelAssertion assertion) throws Exception {
|
private void testCancel(String action, AbstractBulkByScrollRequestBuilder<?, ?> builder, CancelAssertion assertion,
|
||||||
|
Matcher<String> taskDescriptionMatcher) throws Exception {
|
||||||
createIndex(INDEX);
|
createIndex(INDEX);
|
||||||
|
|
||||||
// Total number of documents created for this test (~10 per primary shard per shard)
|
// Total number of documents created for this test (~10 per primary shard per shard)
|
||||||
|
@ -112,6 +114,9 @@ public class CancelTests extends ReindexTestCase {
|
||||||
BulkByScrollTask.Status status = (BulkByScrollTask.Status) mainTask.getStatus();
|
BulkByScrollTask.Status status = (BulkByScrollTask.Status) mainTask.getStatus();
|
||||||
assertNull(status.getReasonCancelled());
|
assertNull(status.getReasonCancelled());
|
||||||
|
|
||||||
|
// Description shouldn't be empty
|
||||||
|
assertThat(mainTask.getDescription(), taskDescriptionMatcher);
|
||||||
|
|
||||||
// Cancel the request while the reindex action is blocked by the indexing operation listeners.
|
// Cancel the request while the reindex action is blocked by the indexing operation listeners.
|
||||||
// This will prevent further requests from being sent.
|
// This will prevent further requests from being sent.
|
||||||
ListTasksResponse cancelTasksResponse = client().admin().cluster().prepareCancelTasks().setTaskId(mainTask.getTaskId()).get();
|
ListTasksResponse cancelTasksResponse = client().admin().cluster().prepareCancelTasks().setTaskId(mainTask.getTaskId()).get();
|
||||||
|
@ -185,7 +190,7 @@ public class CancelTests extends ReindexTestCase {
|
||||||
|
|
||||||
refresh("dest");
|
refresh("dest");
|
||||||
assertHitCount(client().prepareSearch("dest").setTypes(TYPE).setSize(0).get(), modified);
|
assertHitCount(client().prepareSearch("dest").setTypes(TYPE).setSize(0).get(), modified);
|
||||||
});
|
}, equalTo("reindex from [" + INDEX + "] to [dest][" + TYPE + "]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateByQueryCancel() throws Exception {
|
public void testUpdateByQueryCancel() throws Exception {
|
||||||
|
@ -200,7 +205,7 @@ public class CancelTests extends ReindexTestCase {
|
||||||
testCancel(UpdateByQueryAction.NAME, updateByQuery().setPipeline("set-processed").source(INDEX), (response, total, modified) -> {
|
testCancel(UpdateByQueryAction.NAME, updateByQuery().setPipeline("set-processed").source(INDEX), (response, total, modified) -> {
|
||||||
assertThat(response, matcher().updated(modified).reasonCancelled(equalTo("by user request")));
|
assertThat(response, matcher().updated(modified).reasonCancelled(equalTo("by user request")));
|
||||||
assertHitCount(client().prepareSearch(INDEX).setSize(0).setQuery(termQuery("processed", true)).get(), modified);
|
assertHitCount(client().prepareSearch(INDEX).setSize(0).setQuery(termQuery("processed", true)).get(), modified);
|
||||||
});
|
}, equalTo("update-by-query [" + INDEX + "]"));
|
||||||
|
|
||||||
assertAcked(client().admin().cluster().deletePipeline(new DeletePipelineRequest("set-processed")).get());
|
assertAcked(client().admin().cluster().deletePipeline(new DeletePipelineRequest("set-processed")).get());
|
||||||
}
|
}
|
||||||
|
@ -209,7 +214,7 @@ public class CancelTests extends ReindexTestCase {
|
||||||
testCancel(DeleteByQueryAction.NAME, deleteByQuery().source(INDEX), (response, total, modified) -> {
|
testCancel(DeleteByQueryAction.NAME, deleteByQuery().source(INDEX), (response, total, modified) -> {
|
||||||
assertThat(response, matcher().deleted(modified).reasonCancelled(equalTo("by user request")));
|
assertThat(response, matcher().deleted(modified).reasonCancelled(equalTo("by user request")));
|
||||||
assertHitCount(client().prepareSearch(INDEX).setSize(0).get(), total - modified);
|
assertHitCount(client().prepareSearch(INDEX).setSize(0).get(), total - modified);
|
||||||
});
|
}, equalTo("delete-by-query [" + INDEX + "]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReindexCancelWithWorkers() throws Exception {
|
public void testReindexCancelWithWorkers() throws Exception {
|
||||||
|
@ -218,7 +223,7 @@ public class CancelTests extends ReindexTestCase {
|
||||||
|
|
||||||
refresh("dest");
|
refresh("dest");
|
||||||
assertHitCount(client().prepareSearch("dest").setTypes(TYPE).setSize(0).get(), modified);
|
assertHitCount(client().prepareSearch("dest").setTypes(TYPE).setSize(0).get(), modified);
|
||||||
});
|
}, equalTo("reindex from [" + INDEX + "] to [dest][" + TYPE + "]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateByQueryCancelWithWorkers() throws Exception {
|
public void testUpdateByQueryCancelWithWorkers() throws Exception {
|
||||||
|
@ -234,7 +239,7 @@ public class CancelTests extends ReindexTestCase {
|
||||||
(response, total, modified) -> {
|
(response, total, modified) -> {
|
||||||
assertThat(response, matcher().updated(modified).reasonCancelled(equalTo("by user request")).slices(hasSize(5)));
|
assertThat(response, matcher().updated(modified).reasonCancelled(equalTo("by user request")).slices(hasSize(5)));
|
||||||
assertHitCount(client().prepareSearch(INDEX).setSize(0).setQuery(termQuery("processed", true)).get(), modified);
|
assertHitCount(client().prepareSearch(INDEX).setSize(0).setQuery(termQuery("processed", true)).get(), modified);
|
||||||
});
|
}, equalTo("update-by-query [" + INDEX + "]"));
|
||||||
|
|
||||||
assertAcked(client().admin().cluster().deletePipeline(new DeletePipelineRequest("set-processed")).get());
|
assertAcked(client().admin().cluster().deletePipeline(new DeletePipelineRequest("set-processed")).get());
|
||||||
}
|
}
|
||||||
|
@ -243,7 +248,7 @@ public class CancelTests extends ReindexTestCase {
|
||||||
testCancel(DeleteByQueryAction.NAME, deleteByQuery().source(INDEX).setSlices(5), (response, total, modified) -> {
|
testCancel(DeleteByQueryAction.NAME, deleteByQuery().source(INDEX).setSlices(5), (response, total, modified) -> {
|
||||||
assertThat(response, matcher().deleted(modified).reasonCancelled(equalTo("by user request")).slices(hasSize(5)));
|
assertThat(response, matcher().deleted(modified).reasonCancelled(equalTo("by user request")).slices(hasSize(5)));
|
||||||
assertHitCount(client().prepareSearch(INDEX).setSize(0).get(), total - modified);
|
assertHitCount(client().prepareSearch(INDEX).setSize(0).get(), total - modified);
|
||||||
});
|
}, equalTo("delete-by-query [" + INDEX + "]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue