[DOCS] Re-enable code snippet testing in close anomaly detection job API (#48259) (#48585)

This commit is contained in:
Lisa Cawley 2019-10-28 08:42:09 -07:00 committed by GitHub
parent 1ba57dbe08
commit 13ce179706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 7 deletions

View File

@ -972,7 +972,6 @@ buildRestTests.setups['server_metrics_index'] = '''
number_of_shards: 1 number_of_shards: 1
number_of_replicas: 0 number_of_replicas: 0
mappings: mappings:
metric:
properties: properties:
timestamp: timestamp:
type: date type: date
@ -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'] + ''' buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server_metrics_job'] + '''
- do: - do:
ml.put_datafeed: ml.put_datafeed:
@ -1049,11 +1071,28 @@ buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server
"indexes":"server-metrics" "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'] + ''' buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + '''
- do: - do:
ml.open_job: ml.open_job:
job_id: "total-requests" 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'] + ''' buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + '''
- do: - do:
ml.start_datafeed: ml.start_datafeed:

View File

@ -102,7 +102,7 @@ The following example closes the `total-requests` job:
-------------------------------------------------- --------------------------------------------------
POST _ml/anomaly_detectors/total-requests/_close 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: When the job is closed, you receive the following results: