# # Tests to explore and cover the /v2/meters section of the # Ceilometer API. # fixtures: - ConfigFixture tests: # Generic HTTP health explorations of all meters. - name: empty meters list GET: /v2/meters response_headers: content-type: /application/json/ response_strings: - "[]" - name: meters list bad accept GET: /v2/meters request_headers: accept: text/plain status: 406 - name: meters list bad method POST: /v2/meters status: 405 response_headers: allow: GET - name: try to delete meters DELETE: /v2/meters status: 405 response_headers: allow: GET # Generic HTTP health explorations of single meter. - name: get non exist meter GET: /v2/meters/noexist response_strings: - "[]" - name: meter bad accept GET: /v2/meters/noexist?direct=True request_headers: accept: text/plain status: 406 - name: meter delete noexist DELETE: /v2/meters/noexist status: "404 || 405" - name: post meter no data POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: "" status: 400 - name: post meter error is JSON POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: "" status: 400 response_headers: content-type: /application/json/ response_json_paths: $.error_message.faultstring: "Samples should be included in request body" - name: post meter bad content-type POST: /v2/meters/apples?direct=True request_headers: content-type: text/plain data: hello status: 415 - name: post bad samples to meter POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: samples: - red - blue - yellow status: 400 # POST variations on a malformed sample - name: post limited counter to meter POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_unit: instance counter_volume: 1 resource_id: bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 status: 400 response_strings: - "Invalid input for field/attribute counter_name" - name: post mismatched counter name to meter POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_name: cars counter_type: gauge counter_unit: instance counter_volume: 1 resource_id: bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 status: 400 response_strings: - "Invalid input for field/attribute counter_name" - "should be apples" - name: post counter no resource to meter POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 1 status: 400 response_strings: - "Invalid input for field/attribute resource_id" - "Mandatory field missing." - name: post counter bad type to meter POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_name: apples counter_type: elevation counter_unit: instance counter_volume: 1 resource_id: bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 status: 400 response_strings: - "Invalid input for field/attribute counter_type." - "The counter type must be: gauge, delta, cumulative" # Manipulate samples - name: post counter to meter POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 1 resource_id: bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 status: 201 - name: list apple samples GET: /v2/meters/apples response_json_paths: $[0].counter_volume: 1.0 $[0].counter_name: apples $[0].resource_id: bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 - name: list meters GET: /v2/meters response_json_paths: $[0].name: apples $[0].resource_id: bd9431c1-8d69-4ad3-803a-8d4a6b89fd36 $[0].type: gauge $[-1].name: apples - name: negative limit on meter list GET: /v2/meters/apples?limit=-5 status: 400 response_strings: - Limit must be positive - name: nan limit on meter list GET: /v2/meters/apples?limit=NaN status: 400 response_strings: - unable to convert to int - name: post counter to meter different resource POST: /v2/meters/apples?direct=True status: 201 request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 2 resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa - name: query for resource GET: /v2/meters/apples?q.field=resource_id&q.value=aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa&q.op=eq response_json_paths: $[0].resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa $[-1].resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa # Explore posting samples with less than perfect data. - name: post counter with bad timestamp POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 3 resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa timestamp: "2013-01-bad 23:23:20" status: 400 response_strings: - 'Invalid input for field/attribute samples' - name: post counter with good timestamp POST: /v2/meters/apples?direct=True status: 201 request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 3 resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa timestamp: "2013-01-01 23:23:20" - name: post counter with wrong metadata POST: /v2/meters/apples?direct=True request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 3 resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa timestamp: "2013-01-01 23:23:20" resource_metadata: "a string" status: 400 response_strings: - "Invalid input for field/attribute samples" - name: post counter with empty metadata POST: /v2/meters/apples?direct=True status: 201 request_headers: content-type: application/json data: - counter_name: apples counter_type: gauge counter_unit: instance counter_volume: 3 resource_id: aa9431c1-8d69-4ad3-803a-8d4a6b89fdaa timestamp: "2013-01-01 23:23:20" resource_metadata: {} # Statistics - name: get sample statistics GET: /v2/meters/apples/statistics response_json_paths: $[0].groupby: null $[0].unit: instance $[0].sum: 9.0 $[0].min: 1.0 $[0].max: 3.0 $[0].count: 4 - name: get incorrectly grouped sample statistics GET: /v2/meters/apples/statistics?groupby=house_id status: 400 response_strings: - Invalid groupby fields - name: get grouped sample statistics GET: /v2/meters/apples/statistics?groupby=resource_id response_json_paths: $[1].max: 3.0 $[0].max: 1.0 - name: get sample statistics bad period GET: /v2/meters/apples/statistics?period=seven status: 400 response_strings: - unable to convert to int - name: get sample statistics negative period GET: /v2/meters/apples/statistics?period=-7 status: 400 response_strings: - Period must be positive. - name: get sample statistics 600 period GET: /v2/meters/apples/statistics?period=600 response_json_paths: $[0].period: 600 - name: get sample statistics time limit not time GET: /v2/meters/apples/statistics?q.field=timestamp&q.op=gt&q.value=Remember%20Remember status: 400 response_strings: - invalid timestamp format - name: get sample statistics time limit gt GET: /v2/meters/apples/statistics?q.field=timestamp&q.op=gt&q.value=2014-01-01 response_json_paths: $[0].count: 2 - name: get sample statistics time limit lt GET: /v2/meters/apples/statistics?q.field=timestamp&q.op=lt&q.value=2014-01-01 response_json_paths: $[0].count: 2 - name: get sample statistics time limit bounded GET: /v2/meters/apples/statistics?q.field=timestamp&q.op=gt&q.value=2013-06-01&q.field=timestamp&q.op=lt&q.value=2014-01-01 response_strings: - "[]" - name: get sample statistics select aggregate bad format GET: /v2/meters/apples/statistics?aggregate=max status: 400 - name: get sample statistics select aggregate GET: /v2/meters/apples/statistics?aggregate.func=max response_json_paths: $[0].aggregate.max: 3.0 - name: get sample statistics select aggregate multiple GET: /v2/meters/apples/statistics?aggregate.func=max&aggregate.func=count response_json_paths: $[0].aggregate.max: 3.0 $[0].aggregate.count: 4 - name: get sample statistics select aggregate bad function GET: /v2/meters/apples/statistics?aggregate.func=mmm status: 400 response_strings: - 'Invalid aggregation function: mmm' - name: get sample statistics select aggregate good function and bad function GET: /v2/meters/apples/statistics?aggregate.func=max&aggregate.func=mmm status: 400 response_strings: - 'Invalid aggregation function: mmm' # limit meters results - name: get meters ulimited GET: /v2/meters response_json_paths: $.`len`: 2 - name: get meters limited GET: /v2/meters?limit=1 response_json_paths: $.`len`: 1 - name: get meters double limit GET: /v2/meters?limit=1&limit=1 status: 400 - name: get meters filter limit desc: expressing limit this way is now disallowed GET: /v2/meters?q.field=limit&q.op=eq&q.type=&q.value=1 status: 400 response_strings: - 'Unknown argument: \"limit\": unrecognized field in query' - name: get meters filter limit and limit GET: /v2/meters?q.field=limit&q.op=eq&q.type=&q.value=1&limit=1 status: 400 response_strings: - 'Unknown argument: \"limit\": unrecognized field in query'