aodh/aodh/tests/functional/gabbi/gabbits/alarms.yaml

195 lines
5.4 KiB
YAML

# Requests to cover the basic endpoints for alarms.
fixtures:
- ConfigFixture
tests:
- name: list alarms none
desc: Lists alarms, none yet exist
GET: /v2/alarms
response_strings:
- "[]"
- name: try to PUT an alarm
desc: what does PUT do
PUT: /v2/alarms
request_headers:
content-type: application/json
data:
name: added_alarm_defaults2
type: gnocchi_resources_threshold
gnocchi_resources_threshold_rule:
metric: ameter
resource_id: random_id
resource_type: instance
aggregation_method: max
threshold: 300.0
status: 405
response_headers:
allow: GET, POST
- name: try to POST an event type alarm
desc: what does POST response be
POST: /v2/alarms
request_headers:
content-type: application/json
data:
name: instance_off
type: event
event_rule:
query: [{'field': "{=:", 'op': "eq", 'type': "string", 'value': "sample_string"}]
status: 400
response_strings:
- "Query value or traits invalid:"
- name: try to POST an event type alarm2
desc: what does POST response be
POST: /v2/alarms
request_headers:
content-type: application/json
data:
name: instance_off
type: event
event_rule:
query: [{'field': "traits.instance_id", 'op': "eq", 'type': "", 'value': "default_string_datatype_isconsidered"}]
status: 201
- name: try to POST an event type alarm3
desc: what does POST response be
POST: /v2/alarms
request_headers:
content-type: application/json
data:
name: instance_off
type: event
event_rule:
query: [{'field': "traits.instance_id", 'op': "lt", 'type': "integer", 'value': "1234567"}]
status: 201
- name: try to POST an event type alarm4
desc: what does POST response be
POST: /v2/alarms
request_headers:
content-type: application/json
data:
name: instance_off
type: event
event_rule:
query: [{'field': "traits.instance_id", 'op': "lt", 'type': "integer", 'value': "hello"}]
status: 400
response_strings:
- "Unable to convert the value hello to the expected data type integer"
- name: try to POST an event type alarm5
desc: what does POST response be
POST: /v2/alarms
request_headers:
content-type: application/json
data:
name: instance_off
type: event
event_rule:
query: [{'field': "traits.instance_id", 'op': "ltt", 'type': "integer", 'value': "1234567"}]
status: 400
response_strings:
- "Query value or traits invalid:"
- name: createAlarm
desc: Creates an alarm.
POST: /v2/alarms
request_headers:
content-type: application/json
data:
ok_actions: null
name: added_alarm_defaults
type: gnocchi_resources_threshold
gnocchi_resources_threshold_rule:
metric: ameter
resource_id: random_id
resource_type: instance
aggregation_method: max
threshold: 300.0
status: 201
response_headers:
location: /$SCHEME://$NETLOC/v2/alarms/
content-type: application/json
response_json_paths:
$.severity: low
$.gnocchi_resources_threshold_rule.threshold: 300.0
$.gnocchi_resources_threshold_rule.comparison_operator: eq
- name: showAlarm
desc: Shows information for a specified alarm.
GET: /v2/alarms/$RESPONSE['$.alarm_id']
response_json_paths:
$.severity: low
$.alarm_id: $RESPONSE['$.alarm_id']
$.gnocchi_resources_threshold_rule.threshold: 300.0
$.gnocchi_resources_threshold_rule.comparison_operator: eq
response_headers:
content-type: application/json
- name: updateAlarm
desc: Updates a specified alarm.
PUT: /v2/alarms/$RESPONSE['$.alarm_id']
request_headers:
content-type: application/json
data:
name: added_alarm_defaults
severity: moderate
type: gnocchi_resources_threshold
gnocchi_resources_threshold_rule:
metric: ameter
resource_id: random_id
resource_type: instance
aggregation_method: max
threshold: 200.0
# TODO(chdent): why do we have a response, why not status: 204?
# status: 204
response_json_paths:
$.gnocchi_resources_threshold_rule.threshold: 200.0
$.severity: moderate
$.state: insufficient data
- name: showAlarmHistory
desc: Assembles the history for a specified alarm.
GET: /v2/alarms/$RESPONSE['$.alarm_id']/history?q.field=type&q.op=eq&q.value=rule%20change
response_json_paths:
$[0].type: rule change
- name: updateAlarmState
desc: Sets the state of a specified alarm.
PUT: /v2/alarms/$RESPONSE['$[0].alarm_id']/state
request_headers:
content-type: application/json
data: '"alarm"'
# TODO(chdent): really? Of what possible use is this?
response_json_paths:
$: alarm
# Get a list of alarms so we can extract an id for the next test
- name: list alarms
desc: Lists alarms, only one
GET: /v2/alarms
response_json_paths:
$[0].name: added_alarm_defaults
- name: showAlarmState
desc: Gets the state of a specified alarm.
GET: /v2/alarms/$RESPONSE['$[0].alarm_id']/state
response_headers:
content-type: application/json
response_json_paths:
$: alarm
- name: deleteAlarm
desc: Deletes a specified alarm.
DELETE: /v2/alarms/$HISTORY['list alarms'].$RESPONSE['$[0].alarm_id']
status: 204
- name: list alarms none end
desc: Lists alarms, none now exist
GET: /v2/alarms
response_strings:
- "[]"