Skip to content

Commit

Permalink
Allowing {index}/_xpack/rollup/data to accept comma delimited list (#…
Browse files Browse the repository at this point in the history
…34115)

* Allowing `{index}/_xpack/rollup/data` to accept comma delimited list

* Address PR comments
  • Loading branch information
benwtrent authored Oct 2, 2018
1 parent f904c41 commit 10201e0
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
Expand All @@ -27,7 +28,8 @@ public RestGetRollupIndexCapsAction(Settings settings, RestController controller
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) {
String index = restRequest.param(INDEX.getPreferredName());
IndicesOptions options = IndicesOptions.fromRequest(restRequest, IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED);
GetRollupIndexCapsAction.Request request = new GetRollupIndexCapsAction.Request(new String[]{index}, options);
GetRollupIndexCapsAction.Request request =
new GetRollupIndexCapsAction.Request(Strings.splitStringByCommaToArray(index), options);
return channel -> client.execute(GetRollupIndexCapsAction.INSTANCE, request, new RestToXContentListener<>(channel));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,109 @@ setup:
- agg: "max"
- agg: "sum"

---
"Verify job caps by rollup index comma delimited list":

- skip:
version: " - 6.99.99"
reason: "comma delimited index support was fixed in 7.0"

- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
xpack.rollup.put_job:
id: foo2
body: >
{
"index_pattern": "foo2",
"rollup_index": "foo_rollup",
"cron": "*/30 * * * * ?",
"page_size" :10,
"groups" : {
"date_histogram": {
"field": "the_field",
"interval": "1h"
}
},
"metrics": [
{
"field": "value_field",
"metrics": ["min", "max", "sum"]
}
]
}
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
xpack.rollup.put_job:
id: foo3
body: >
{
"index_pattern": "foo3",
"rollup_index": "foo_rollup2",
"cron": "*/30 * * * * ?",
"page_size" :10,
"groups" : {
"date_histogram": {
"field": "the_field",
"interval": "1h"
}
},
"metrics": [
{
"field": "value_field",
"metrics": ["min", "max", "sum"]
}
]
}
- do:
xpack.rollup.get_rollup_index_caps:
index: "foo_rollup2,foo_rollup"

- match:
$body:
foo_rollup:
rollup_jobs:
- job_id: "foo"
rollup_index: "foo_rollup"
index_pattern: "foo"
fields:
the_field:
- agg: "date_histogram"
interval: "1h"
time_zone: "UTC"
value_field:
- agg: "min"
- agg: "max"
- agg: "sum"
- job_id: "foo2"
rollup_index: "foo_rollup"
index_pattern: "foo2"
fields:
the_field:
- agg: "date_histogram"
interval: "1h"
time_zone: "UTC"
value_field:
- agg: "min"
- agg: "max"
- agg: "sum"
foo_rollup2:
rollup_jobs:
- job_id: "foo3"
rollup_index: "foo_rollup2"
index_pattern: "foo3"
fields:
the_field:
- agg: "date_histogram"
interval: "1h"
time_zone: "UTC"
value_field:
- agg: "min"
- agg: "max"
- agg: "sum"

---
"Verify index pattern":

Expand Down

0 comments on commit 10201e0

Please sign in to comment.