Need to validate date and time format of a response of tenant_usage API

Bug #1567640 reported by Ken'ichi Ohmichi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
Medium
Ghanshyam Mann

Bug Description

https://github.com/openstack/tempest-lib/blob/master/tempest_lib/api_schema/response/compute/v2_1/tenant_usages.py#L34

Current response schema just checks string format, but we have multiple date and time format.
So tempest needs to validate these formats to block backwards incompatible change.

Changed in tempest:
importance: Undecided → Medium
Revision history for this message
Matt Riedemann (mriedem) wrote :

(3:09:10 PM) mriedem: oomichi: the response value for started_at is here https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/simple_tenant_usage.py#L132
(3:09:28 PM) mriedem: which is instance.launched_at, which is an oslo.versionedobject DateTimeField
(3:10:00 PM) mriedem: which gets it's string version here https://github.com/openstack/oslo.versionedobjects/blob/master/oslo_versionedobjects/fields.py#L403
(3:10:17 PM) mriedem: and the format for that is here https://github.com/openstack/oslo.versionedobjects/blob/master/oslo_versionedobjects/_utils.py#L21

Changed in tempest:
status: New → Confirmed
Revision history for this message
Matt Riedemann (mriedem) wrote :

Here is example request/response from novaclient:

DEBUG (session:248) REQ: curl -g -i -X GET http://9.5.124.163:8774/v2.1/9ec8476726a64ebabcf3b5ef1f97d1de/os-simple-tenant-usage/9ec8476726a64ebabcf3b5ef1f97d1de?start=2016-03-10T20:19:46.402011&end=2016-04-08T20:19:46.402011 -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-OpenStack-Nova-API-Version: 2.25" -H "X-Auth-Token: {SHA1}a6eeba241fe35e8892607282e244a3bd628b3c6a"
DEBUG (connectionpool:387) "GET /v2.1/9ec8476726a64ebabcf3b5ef1f97d1de/os-simple-tenant-usage/9ec8476726a64ebabcf3b5ef1f97d1de?start=2016-03-10T20:19:46.402011&end=2016-04-08T20:19:46.402011 HTTP/1.1" 200 645
DEBUG (session:277) RESP: [200] Content-Length: 645 X-Compute-Request-Id: req-39e8decd-73a3-486e-be48-34c0b9c2b834 Vary: X-OpenStack-Nova-API-Version Connection: keep-alive X-Openstack-Nova-Api-Version: 2.25 Date: Thu, 07 Apr 2016 20:19:46 GMT Content-Type: application/json
RESP BODY: {"tenant_usage": {"total_memory_mb_usage": 22.854223644444446, "total_vcpus_usage": 0.04463715555555556, "start": "2016-03-10T20:19:46.402011", "tenant_id": "9ec8476726a64ebabcf3b5ef1f97d1de", "stop": "2016-04-07T20:19:46.693760", "server_usages": [{"instance_id": "cda8a8ac-6eac-434d-bded-a0b34d285f41", "uptime": 160, "started_at": "2016-04-07T20:17:06.000000", "ended_at": null, "memory_mb": 512, "tenant_id": "9ec8476726a64ebabcf3b5ef1f97d1de", "state": "active", "hours": 0.04463715555555556, "vcpus": 1, "flavor": "m1.tiny", "local_gb": 1, "name": "test"}], "total_hours": 0.04463715555555556, "total_local_gb_usage": 0.04463715555555556}}

Changed in tempest:
assignee: nobody → Ghanshyam Mann (ghanshyammann)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tempest (master)

Fix proposed to branch: master
Review: https://review.openstack.org/304441

Changed in tempest:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tempest (master)

Reviewed: https://review.openstack.org/304441
Committed: https://git.openstack.org/cgit/openstack/tempest/commit/?id=f9ded3536646bb3998325f3417ef4ed588e05b7d
Submitter: Jenkins
Branch: master

commit f9ded3536646bb3998325f3417ef4ed588e05b7d
Author: ghanshyam <email address hidden>
Date: Tue Apr 12 17:03:01 2016 +0900

    Fix date-time format checking in response schema

    Currently datetime attributes in response schema like
    'created_at' etc are being validated against type 'string' only
    not with ISO 8601 date time format.

    Another issue is with jsonschema validation for built-in 'date-time'
    format. It needs 'strict_rfc3339' or 'isodate' module to be installed
    for proper date-time validation as per rfc3339.
    Otherwise it returns True wihtout doing any validation.

    This patch define the new format checker for 'iso8601-date-time' format
    which checks the format as per ISO 8601 with help of oslo_utils.timeutils
    and validate all the date time attributes against JSON schema
    'iso8601-date-time' format.

    NOTE: date in image API header is returned in different format than
    ISO 8601 date time format which is not consistent with other date-time
    format in nova. So validating this as string only.
    This API is already deprecated so not worth to fix on nova side.

    Change-Id: Ief7729975daea373dcfa54a23ec76c3ec7754a70
    Closes-Bug: #1567640

Changed in tempest:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.