blob: 6cda3ee254e80b1cb284a8bd86d7f3c9abc3fbcb [file] [log] [blame]
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +01001#
2# Tests for gnocchi-threshold-alarm
3#
4# user_id : c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
5# project_id : 709f6ed6-bfb3-4649-b303-0019a7f6aef2
6# alarm name : gabbi-gnocchi-threshold-resource-alarm
7# resource_id : gabbi-mock-resource
8# archive policy : gabbiliveceph
9#
10
11defaults:
12 request_headers:
13 x-auth-token: $ENVIRON['ADMIN_TOKEN']
14
15tests:
16 #
17 # Setup gnocchi archive policy/resource type/resource/metrics
18 #
19
20 - name: SETUP. create archive policy gabbiliveceph
21 desc: create archve policy 'gabbiliveceph' for tests
22 POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/archive_policy
23 status: 201
24 request_headers:
25 content-type: application/json
26 data:
27 name: gabbiliveceph
28 back_window: 0
29 definition:
30 - granularity: 1 second
31 points: 60
32 - granularity: 20 second
33 timespan: 1 minute
34 - points: 5
35 timespan: 5 minute
36 aggregation_methods:
37 - mean
38 - min
39 - max
40 response_json_paths:
41 $.name: gabbiliveceph
42 $.back_window: 0
43 $.aggregation_methods.`len`: 3
44
45 - name: create resource type ceph_account
46 desc: needed to create a resource
47 POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource_type
48 status: 201 || 409
49 request_headers:
50 content-type: application/json
51 data:
52 name: ceph_account
53
54 - name: create resource of ceph_account type
55 POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/ceph_account
56 request_headers:
57 content-type: application/json
58 data:
Julien Danjou0cf2f9f2017-02-01 17:42:05 +010059 id: 662e46f3-8c06-430c-8a9c-adcaedd1272c
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +010060 user_id: 27e342e4-4489-424f-a7e4-ba8ed9ad729c
61 project_id: d6d32769-c351-4758-b0a2-458fa1a065a3
62 metrics:
63 radosgw.objects:
64 archive_policy_name: gabbiliveceph
65 radosgw.objects.size:
66 archive_policy_name: gabbiliveceph
67 radosgw.objects.containers:
68 archive_policy_name: gabbiliveceph
69 radosgw.api.request:
70 archive_policy_name: gabbiliveceph
71 radosgw.containers.objects:
72 archive_policy_name: gabbiliveceph
73 radosgw.containers.objects.size:
74 archive_policy_name: gabbiliveceph
75 status: 201
76 response_json_paths:
77 $.user_id: 27e342e4-4489-424f-a7e4-ba8ed9ad729c
78 $.project_id: d6d32769-c351-4758-b0a2-458fa1a065a3
79 $.metrics.`len`: 6
80
81 #
82 # Actual tests
83 #
84
85 - name: search 'gabbi-gnocchi-threshold-resource-alarm' alarm doesnt exist
86 desc: search for alarm using user_id, project_id, alarm_name
87 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
88 query_parameters:
89 q.field:
90 - user_id
91 - project_id
92 - name
93 q.op:
94 - eq
95 - eq
96 - eq
97 q.value:
98 - c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
99 - 709f6ed6-bfb3-4649-b303-0019a7f6aef2
100 - gabbi-gnocchi-threshold-resource-alarm
101 method: GET
102 response_json_paths:
103 $.`len`: 0
104
105 - name: fail to create alarm 'gabbi-gnocchi-threshold-resource-alarm'
106 desc: fails until resource exists in gnocchi
107 POST: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
108 request_headers:
109 content-type: application/json
110 data:
111 alarm_actions:
112 - "http://site:8000/gnocchi-threshold-resource"
113 alarm_id: null
114 description: An gabbilive threshold based alarm
115 enabled: true
116 insufficient_data_actions:
117 - "http://site:8000/nodata-gnocchi-threshold-resource"
118 name: "gabbi-gnocchi-threshold-resource-alarm"
119 ok_actions:
120 - "http://site:8000/ok-gnocchi-threshold-resource"
121 project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2
122 repeat_actions: false
123 severity: moderate
124 state: "insufficient data"
125 type: gnocchi_resources_threshold
126 gnocchi_resources_threshold_rule:
127 evaluation_periods: 3
128 metric: "radosgw.containers.objects"
129 resource_id: "fake-mock-up"
130 aggregation_method: "mean"
131 granularity: 60
132 threshold: 5.0
133 comparison_operator: "ge"
134 resource_type: ceph_account
135 user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
136 status: 404
137
138 - name: create alarm 'gabbi-gnocchi-threshold-resource-alarm'
139 desc: create a threshold alarm gabbi-gnocchi-threshold-resource-alarm
140 POST: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
141 request_headers:
142 content-type: application/json
143 data:
144 alarm_actions:
145 - "http://site:8000/gnocchi-threshold-resource"
146 alarm_id: null
147 description: An gabbilive threshold based alarm
148 enabled: true
149 insufficient_data_actions:
150 - "http://site:8000/nodata-gnocchi-threshold-resource"
151 name: "gabbi-gnocchi-threshold-resource-alarm"
152 ok_actions:
153 - "http://site:8000/ok-gnocchi-threshold-resource"
154 project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2
155 repeat_actions: false
156 severity: moderate
157 state: "insufficient data"
158 type: gnocchi_resources_threshold
159 gnocchi_resources_threshold_rule:
160 evaluation_periods: 3
161 metric: "radosgw.objects.size"
Julien Danjou0cf2f9f2017-02-01 17:42:05 +0100162 resource_id: "662e46f3-8c06-430c-8a9c-adcaedd1272c"
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +0100163 aggregation_method: "mean"
164 granularity: 60
165 threshold: 5.0
166 comparison_operator: "ge"
167 resource_type: ceph_account
168 user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
169 status: 201
170 response_json_paths:
171 $.name: gabbi-gnocchi-threshold-resource-alarm
172 $.type: gnocchi_resources_threshold
173 $.user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
174 $.project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2
175 $.severity: moderate
176
177 - name: retrieve history about 'gabbi-gnocchi-threshold-resource-alarm' creation
178 desc: get history about alarm creation
179 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.alarm_id']/history
180 request_headers:
181 content-type: application/json
182 poll:
183 count: 5
184 delay: 2
185 response_json_paths:
186 $.`len`: 1
187 $.[0].type: creation
188 $.[0].alarm_id: $RESPONSE['$.alarm_id']
189
190 - name: update severity for alarm 'gabbi-gnocchi-threshold-resource-alarm'
191 desc: update severity for alarm gabbi-gnocchi-threshold-resource-alarm
192 PUT: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id']
193 status: 200
194 request_headers:
195 content-type: application/json
196 data:
197 alarm_actions:
198 - "http://site:8000/gnocchi-threshold-resource"
199 alarm_id: null
200 description: An gabbilive threshold based alarm
201 enabled: true
202 insufficient_data_actions:
203 - "http://site:8000/nodata-gnocchi-threshold-resource"
204 name: "gabbi-gnocchi-threshold-resource-alarm"
205 ok_actions:
206 - "http://site:8000/ok-gnocchi-threshold-resource"
207 project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2
208 repeat_actions: false
209 severity: low
210 state: "insufficient data"
211 type: gnocchi_resources_threshold
212 gnocchi_resources_threshold_rule:
213 evaluation_periods: 3
214 metric: "radosgw.objects.size"
Julien Danjou0cf2f9f2017-02-01 17:42:05 +0100215 resource_id: "662e46f3-8c06-430c-8a9c-adcaedd1272c"
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +0100216 aggregation_method: "mean"
217 granularity: 60
218 threshold: 5.0
219 comparison_operator: "ge"
220 resource_type: ceph_account
221 user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
222 response_json_paths:
223 $.name: gabbi-gnocchi-threshold-resource-alarm
224 $.type: gnocchi_resources_threshold
225 $.user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
226 $.project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2
227 $.severity: low
228 $.state: "insufficient data"
229
230 - name: retrieve history for 'gabbi-gnocchi-threshold-resource-alarm'
231 desc: get history for rule_change
232 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.alarm_id']/history
233 request_headers:
234 content-type: application/json
235 poll:
236 count: 5
237 delay: 2
238 response_json_paths:
239 $.`len`: 2
240 $.[0].type: rule change
241 $.[0].alarm_id: $RESPONSE['$.alarm_id']
242 $.[0].detail: '{"severity": "low"}'
243
244 - name: update alarm state for 'gabbi-gnocchi-threshold-resource-alarm'
245 desc: update state for alarm
246 PUT: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id']/state
247 request_headers:
248 content-type: application/json
249 data: '"ok"'
250 status: 200
251 response_strings:
252 "ok"
253
254 - name: search 'gabbi-gnocchi-threshold-resource-alarm' alarm exist
255 desc: search for alarm using user_id, project_id, alarm_name
256 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
257 query_parameters:
258 q.field:
259 - user_id
260 - project_id
261 - name
262 q.op:
263 - eq
264 - eq
265 - eq
266 q.value:
267 - c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
268 - 709f6ed6-bfb3-4649-b303-0019a7f6aef2
269 - gabbi-gnocchi-threshold-resource-alarm
270 poll:
271 count: 5
272 delay: 2
273 response_json_paths:
274 $.`len`: 1
275
276 - name: get info about 'gabbi-gnocchi-threshold-resource-alarm' alarm
277 desc: access alarm using its ID
278 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id']
279 response_json_paths:
280 $.alarm_id: $RESPONSE['$.[0].alarm_id']
281 $.alarm_actions: ["http://site:8000/gnocchi-threshold-resource"]
282 $.name: gabbi-gnocchi-threshold-resource-alarm
Julien Danjou0cf2f9f2017-02-01 17:42:05 +0100283 $.gnocchi_resources_threshold_rule.resource_id: "662e46f3-8c06-430c-8a9c-adcaedd1272c"
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +0100284 $.gnocchi_resources_threshold_rule.metric: "radosgw.objects.size"
285 $.gnocchi_resources_threshold_rule.resource_type: "ceph_account"
286 $.user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
287
288 - name: get alarm state for 'gabbi-gnocchi-threshold-resource-alarm'
289 desc: get state for alarm
290 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.alarm_id']/state
291 request_headers:
292 content-type: application/json
293 status: 200
294 response_strings:
295 - "ok"
296
297 #
298 # Teardown
299 #
300
301 - name: CLEANUP. search 'gabbi-gnocchi-threshold-resource' alarm exist
302 desc: Find alarm id using user_id, project_id, alarm_name
303 GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
304 query_parameters:
305 q.field:
306 - user_id
307 - project_id
308 - name
309 q.op:
310 - eq
311 - eq
312 - eq
313 q.value:
314 - c8ecb587-d38c-426f-a58d-22b8d4a9a1d3
315 - 709f6ed6-bfb3-4649-b303-0019a7f6aef2
316 - gabbi-gnocchi-threshold-resource-alarm
317 response_json_paths:
318 $.`len`: 1
319
320 - name: CLEANUP. delete threshold alarm 'gabbi-gnocchi-threshold-resource'
321 DELETE: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id']
322 status: 204
323
Julien Danjou0cf2f9f2017-02-01 17:42:05 +0100324 - name: CLEANUP. Get resource by name '662e46f3-8c06-430c-8a9c-adcaedd1272c'
325 desc: retrieve resource by 662e46f3-8c06-430c-8a9c-adcaedd1272c to get its ID
326 GET: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/generic/662e46f3-8c06-430c-8a9c-adcaedd1272c
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +0100327 status: 200
328
Julien Danjou0cf2f9f2017-02-01 17:42:05 +0100329 - name: CLEANUP. delete test ceph_resource '662e46f3-8c06-430c-8a9c-adcaedd1272c'
330 desc: delete ceph_account resource 662e46f3-8c06-430c-8a9c-adcaedd1272c
Yurii Prokulevychaf09dd92016-12-15 16:14:17 +0100331 DELETE: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/generic/$RESPONSE['$.id']
332 status: 204
333
334 - name: CLEANUP. delete resource type ceph_account
335 DELETE: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource_type/ceph_account
336 status: 204
337
338 - name: CLEANUP. delete archive
339 DELETE: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/archive_policy/gabbiliveceph
340 status: 204
341 xfail: True
342