From 8c7fa4ea67ecd2a400cd0e68efdc16304ffc27a5 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Tue, 29 Sep 2020 14:47:10 -0400 Subject: [PATCH 1/3] Add support for x_opaque_id to _cat/tasks Adds an optional column with support for x_opaque_id to _cat/tasks API. Closes #61118 --- .../rest-api-spec/test/cat.tasks/10_basic.yml | 15 +++++++++++++++ .../rest/action/cat/RestTasksAction.java | 3 +++ 2 files changed, 18 insertions(+) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml index c7a38bfb44adc..7c425a487fb3f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml @@ -17,3 +17,18 @@ $body: | / # action task_id parent_task_id type start_time timestamp running_time ip node description ^( \S+\s+ \S+\:\d+\s+ (?:\-|\S+\:\d+)\s+ \S+\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \S+\s+ \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s+ \S+\s+ .*\n)+$/ + +--- +"Test cat tasks output with X-Opaque-Id": + - skip: + features: headers + + - do: + headers: { "X-Opaque-Id": "TestID" } + cat.tasks: + h: ["action", "x_opaque_id"] + + - match: + $body: | + / # action x_opaque_id + ^.*cluster\:monitor/tasks/lists\s+TestID\n.*$/ diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java index a41571f32be6b..b872bb7fa9630 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java @@ -31,6 +31,7 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.action.RestResponseListener; +import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskInfo; import java.time.Instant; @@ -116,6 +117,7 @@ protected Table getTableWithHeader(final RestRequest request) { table.addCell("port", "default:false;alias:po;desc:bound transport port"); table.addCell("node", "default:true;alias:n;desc:node name"); table.addCell("version", "default:false;alias:v;desc:es version"); + table.addCell("x_opaque_id", "default:false;alias:x;desc:X-Opaque-ID header"); // Task detailed info if (detailed) { @@ -152,6 +154,7 @@ private void buildRow(Table table, boolean fullId, boolean detailed, DiscoveryNo table.addCell(node.getAddress().address().getPort()); table.addCell(node == null ? "-" : node.getName()); table.addCell(node == null ? "-" : node.getVersion().toString()); + table.addCell(taskInfo.getHeaders().getOrDefault(Task.X_OPAQUE_ID, "-")); if (detailed) { table.addCell(taskInfo.getDescription()); From 71d2f51794824415b3968ab852fe8cf390db265e Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Tue, 29 Sep 2020 15:22:42 -0400 Subject: [PATCH 2/3] Suppress tests for older versions --- .../resources/rest-api-spec/test/cat.tasks/10_basic.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml index 7c425a487fb3f..0d0ce0c1ede5c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml @@ -21,6 +21,8 @@ --- "Test cat tasks output with X-Opaque-Id": - skip: + version: " - 7.99.99" + reason: support for opaque_id was added in 8.0.0 features: headers - do: @@ -29,6 +31,4 @@ h: ["action", "x_opaque_id"] - match: - $body: | - / # action x_opaque_id - ^.*cluster\:monitor/tasks/lists\s+TestID\n.*$/ + $body: / ^.*TestID\n.*$/ From a9af86e156f63841af1e38b388f3112895c6c79b Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Tue, 29 Sep 2020 17:05:14 -0400 Subject: [PATCH 3/3] Simplify the test to satisfy smoke tests --- .../main/resources/rest-api-spec/test/cat.tasks/10_basic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml index 0d0ce0c1ede5c..a4d4ca84049cf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.tasks/10_basic.yml @@ -31,4 +31,4 @@ h: ["action", "x_opaque_id"] - match: - $body: / ^.*TestID\n.*$/ + $body: /TestID/