Class CancellableActionTestPlugin

java.lang.Object
org.elasticsearch.plugins.Plugin
org.elasticsearch.action.support.CancellableActionTestPlugin
All Implemented Interfaces:
Closeable, AutoCloseable, ActionPlugin

public class CancellableActionTestPlugin extends Plugin implements ActionPlugin
Utility plugin that captures the invocation of an action on a node after the task has been registered with the TaskManager, cancels it (e.g. by closing the connection used for the original REST request), verifies that the corresponding task is cancelled, then lets the action execution proceed in order to verify that it fails with a TaskCancelledException. This allows to verify a few key aspects of the cancellability of tasks:
  • The task that the request creates is cancellable.
  • The REST handler propagates cancellation to the task it starts.
  • The action implementation checks for cancellation at least once.
However, note that this is implemented as an ActionFilter it blocks and cancels the action before it even starts executing on the local node, so it does not verify that the cancellation is processed promptly at all stages of the execution of the action, nor that cancellations are propagated correctly to subsidiary actions.