Automate generation of API versions api-ref samples

This patch adds Tests for the following :

1) API versions
2) API extensions

Change-Id: Ieaa1e2768c091b93c7afcbf04ec4a181cb021ec5
Partially-Implements: blueprint generating-sample-files
This commit is contained in:
whoami-rajat 2018-11-26 17:56:18 +05:30
parent da34b35579
commit c5c5c009ff
48 changed files with 632 additions and 37 deletions

View File

@ -37,5 +37,5 @@ Response
**Example List Api Versions: JSON request** **Example List Api Versions: JSON request**
.. literalinclude:: ./samples/versions-response.json .. literalinclude:: ./samples/versions/versions-response.json
:language: javascript :language: javascript

View File

@ -0,0 +1,221 @@
{
"extensions": [
{
"alias": "os-hosts",
"description": "Admin-only host administration.",
"links": [],
"name": "Hosts",
"updated": "2011-06-29T00:00:00+00:00"
},
{
"alias": "os-vol-tenant-attr",
"description": "Expose the internal project_id as an attribute of a volume.",
"links": [],
"name": "VolumeTenantAttribute",
"updated": "2011-11-03T00:00:00+00:00"
},
{
"alias": "os-quota-sets",
"description": "Quota management support.",
"links": [],
"name": "Quotas",
"updated": "2011-08-08T00:00:00+00:00"
},
{
"alias": "os-availability-zone",
"description": "Describe Availability Zones.",
"links": [],
"name": "AvailabilityZones",
"updated": "2013-06-27T00:00:00+00:00"
},
{
"alias": "os-volume-encryption-metadata",
"description": "Volume encryption metadata retrieval support.",
"links": [],
"name": "VolumeEncryptionMetadata",
"updated": "2013-07-10T00:00:00+00:00"
},
{
"alias": "backups",
"description": "Backups support.",
"links": [],
"name": "Backups",
"updated": "2012-12-12T00:00:00+00:00"
},
{
"alias": "os-snapshot-actions",
"description": "Enable snapshot manager actions.",
"links": [],
"name": "SnapshotActions",
"updated": "2013-07-16T00:00:00+00:00"
},
{
"alias": "os-volume-actions",
"description": "Enable volume actions.",
"links": [],
"name": "VolumeActions",
"updated": "2012-05-31T00:00:00+00:00"
},
{
"alias": "os-snapshot-manage",
"description": "Allows existing backend storage to be 'managed' by Cinder.",
"links": [],
"name": "SnapshotManage",
"updated": "2014-12-31T00:00:00+00:00"
},
{
"alias": "os-volume-unmanage",
"description": "Enable volume unmanage operation.",
"links": [],
"name": "VolumeUnmanage",
"updated": "2012-05-31T00:00:00+00:00"
},
{
"alias": "consistencygroups",
"description": "consistency groups support.",
"links": [],
"name": "Consistencygroups",
"updated": "2014-08-18T00:00:00+00:00"
},
{
"alias": "os-vol-host-attr",
"description": "Expose host as an attribute of a volume.",
"links": [],
"name": "VolumeHostAttribute",
"updated": "2011-11-03T00:00:00+00:00"
},
{
"alias": "encryption",
"description": "Encryption support for volume types.",
"links": [],
"name": "VolumeTypeEncryption",
"updated": "2013-07-01T00:00:00+00:00"
},
{
"alias": "os-vol-image-meta",
"description": "Show image metadata associated with the volume.",
"links": [],
"name": "VolumeImageMetadata",
"updated": "2012-12-07T00:00:00+00:00"
},
{
"alias": "os-types-manage",
"description": "Types manage support.",
"links": [],
"name": "TypesManage",
"updated": "2011-08-24T00:00:00+00:00"
},
{
"alias": "capabilities",
"description": "Capabilities support.",
"links": [],
"name": "Capabilities",
"updated": "2015-08-31T00:00:00+00:00"
},
{
"alias": "cgsnapshots",
"description": "cgsnapshots support.",
"links": [],
"name": "Cgsnapshots",
"updated": "2014-08-18T00:00:00+00:00"
},
{
"alias": "os-types-extra-specs",
"description": "Type extra specs support.",
"links": [],
"name": "TypesExtraSpecs",
"updated": "2011-08-24T00:00:00+00:00"
},
{
"alias": "os-used-limits",
"description": "Provide data on limited resources that are being used.",
"links": [],
"name": "UsedLimits",
"updated": "2013-10-03T00:00:00+00:00"
},
{
"alias": "os-vol-mig-status-attr",
"description": "Expose migration_status as an attribute of a volume.",
"links": [],
"name": "VolumeMigStatusAttribute",
"updated": "2013-08-08T00:00:00+00:00"
},
{
"alias": "os-volume-type-access",
"description": "Volume type access support.",
"links": [],
"name": "VolumeTypeAccess",
"updated": "2014-06-26T00:00:00Z"
},
{
"alias": "os-extended-services",
"description": "Extended services support.",
"links": [],
"name": "ExtendedServices",
"updated": "2014-01-10T00:00:00-00:00"
},
{
"alias": "os-extended-snapshot-attributes",
"description": "Extended SnapshotAttributes support.",
"links": [],
"name": "ExtendedSnapshotAttributes",
"updated": "2012-06-19T00:00:00+00:00"
},
{
"alias": "os-snapshot-unmanage",
"description": "Enable volume unmanage operation.",
"links": [],
"name": "SnapshotUnmanage",
"updated": "2014-12-31T00:00:00+00:00"
},
{
"alias": "qos-specs",
"description": "QoS specs support.",
"links": [],
"name": "Qos_specs_manage",
"updated": "2013-08-02T00:00:00+00:00"
},
{
"alias": "os-quota-class-sets",
"description": "Quota classes management support.",
"links": [],
"name": "QuotaClasses",
"updated": "2012-03-12T00:00:00+00:00"
},
{
"alias": "os-volume-transfer",
"description": "Volume transfer management support.",
"links": [],
"name": "VolumeTransfer",
"updated": "2013-05-29T00:00:00+00:00"
},
{
"alias": "os-volume-manage",
"description": "Allows existing backend storage to be 'managed' by Cinder.",
"links": [],
"name": "VolumeManage",
"updated": "2014-02-10T00:00:00+00:00"
},
{
"alias": "os-admin-actions",
"description": "Enable admin actions.",
"links": [],
"name": "AdminActions",
"updated": "2012-08-25T00:00:00+00:00"
},
{
"alias": "os-services",
"description": "Services support.",
"links": [],
"name": "Services",
"updated": "2012-10-28T00:00:00-00:00"
},
{
"alias": "scheduler-stats",
"description": "Scheduler stats support.",
"links": [],
"name": "Scheduler_stats",
"updated": "2014-09-07T00:00:00+00:00"
}
]
}

View File

@ -9,20 +9,20 @@
"type": "text/html" "type": "text/html"
}, },
{ {
"href": "http://23.253.248.171:8776/v3/", "href": "http://127.0.0.1:44895/v3/",
"rel": "self" "rel": "self"
} }
], ],
"media-types": [ "media-types": [
{ {
"base": "application/json", "base": "application/json",
"type": "application/vnd.openstack.volume+json;version=1" "type": "application/vnd.openstack.volume+json;version=3"
} }
], ],
"min_version": "3.0", "min_version": "3.0",
"status": "CURRENT", "status": "CURRENT",
"updated": "2016-02-08T12:20:21Z", "updated": "2018-07-17T00:00:00Z",
"version": "3.0" "version": "3.56"
} }
] ]
} }

View File

@ -0,0 +1,52 @@
{
"versions": [
{
"id": "v2.0",
"links": [
{
"href": "https://docs.openstack.org/",
"rel": "describedby",
"type": "text/html"
},
{
"href": "http://127.0.0.1:45697/v2/",
"rel": "self"
}
],
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.volume+json;version=2"
}
],
"min_version": "",
"status": "DEPRECATED",
"updated": "2017-02-25T12:00:00Z",
"version": ""
},
{
"id": "v3.0",
"links": [
{
"href": "https://docs.openstack.org/",
"rel": "describedby",
"type": "text/html"
},
{
"href": "http://127.0.0.1:45697/v3/",
"rel": "self"
}
],
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.volume+json;version=3"
}
],
"min_version": "3.0",
"status": "CURRENT",
"updated": "2018-07-17T00:00:00Z",
"version": "3.56"
}
]
}

View File

@ -51,7 +51,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/extensions-list-response.json .. literalinclude:: ./samples/extensions/extensions-list-response.json
:language: javascript :language: javascript

View File

@ -47,7 +47,7 @@ Request
Request Example Request Example
--------------- ---------------
.. literalinclude:: ./samples/volume-type-update-request.json .. literalinclude:: ./samples/volume_type/volume-type-update-request.json
:language: javascript :language: javascript
@ -66,7 +66,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-show-response.json .. literalinclude:: ./samples/volume_type/volume-type-show-response.json
:language: javascript :language: javascript
@ -98,7 +98,7 @@ Request
Request Example Request Example
--------------- ---------------
.. literalinclude:: ./samples/volume-type-extra-specs-create-update-request.json .. literalinclude:: ./samples/volume_type/volume-type-extra-specs-create-update-request.json
:language: javascript :language: javascript
@ -113,7 +113,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-extra-specs-create-update-response.json .. literalinclude:: ./samples/volume_type/volume-type-extra-specs-create-update-response.json
:language: javascript :language: javascript
@ -151,7 +151,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-all-extra-specs-show-response.json .. literalinclude:: ./samples/volume_type/volume-type-all-extra-specs-show-response.json
:language: javascript :language: javascript
@ -182,7 +182,7 @@ Request
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-specific-extra-specs-show-response.json .. literalinclude:: ./samples/volume_type/volume-type-specific-extra-specs-show-response.json
:language: javascript :language: javascript
@ -213,14 +213,14 @@ Request
Request Example Request Example
--------------- ---------------
.. literalinclude:: ./samples/volume-type-specific-extra-specs-update-request.json .. literalinclude:: ./samples/volume_type/volume-type-specific-extra-specs-update-request.json
:language: javascript :language: javascript
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-specific-extra-specs-update-response.json .. literalinclude:: ./samples/volume_type/volume-type-specific-extra-specs-update-response.json
:language: javascript :language: javascript
@ -290,7 +290,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-show-response.json .. literalinclude:: ./samples/volume_type/volume-type-show-response.json
:language: javascript :language: javascript
@ -331,7 +331,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-default-response.json .. literalinclude:: ./samples/volume_type/volume-type-default-response.json
:language: javascript :language: javascript
@ -404,7 +404,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-types-list-response.json .. literalinclude:: ./samples/volume_type/volume-types-list-response.json
:language: javascript :language: javascript
@ -438,7 +438,7 @@ Request
Request Example Request Example
--------------- ---------------
.. literalinclude:: ./samples/volume-type-create-request.json .. literalinclude:: ./samples/volume_type/volume-type-create-request.json
:language: javascript :language: javascript
@ -458,7 +458,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/volume-type-create-response.json .. literalinclude:: ./samples/volume_type/volume-type-create-response.json
:language: javascript :language: javascript
@ -505,7 +505,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/encryption-type-show-response.json .. literalinclude:: ./samples/volume_type/encryption-type-show-response.json
:language: javascript :language: javascript
@ -536,7 +536,7 @@ Request
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/encryption-type-specific-specs-show-response.json .. literalinclude:: ./samples/volume_type/encryption-type-specific-specs-show-response.json
:language: javascript :language: javascript
@ -596,7 +596,7 @@ Request
Request Example Request Example
--------------- ---------------
.. literalinclude:: ./samples/encryption-type-create-request.json .. literalinclude:: ./samples/volume_type/encryption-type-create-request.json
:language: javascript :language: javascript
@ -616,7 +616,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/encryption-type-create-response.json .. literalinclude:: ./samples/volume_type/encryption-type-create-response.json
:language: javascript :language: javascript
@ -652,7 +652,7 @@ Request
Request Example Request Example
--------------- ---------------
.. literalinclude:: ./samples/encryption-type-update-request.json .. literalinclude:: ./samples/volume_type/encryption-type-update-request.json
:language: javascript :language: javascript
@ -670,5 +670,5 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/encryption-type-update-response.json .. literalinclude:: ./samples/volume_type/encryption-type-update-response.json
:language: javascript :language: javascript

View File

@ -42,7 +42,7 @@ Response Parameters
Response Example Response Example
---------------- ----------------
.. literalinclude:: ./samples/version-show-response.json .. literalinclude:: ./samples/versions/version-show-response.json
:language: javascript :language: javascript

View File

@ -124,12 +124,17 @@ class TestOpenStackClient(object):
self.project_id = new_project_id self.project_id = new_project_id
self._authenticate(True) self._authenticate(True)
def api_request(self, relative_uri, check_response_status=None, **kwargs): def api_request(self, relative_uri, check_response_status=None,
strip_version=False, **kwargs):
auth_result = self._authenticate() auth_result = self._authenticate()
# NOTE(justinsb): httplib 'helpfully' converts headers to lower case # NOTE(justinsb): httplib 'helpfully' converts headers to lower case
base_uri = auth_result['x-server-management-url'] base_uri = auth_result['x-server-management-url']
if strip_version:
# cut out version number and tenant_id
base_uri = '/'.join(base_uri.split('/', 3)[:-1])
full_uri = '%s/%s' % (base_uri, relative_uri) full_uri = '%s/%s' % (base_uri, relative_uri)
headers = kwargs.setdefault('headers', {}) headers = kwargs.setdefault('headers', {})

View File

@ -0,0 +1,221 @@
{
"extensions": [
{
"alias": "os-hosts",
"description": "Admin-only host administration.",
"links": [],
"name": "Hosts",
"updated": "%(extension_update)s"
},
{
"alias": "os-vol-tenant-attr",
"description": "Expose the internal project_id as an attribute of a volume.",
"links": [],
"name": "VolumeTenantAttribute",
"updated": "%(extension_update)s"
},
{
"alias": "os-quota-sets",
"description": "Quota management support.",
"links": [],
"name": "Quotas",
"updated": "%(extension_update)s"
},
{
"alias": "os-availability-zone",
"description": "Describe Availability Zones.",
"links": [],
"name": "AvailabilityZones",
"updated": "%(extension_update)s"
},
{
"alias": "os-volume-encryption-metadata",
"description": "Volume encryption metadata retrieval support.",
"links": [],
"name": "VolumeEncryptionMetadata",
"updated": "%(extension_update)s"
},
{
"alias": "backups",
"description": "Backups support.",
"links": [],
"name": "Backups",
"updated": "%(extension_update)s"
},
{
"alias": "os-snapshot-actions",
"description": "Enable snapshot manager actions.",
"links": [],
"name": "SnapshotActions",
"updated": "%(extension_update)s"
},
{
"alias": "os-volume-actions",
"description": "Enable volume actions.",
"links": [],
"name": "VolumeActions",
"updated": "%(extension_update)s"
},
{
"alias": "os-snapshot-manage",
"description": "Allows existing backend storage to be 'managed' by Cinder.",
"links": [],
"name": "SnapshotManage",
"updated": "%(extension_update)s"
},
{
"alias": "os-volume-unmanage",
"description": "Enable volume unmanage operation.",
"links": [],
"name": "VolumeUnmanage",
"updated": "%(extension_update)s"
},
{
"alias": "consistencygroups",
"description": "consistency groups support.",
"links": [],
"name": "Consistencygroups",
"updated": "%(extension_update)s"
},
{
"alias": "os-vol-host-attr",
"description": "Expose host as an attribute of a volume.",
"links": [],
"name": "VolumeHostAttribute",
"updated": "%(extension_update)s"
},
{
"alias": "encryption",
"description": "Encryption support for volume types.",
"links": [],
"name": "VolumeTypeEncryption",
"updated": "%(extension_update)s"
},
{
"alias": "os-vol-image-meta",
"description": "Show image metadata associated with the volume.",
"links": [],
"name": "VolumeImageMetadata",
"updated": "%(extension_update)s"
},
{
"alias": "os-types-manage",
"description": "Types manage support.",
"links": [],
"name": "TypesManage",
"updated": "%(extension_update)s"
},
{
"alias": "capabilities",
"description": "Capabilities support.",
"links": [],
"name": "Capabilities",
"updated": "%(extension_update)s"
},
{
"alias": "cgsnapshots",
"description": "cgsnapshots support.",
"links": [],
"name": "Cgsnapshots",
"updated": "%(extension_update)s"
},
{
"alias": "os-types-extra-specs",
"description": "Type extra specs support.",
"links": [],
"name": "TypesExtraSpecs",
"updated": "%(extension_update)s"
},
{
"alias": "os-used-limits",
"description": "Provide data on limited resources that are being used.",
"links": [],
"name": "UsedLimits",
"updated": "%(extension_update)s"
},
{
"alias": "os-vol-mig-status-attr",
"description": "Expose migration_status as an attribute of a volume.",
"links": [],
"name": "VolumeMigStatusAttribute",
"updated": "%(extension_update)s"
},
{
"alias": "os-volume-type-access",
"description": "Volume type access support.",
"links": [],
"name": "VolumeTypeAccess",
"updated": "%(isotime)s"
},
{
"alias": "os-extended-services",
"description": "Extended services support.",
"links": [],
"name": "ExtendedServices",
"updated": "%(extension_update)s"
},
{
"alias": "os-extended-snapshot-attributes",
"description": "Extended SnapshotAttributes support.",
"links": [],
"name": "ExtendedSnapshotAttributes",
"updated": "%(extension_update)s"
},
{
"alias": "os-snapshot-unmanage",
"description": "Enable volume unmanage operation.",
"links": [],
"name": "SnapshotUnmanage",
"updated": "%(extension_update)s"
},
{
"alias": "qos-specs",
"description": "QoS specs support.",
"links": [],
"name": "Qos_specs_manage",
"updated": "%(extension_update)s"
},
{
"alias": "os-quota-class-sets",
"description": "Quota classes management support.",
"links": [],
"name": "QuotaClasses",
"updated": "%(extension_update)s"
},
{
"alias": "os-volume-transfer",
"description": "Volume transfer management support.",
"links": [],
"name": "VolumeTransfer",
"updated": "%(extension_update)s"
},
{
"alias": "os-volume-manage",
"description": "Allows existing backend storage to be 'managed' by Cinder.",
"links": [],
"name": "VolumeManage",
"updated": "%(extension_update)s"
},
{
"alias": "os-admin-actions",
"description": "Enable admin actions.",
"links": [],
"name": "AdminActions",
"updated": "%(extension_update)s"
},
{
"alias": "os-services",
"description": "Services support.",
"links": [],
"name": "Services",
"updated": "%(extension_update)s"
},
{
"alias": "scheduler-stats",
"description": "Scheduler stats support.",
"links": [],
"name": "Scheduler_stats",
"updated": "%(extension_update)s"
}
]
}

