From 13ce179706900a8ceef84992e66775e8502a467e Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Mon, 28 Oct 2019 08:42:09 -0700 Subject: [PATCH] [DOCS] Re-enable code snippet testing in close anomaly detection job API (#48259) (#48585) --- docs/build.gradle | 51 ++++++++++++++++--- .../anomaly-detection/apis/close-job.asciidoc | 2 +- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/docs/build.gradle b/docs/build.gradle index eac1490d5af..5b499b19af2 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -972,12 +972,11 @@ buildRestTests.setups['server_metrics_index'] = ''' number_of_shards: 1 number_of_replicas: 0 mappings: - metric: - properties: - timestamp: - type: date - total: - type: long + properties: + timestamp: + type: date + total: + type: long ''' buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_metrics_index'] + ''' - do: @@ -1039,6 +1038,29 @@ buildRestTests.setups['server_metrics_job'] = buildRestTests.setups['server_metr } } ''' +buildRestTests.setups['server_metrics_job-raw'] = buildRestTests.setups['server_metrics_data'] + ''' + - do: + raw: + method: PUT + path: _ml/anomaly_detectors/total-requests + body: > + { + "description" : "Total sum of requests", + "analysis_config" : { + "bucket_span":"10m", + "detectors" :[ + { + "detector_description": "Sum of total", + "function": "sum", + "field_name": "total" + } + ]}, + "data_description" : { + "time_field":"timestamp", + "time_format": "epoch_ms" + } + } +''' buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server_metrics_job'] + ''' - do: ml.put_datafeed: @@ -1049,11 +1071,28 @@ buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server "indexes":"server-metrics" } ''' +buildRestTests.setups['server_metrics_datafeed-raw'] = buildRestTests.setups['server_metrics_job-raw'] + ''' + - do: + raw: + method: PUT + path: _ml/datafeeds/datafeed-total-requests + body: > + { + "job_id":"total-requests", + "indexes":"server-metrics" + } +''' buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + ''' - do: ml.open_job: job_id: "total-requests" ''' +buildRestTests.setups['server_metrics_openjob-raw'] = buildRestTests.setups['server_metrics_datafeed-raw'] + ''' + - do: + raw: + method: POST + path: _ml/anomaly_detectors/total-requests/_open +''' buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + ''' - do: ml.start_datafeed: diff --git a/docs/reference/ml/anomaly-detection/apis/close-job.asciidoc b/docs/reference/ml/anomaly-detection/apis/close-job.asciidoc index 82375be0654..a6ec923911a 100644 --- a/docs/reference/ml/anomaly-detection/apis/close-job.asciidoc +++ b/docs/reference/ml/anomaly-detection/apis/close-job.asciidoc @@ -102,7 +102,7 @@ The following example closes the `total-requests` job: -------------------------------------------------- POST _ml/anomaly_detectors/total-requests/_close -------------------------------------------------- -// TEST[skip:setup:server_metrics_openjob] +// TEST[setup:server_metrics_openjob-raw] When the job is closed, you receive the following results: