forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_datafeed_stats.yml
215 lines (187 loc) · 5.78 KB
/
get_datafeed_stats.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
setup:
- skip:
features: headers
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.create:
index: index-1
body:
settings:
index:
number_of_replicas: 1
mappings:
type-1:
properties:
time:
type: date
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.create:
index: index-2
body:
settings:
index:
number_of_replicas: 1
mappings:
type-2:
properties:
time:
type: date
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
xpack.ml.put_job:
job_id: get-datafeed-stats-1
body: >
{
"job_id":"get-datafeed-stats-1",
"analysis_config" : {
"bucket_span": "1h",
"detectors" :[{"function":"count"}]
},
"analysis_limits" : {
"model_memory_limit": "10mb"
},
"data_description" : {
"format":"xcontent",
"time_field":"time",
"time_format":"epoch"
}
}
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
xpack.ml.put_job:
job_id: get-datafeed-stats-2
body: >
{
"job_id":"get-datafeed-stats-2",
"analysis_config" : {
"bucket_span": "1h",
"detectors" :[{"function":"count"}]
},
"analysis_limits" : {
"model_memory_limit": "10mb"
},
"data_description" : {
"time_field":"time"
}
}
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
xpack.ml.put_datafeed:
datafeed_id: datafeed-1
body: >
{
"job_id":"get-datafeed-stats-1",
"indexes":["index-1"],
"types":["type-1"]
}
- do:
headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
xpack.ml.put_datafeed:
datafeed_id: datafeed-2
body: >
{
"job_id":"get-datafeed-stats-2",
"indexes":["index-2"],
"types":["type-2"]
}
---
"Test get datafeed stats given missing datafeed_id":
- do:
catch: missing
xpack.ml.get_datafeed_stats:
datafeed_id: missing-datafeed
---
"Test get datafeed stats with expression that does not match and allow_no_datafeeds":
- do:
xpack.ml.get_datafeed_stats:
datafeed_id: "missing-*"
allow_no_datafeeds: true
- match: { count: 0 }
- match: { datafeeds: [] }
---
"Test get datafeed stats with expression that does not match and not allow_no_datafeeds":
- do:
catch: missing
xpack.ml.get_datafeed_stats:
datafeed_id: "missing-*"
allow_no_datafeeds: false
---
"Test get single datafeed stats":
- do:
xpack.ml.get_datafeed_stats:
datafeed_id: datafeed-1
- match: { datafeeds.0.datafeed_id: "datafeed-1"}
- match: { datafeeds.0.state: "stopped"}
- is_false: datafeeds.0.node
- do:
xpack.ml.get_datafeed_stats:
datafeed_id: datafeed-2
- match: { datafeeds.0.datafeed_id: "datafeed-2"}
- match: { datafeeds.0.state: "stopped"}
- is_false: datafeeds.0.node
---
"Test get stats for started datafeed":
- do:
xpack.ml.open_job:
job_id: get-datafeed-stats-1
- do:
xpack.ml.start_datafeed:
"datafeed_id": "datafeed-1"
"start": 0
- do:
xpack.ml.get_datafeed_stats:
datafeed_id: datafeed-1
- match: { datafeeds.0.datafeed_id: "datafeed-1"}
- match: { datafeeds.0.state: "started"}
- is_true: datafeeds.0.node.name
- is_true: datafeeds.0.node.transport_address
- match: { datafeeds.0.node.attributes.ml\.enabled: "true"}
---
"Test implicit get all datafeed stats given started datafeeds":
- do:
xpack.ml.open_job:
job_id: get-datafeed-stats-1
- do:
xpack.ml.start_datafeed:
"datafeed_id": "datafeed-1"
"start": 0
- do:
xpack.ml.open_job:
job_id: get-datafeed-stats-2
- do:
xpack.ml.start_datafeed:
"datafeed_id": "datafeed-2"
"start": 0
- do:
xpack.ml.get_datafeed_stats: {}
- match: { count: 2 }
- match: { datafeeds.0.datafeed_id: "datafeed-1"}
- match: { datafeeds.0.state: "started"}
- match: { datafeeds.1.datafeed_id: "datafeed-2"}
- match: { datafeeds.1.state: "started"}
---
"Test explicit get all datafeed stats given stopped datafeeds":
- do:
xpack.ml.get_datafeed_stats:
datafeed_id: _all
- match: { count: 2 }
- match: { datafeeds.0.datafeed_id: "datafeed-1"}
- match: { datafeeds.0.state: "stopped"}
- match: { datafeeds.1.datafeed_id: "datafeed-2"}
- match: { datafeeds.1.state: "stopped"}
---
"Test implicit get all datafeed stats given stopped datafeeds":
- do:
xpack.ml.get_datafeed_stats: {}
- match: { count: 2 }
- match: { datafeeds.0.datafeed_id: "datafeed-1"}
- match: { datafeeds.0.state: "stopped"}
- match: { datafeeds.1.datafeed_id: "datafeed-2"}
- match: { datafeeds.1.state: "stopped"}