View File

@ -0,0 +1,28 @@
{
"versions": [
{
"id": "v3.0",
"links": [
{
"href": "https://docs.openstack.org/",
"rel": "describedby",
"type": "text/html"
},
{
"href": "%(host)s/v3/",
"rel": "self"
}
],
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.volume+json;version=3"
}
],
"min_version": "3.0",
"status": "CURRENT",
"updated": "%(isotime)s",
"version": "%(max_api_version)s"
}
]
}

View File

@ -1,8 +1,8 @@
{ {
"versions": [ "versions": [
{ {
"status": "SUPPORTED", "status": "DEPRECATED",
"updated": "2014-06-28T12:20:21Z", "updated": "%(isotime)s",
"links": [ "links": [
{ {
"href": "https://docs.openstack.org/", "href": "https://docs.openstack.org/",
@ -10,7 +10,7 @@
"rel": "describedby" "rel": "describedby"
}, },
{ {
"href": "http://10.0.2.15:8776/v2/", "href": "%(host)s/v2/",
"rel": "self" "rel": "self"
} }
], ],
@ -26,7 +26,7 @@
}, },
{ {
"status": "CURRENT", "status": "CURRENT",
"updated": "2016-02-08T12:20:21Z", "updated": "%(isotime)s",
"links": [ "links": [
{ {
"href": "https://docs.openstack.org/", "href": "https://docs.openstack.org/",
@ -34,12 +34,12 @@
"rel": "describedby" "rel": "describedby"
}, },
{ {
"href": "http://10.0.2.15:8776/v3/", "href": "%(host)s/v3/",
"rel": "self" "rel": "self"
} }
], ],
"min_version": "3.0", "min_version": "3.0",
"version": "{Current_Max_Version}", "version": "%(max_api_version)s",
"media-types": [ "media-types": [
{ {
"base": "application/json", "base": "application/json",

View File

@ -0,0 +1,29 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cinder.api.openstack import api_version_request
from cinder.tests.functional import api_samples_test_base
class ExtensionsSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
sample_dir = "extensions"
def setUp(self):
super(ExtensionsSampleJsonTest, self).setUp()
self.subs = {
'max_api_version': api_version_request._MAX_API_VERSION}
def test_extensions(self):
response = self._do_get('extensions')
self._verify_response('extensions-list-response',
self.subs,
response, 200, update_links=False)

View File

@ -0,0 +1,35 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cinder.api.openstack import api_version_request
from cinder.tests.functional import api_samples_test_base
class VersionsSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
sample_dir = "versions"
def setUp(self):
super(VersionsSampleJsonTest, self).setUp()
self.subs = {
'max_api_version': api_version_request._MAX_API_VERSION}
def test_versions_get_all(self):
response = self.api.api_request('', strip_version=True)
self._verify_response('versions-response',
self.subs,
response, 300, update_links=False)
def test_versions_get_v3(self):
response = self.api.api_request('v3/', strip_version=True)
self._verify_response('version-show-response',
self.subs,
response, 200, update_links=False)

View File

@ -19,7 +19,7 @@ CONF = cfg.CONF
class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase): class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
sample_dir = "volumes" sample_dir = "volume_type"
def setUp(self): def setUp(self):
super(VolumeTypesSampleJsonTest, self).setUp() super(VolumeTypesSampleJsonTest, self).setUp()

View File

@ -100,6 +100,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
def _get_sample_path(cls, name, dirname, suffix='', api_version=None): def _get_sample_path(cls, name, dirname, suffix='', api_version=None):
parts = [dirname] parts = [dirname]
parts.append('samples') parts.append('samples')
parts.append(cls.sample_dir)
if api_version: if api_version:
parts.append('v' + api_version) parts.append('v' + api_version)
parts.append(name + ".json" + suffix) parts.append(name + ".json" + suffix)
@ -400,6 +401,8 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
text = r'(\\"|[^"])*' text = r'(\\"|[^"])*'
isotime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}Z' isotime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}Z'
strtime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}\.\d{6}' strtime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}\.\d{6}'
extension_update = (
'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}')
strtime_url_re = ('\d{4}-[0,1]\d-[0-3]\d' strtime_url_re = ('\d{4}-[0,1]\d-[0-3]\d'
'\+\d{2}\%3A\d{2}\%3A\d{2}\.\d{6}') '\+\d{2}\%3A\d{2}\%3A\d{2}\.\d{6}')
@ -415,7 +418,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
'-[0-9a-f]{4}-[0-9a-f]{12}', '-[0-9a-f]{4}-[0-9a-f]{12}',
'request_id': 'req-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}' 'request_id': 'req-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}'
'-[0-9a-f]{4}-[0-9a-f]{12}', '-[0-9a-f]{4}-[0-9a-f]{12}',
'host': self._get_host(), 'host': 'https?://[0-9]+(?:\.[0-9]+){3}:[0-9]+',
'host_name': r'\w+', 'host_name': r'\w+',
'glance_host': self._get_glance_host(), 'glance_host': self._get_glance_host(),
'os-vol-host-attr:host': self.volume.host, 'os-vol-host-attr:host': self.volume.host,
@ -426,7 +429,8 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
'volume_endpoint': self._get_volume_endpoint(), 'volume_endpoint': self._get_volume_endpoint(),
'versioned_volume_endpoint': self._get_versioned_volume_endpoint(), 'versioned_volume_endpoint': self._get_versioned_volume_endpoint(),
'name': text, 'name': text,
'description': text 'description': text,
'extension_update': extension_update
} }
def _get_volume_endpoint(self): def _get_volume_endpoint(self):