ceilometer/ceilometer/tests/functional/gabbi/gabbits/samples.yaml

155 lines
4.3 KiB
YAML

#
# Explore and test the samples controller, using samples supplied by
# the SampleDataFixture.
#
fixtures:
- ConfigFixture
- SampleDataFixture
tests:
# Confirm all the samples are there and expected requests behave.
# TODO(chdent): There's a danger here that the ordering of multiple
# samples will not be consistent.
- name: lists samples
GET: /v2/samples
response_headers:
content-type: /application/json/
response_json_paths:
$[0].meter: livestock
$[0].metadata.breed: cow
$[1].metadata.breed: pig
$[2].metadata.breed: sheep
- name: get just one
GET: /v2/samples/$RESPONSE['$[0].id']
response_json_paths:
$.meter: livestock
$.metadata.breed: cow
- name: list samples with limit
GET: /v2/samples?limit=1
response_json_paths:
$[0].meter: livestock
$[0].metadata.breed: cow
$[-1].metadata.breed: cow
- name: list zero samples with zero limit
GET: /v2/samples?limit=0
status: 400
- name: list samples with query
GET: /v2/samples?q.field=resource_metadata.breed&q.value=cow&q.op=eq
response_json_paths:
$[0].meter: livestock
$[0].metadata.breed: cow
$[-1].metadata.breed: cow
- name: query by user
GET: /v2/samples?q.field=user&q.value=$RESPONSE['$[0].user_id']&q.op=eq
response_json_paths:
$[0].user_id: $RESPONSE['$[0].user_id']
- name: query by user_id
GET: /v2/samples?q.field=user_id&q.value=$RESPONSE['$[0].user_id']&q.op=eq
response_json_paths:
$[0].user_id: $RESPONSE['$[0].user_id']
- name: query by project
GET: /v2/samples?q.field=project&q.value=$RESPONSE['$[0].project_id']&q.op=eq
response_json_paths:
$[0].project_id: $RESPONSE['$[0].project_id']
- name: query by project_id
GET: /v2/samples?q.field=project_id&q.value=$RESPONSE['$[0].project_id']&q.op=eq
response_json_paths:
$[0].project_id: $RESPONSE['$[0].project_id']
# Explore failure modes for listing samples
- name: list samples with bad field
GET: /v2/samples?q.field=harpoon&q.value=cow&q.op=eq
status: 400
response_strings:
- timestamp
- project
- unrecognized field in query
- name: list samples with bad metaquery field
GET: /v2/samples?q.field=metaquery&q.value=cow&q.op=eq
status: 400
response_strings:
- unrecognized field in query
- name: bad limit value
GET: /v2/samples?limit=happiness
status: 400
response_strings:
- Invalid input for field/attribute limit
- name: negative limit value 400
GET: /v2/samples?limit=-99
status: 400
- name: negative limit value error message
GET: /v2/samples?limit=-99
status: 400
response_headers:
content-type: /application/json/
response_json_paths:
$.error_message.faultstring: Limit must be positive
- name: bad accept
desc: try an unexpected content type
GET: /v2/samples
request_headers:
accept: text/plain
status: 406
- name: complex good accept
desc: client sends complex accept do we adapt
GET: /v2/samples
request_headers:
accept: text/plain, application/json; q=0.8
- name: complex bad accept
desc: client sends complex accept do we adapt
GET: /v2/samples
request_headers:
accept: text/plain, application/binary; q=0.8
status: 406
- name: bad method
POST: /v2/samples
status: 405
response_headers:
allow: GET
# Work with just one sample.
- name: list one of the samples
GET: /v2/samples?limit=1
- name: retrieve one sample
GET: /v2/samples/$RESPONSE['$[0].id']
response_headers:
content-type: /application/json/
response_json_paths:
$.meter: livestock
- name: retrieve sample with useless query
GET: /v2/samples/$RESPONSE['$.id']?limit=5
status: 400
response_strings:
- "Unknown argument:"
- name: attempt missing sample
GET: /v2/samples/davesnothere
status: 404
response_headers:
content-type: /application/json/
response_json_paths:
$.error_message.faultstring: Sample davesnothere Not Found