Initial gabbi testing for alarms
Initial testing of the alarms-related resources in the API. Note that these tests were initially started by processing the WADL files at https://github.com/openstack/api-site/tree/master/api-ref/src/wadls to generate a stubbed out YAML file which was then filled in and reordered as required. It doesn't save a great deal of time but does provide a base to start from, which is useful scaffolding to get started. Thus, the endpoints in the YAML file are only those endpoints mentioned in the WADL. If the documentation is not up to date, then neither are these tests. The course of these tests is as follows: * list the alarms confirm there are none * create an alarm * list the alarms confirm there are one * update an alarm * check an alarm's history * change state on alarm * check the state * delete the alarm * list the alarms confirm there are none This is not sufficient for coverage but does provide a good representation of what's going on in the alarms API. Tests with 'xfail: true' will require changes either in frameworks or controllers, pending discussion. Change-Id: I814b65abb753c4882b0aed48f0b20d6994fb1f30
This commit is contained in:
parent
35d375dabc
commit
8bd9b4edd6
144
ceilometer/tests/gabbi/gabbits/alarms.yaml
Normal file
144
ceilometer/tests/gabbi/gabbits/alarms.yaml
Normal file
@ -0,0 +1,144 @@
|
||||
# Requests to cover the basic endpoints for alarms.
|
||||
|
||||
fixtures:
|
||||
- ConfigFixture
|
||||
|
||||
tests:
|
||||
- name: list alarms none
|
||||
desc: Lists alarms, none yet exist
|
||||
url: /v2/alarms
|
||||
method: GET
|
||||
response_strings:
|
||||
- "[]"
|
||||
|
||||
# TODO(chdent) because of the way _lookup is used in the
|
||||
# AlarmsController pecan is unable to correctly create a 405
|
||||
# when it receives a PUT to /v2/alarms. This is partially
|
||||
# fixable in Ceilometer by raising an exception in _lookup if
|
||||
# alarm_id is not present, but no Allow header will be created.
|
||||
- name: try to PUT an alarm
|
||||
xfail: true
|
||||
desc: what does PUT do
|
||||
url: /v2/alarms
|
||||
method: PUT
|
||||
request_headers:
|
||||
content-type: application/json
|
||||
data:
|
||||
name: added_alarm_defaults2
|
||||
type: threshold
|
||||
threshold_rule:
|
||||
meter_name: ameter
|
||||
threshold: 300.0
|
||||
status: 405
|
||||
response_headers:
|
||||
allow: GET, POST
|
||||
|
||||
# TODO(chdent): A POST should return a location header.
|
||||
- name: createAlarm
|
||||
xfail: true
|
||||
desc: Creates an alarm.
|
||||
url: /v2/alarms
|
||||
method: POST
|
||||
request_headers:
|
||||
content-type: application/json
|
||||
data:
|
||||
name: added_alarm_defaults
|
||||
type: threshold
|
||||
threshold_rule:
|
||||
meter_name: ameter
|
||||
threshold: 300.0
|
||||
status: 201
|
||||
response_headers:
|
||||
location: /$SCHEME://$NETLOC/v2/alarms/
|
||||
content-type: application/json; charset=UTF-8
|
||||
response_json_paths:
|
||||
$.severity: low
|
||||
$.threshold_rule.threshold: 300.0
|
||||
$.threshold_rule.comparison_operator: eq
|
||||
|
||||
- name: showAlarm
|
||||
desc: Shows information for a specified alarm.
|
||||
url: /v2/alarms/$RESPONSE['$.alarm_id']
|
||||
method: GET
|
||||
response_json_paths:
|
||||
$.severity: low
|
||||
$.alarm_id: $RESPONSE['$.alarm_id']
|
||||
$.threshold_rule.threshold: 300.0
|
||||
$.threshold_rule.comparison_operator: eq
|
||||
response_headers:
|
||||
content-type: application/json; charset=UTF-8
|
||||
|
||||
- name: updateAlarm
|
||||
desc: Updates a specified alarm.
|
||||
url: /v2/alarms/$RESPONSE['$.alarm_id']
|
||||
method: PUT
|
||||
request_headers:
|
||||
content-type: application/json
|
||||
data:
|
||||
name: added_alarm_defaults
|
||||
type: threshold
|
||||
severity: moderate
|
||||
threshold_rule:
|
||||
meter_name: ameter
|
||||
threshold: 200.0
|
||||
# TODO(chdent): why do we have a response, why not status: 204?
|
||||
# status: 204
|
||||
response_json_paths:
|
||||
$.threshold_rule.threshold: 200.0
|
||||
$.severity: moderate
|
||||
$.state: insufficient data
|
||||
|
||||
- name: showAlarmHistory
|
||||
desc: Assembles the history for a specified alarm.
|
||||
url: /v2/alarms/$RESPONSE['$.alarm_id']/history?q.field=type&q.op=eq&q.value=rule%20change
|
||||
method: GET
|
||||
response_json_paths:
|
||||
$[0].type: rule change
|
||||
|
||||
- name: updateAlarmState
|
||||
desc: Sets the state of a specified alarm.
|
||||
url: /v2/alarms/$RESPONSE['$[0].alarm_id']/state
|
||||
request_headers:
|
||||
content-type: application/json
|
||||
data: '"alarm"'
|
||||
method: PUT
|
||||
# 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 for data
|
||||
desc: Lists alarms, only one
|
||||
url: /v2/alarms
|
||||
method: GET
|
||||
response_json_paths:
|
||||
$[0].name: added_alarm_defaults
|
||||
|
||||
- name: showAlarmState
|
||||
desc: Gets the state of a specified alarm.
|
||||
url: /v2/alarms/$RESPONSE['$[0].alarm_id']/state
|
||||
method: GET
|
||||
response_headers:
|
||||
content-type: application/json; charset=UTF-8
|
||||
response_json_paths:
|
||||
$: alarm
|
||||
|
||||
- name: list alarms one
|
||||
desc: Lists alarms, only one
|
||||
url: /v2/alarms
|
||||
method: GET
|
||||
response_json_paths:
|
||||
$[0].name: added_alarm_defaults
|
||||
|
||||
- name: deleteAlarm
|
||||
desc: Deletes a specified alarm.
|
||||
url: /v2/alarms/$RESPONSE['$[0].alarm_id']
|
||||
method: DELETE
|
||||
status: 204
|
||||
|
||||
- name: list alarms none end
|
||||
desc: Lists alarms, none now exist
|
||||
url: /v2/alarms
|
||||
method: GET
|
||||
response_strings:
|
||||
- "[]"
|
Loading…
x
Reference in New Issue
Block a user