Skip to content

Commit 0353a8c

Browse files
committed
[DOCS] Adds test for ML preview API
1 parent 32394ce commit 0353a8c

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

x-pack/docs/build.gradle

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ buildRestTests.expectedUnconvertedCandidates = [
5656
'en/rest-api/ml/get-influencer.asciidoc',
5757
'en/rest-api/ml/get-snapshot.asciidoc',
5858
'en/rest-api/ml/post-data.asciidoc',
59-
'en/rest-api/ml/preview-datafeed.asciidoc',
6059
'en/rest-api/ml/revert-snapshot.asciidoc',
6160
'en/rest-api/ml/update-snapshot.asciidoc',
6261
'en/rest-api/watcher/stats.asciidoc',
@@ -296,7 +295,9 @@ setups['farequote_index'] = '''
296295
responsetime:
297296
type: float
298297
airline:
299-
type: keyword
298+
type: keyword
299+
doc_count:
300+
type: integer
300301
'''
301302
setups['farequote_data'] = setups['farequote_index'] + '''
302303
- do:
@@ -306,11 +307,11 @@ setups['farequote_data'] = setups['farequote_index'] + '''
306307
refresh: true
307308
body: |
308309
{"index": {"_id":"1"}}
309-
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000"}
310+
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": "5"}
310311
{"index": {"_id":"2"}}
311-
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000"}
312+
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": "23"}
312313
{"index": {"_id":"3"}}
313-
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000"}
314+
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": "42"}
314315
'''
315316
setups['farequote_job'] = setups['farequote_data'] + '''
316317
- do:
@@ -332,6 +333,16 @@ setups['farequote_job'] = setups['farequote_data'] + '''
332333
}
333334
}
334335
'''
336+
setups['farequote_datafeed'] = setups['farequote_job'] + '''
337+
- do:
338+
xpack.ml.put_datafeed:
339+
datafeed_id: "datafeed-farequote"
340+
body: >
341+
{
342+
"job_id":"farequote",
343+
"indexes":"farequote"
344+
}
345+
'''
335346
setups['server_metrics_index'] = '''
336347
- do:
337348
indices.create:

x-pack/docs/en/rest-api/ml/forecast.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ POST _xpack/ml/anomaly_detectors/total-requests/_forecast
6262
}
6363
--------------------------------------------------
6464
// CONSOLE
65-
// TEST[setup:server_metrics_openjob]
65+
// TEST[skip:requires delay]
6666

6767
When the forecast is created, you receive the following results:
6868
[source,js]
@@ -72,7 +72,7 @@ When the forecast is created, you receive the following results:
7272
"forecast_id": "wkCWa2IB2lF8nSE_TzZo"
7373
}
7474
----
75-
// TESTRESPONSE[s/"forecast_id": "wkCWa2IB2lF8nSE_TzZo"/"forecast_id": $body.forecast_id/]
75+
// NOTCONSOLE
7676

7777
You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.
7878

x-pack/docs/en/rest-api/ml/preview-datafeed.asciidoc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ structure of the data that will be passed to the anomaly detection engine.
3131
You must have `monitor_ml`, `monitor`, `manage_ml`, or `manage` cluster
3232
privileges to use this API. For more information, see
3333
{xpack-ref}/security-privileges.html[Security Privileges].
34-
//<<privileges-list-cluster>>.
3534

3635

3736
==== Security Integration
@@ -54,27 +53,30 @@ The following example obtains a preview of the `datafeed-farequote` {dfeed}:
5453
GET _xpack/ml/datafeeds/datafeed-farequote/_preview
5554
--------------------------------------------------
5655
// CONSOLE
57-
// TEST[skip:todo]
56+
// TEST[setup:farequote_datafeed]
5857

5958
The data that is returned for this example is as follows:
6059
[source,js]
6160
----
6261
[
6362
{
64-
"@timestamp": 1454803200000,
65-
"airline": "AAL",
66-
"responsetime": 132.20460510253906
67-
},
68-
{
69-
"@timestamp": 1454803200000,
63+
"time": 1454803200000,
7064
"airline": "JZA",
65+
"doc_count": 5,
7166
"responsetime": 990.4628295898438
7267
},
7368
{
74-
"@timestamp": 1454803200000,
69+
"time": 1454803200000,
7570
"airline": "JBU",
71+
"doc_count": 23,
7672
"responsetime": 877.5927124023438
7773
},
78-
...
74+
{
75+
"time": 1454803200000,
76+
"airline": "KLM",
77+
"doc_count": 42,
78+
"responsetime": 1355.481201171875
79+
}
7980
]
8081
----
82+
// TESTRESPONSE

0 commit comments

Comments
 (0)