Merge "Address bug 1839794 on the Volume show version client"
This commit is contained in:
commit
e227022df9
|
@ -27,3 +27,15 @@ class VersionsTest(base.BaseVolumeTest):
|
||||||
# with JSON-Schema validation. It is enough to just call
|
# with JSON-Schema validation. It is enough to just call
|
||||||
# the API here.
|
# the API here.
|
||||||
self.versions_client.list_versions()
|
self.versions_client.list_versions()
|
||||||
|
|
||||||
|
@decorators.idempotent_id('7f755ae2-caa9-4049-988c-331d8f7a579f')
|
||||||
|
def test_show_version(self):
|
||||||
|
# NOTE: The version data is checked on service client side
|
||||||
|
# with JSON-Schema validation. So we will loop through each
|
||||||
|
# version and call show version.
|
||||||
|
versions = self.versions_client.list_versions()['versions']
|
||||||
|
for version_dict in versions:
|
||||||
|
version = version_dict['id']
|
||||||
|
major_version = version.split('.')[0]
|
||||||
|
response = self.versions_client.show_version(major_version)
|
||||||
|
self.assertEqual(version, response['versions'][0]['id'])
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from six.moves.urllib.parse import urljoin
|
||||||
|
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
|
|
||||||
from tempest.lib.api_schema.response.volume import versions as schema
|
from tempest.lib.api_schema.response.volume import versions as schema
|
||||||
|
@ -50,13 +51,18 @@ class VersionsClient(base_client.BaseClient):
|
||||||
def show_version(self, version):
|
def show_version(self, version):
|
||||||
"""Show API version details
|
"""Show API version details
|
||||||
|
|
||||||
|
Use raw_request in order to have access to the endpoints minus
|
||||||
|
version and project in order to add version only back.
|
||||||
|
|
||||||
For a full list of available parameters, please refer to the official
|
For a full list of available parameters, please refer to the official
|
||||||
API reference:
|
API reference:
|
||||||
https://docs.openstack.org/api-ref/block-storage/v3/#show-api-v3-details
|
https://docs.openstack.org/api-ref/block-storage/v3/#show-api-v3-details
|
||||||
"""
|
"""
|
||||||
|
|
||||||
version_url = os.path.join(self._get_base_version_url(), version)
|
version_url = urljoin(self._get_base_version_url(), version + '/')
|
||||||
resp, body = self.get(version_url)
|
resp, body = self.raw_request(version_url, 'GET',
|
||||||
|
{'X-Auth-Token': self.token})
|
||||||
|
self._error_checker(resp, body)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.validate_response(schema.volume_api_version_details, resp, body)
|
self.validate_response(schema.volume_api_version_details, resp, body)
|
||||||
return rest_client.ResponseBody(resp, body)
|
return rest_client.ResponseBody(resp, body)
|
||||||
|
|
|
@ -97,6 +97,14 @@ class TestVersionsClient(base.BaseServiceTest):
|
||||||
'volume',
|
'volume',
|
||||||
'regionOne')
|
'regionOne')
|
||||||
|
|
||||||
|
def _test_get_base_version_url(self, url, expected_base_url):
|
||||||
|
fake_auth = fake_auth_provider.FakeAuthProvider(fake_base_url=url)
|
||||||
|
client = versions_client.VersionsClient(fake_auth,
|
||||||
|
'volume',
|
||||||
|
'regionOne')
|
||||||
|
self.assertEqual(expected_base_url,
|
||||||
|
client._get_base_version_url())
|
||||||
|
|
||||||
def _test_list_versions(self, bytes_body=False):
|
def _test_list_versions(self, bytes_body=False):
|
||||||
self.check_service_client_function(
|
self.check_service_client_function(
|
||||||
self.client.list_versions,
|
self.client.list_versions,
|
||||||
|
@ -105,22 +113,30 @@ class TestVersionsClient(base.BaseServiceTest):
|
||||||
bytes_body,
|
bytes_body,
|
||||||
300)
|
300)
|
||||||
|
|
||||||
|
def _test_show_version(self, version, bytes_body=False):
|
||||||
|
self.check_service_client_function(
|
||||||
|
self.client.show_version,
|
||||||
|
'tempest.lib.common.rest_client.RestClient.raw_request',
|
||||||
|
self.FAKE_VERSION_DETAILS,
|
||||||
|
bytes_body,
|
||||||
|
200, version=version)
|
||||||
|
|
||||||
def test_list_versions_with_str_body(self):
|
def test_list_versions_with_str_body(self):
|
||||||
self._test_list_versions()
|
self._test_list_versions()
|
||||||
|
|
||||||
def test_list_versions_with_bytes_body(self):
|
def test_list_versions_with_bytes_body(self):
|
||||||
self._test_list_versions(bytes_body=True)
|
self._test_list_versions(bytes_body=True)
|
||||||
|
|
||||||
def _test_show_version(self, bytes_body=False):
|
|
||||||
self.check_service_client_function(
|
|
||||||
self.client.show_version,
|
|
||||||
'tempest.lib.common.rest_client.RestClient.get',
|
|
||||||
self.FAKE_VERSION_DETAILS,
|
|
||||||
bytes_body,
|
|
||||||
200, version='v3')
|
|
||||||
|
|
||||||
def test_show_version_details_with_str_body(self):
|
def test_show_version_details_with_str_body(self):
|
||||||
self._test_show_version()
|
self._test_show_version('v3')
|
||||||
|
|
||||||
def test_show_version_details_with_bytes_body(self):
|
def test_show_version_details_with_bytes_body(self):
|
||||||
self._test_show_version(bytes_body=True)
|
self._test_show_version('v3', bytes_body=True)
|
||||||
|
|
||||||
|
def test_get_base_version_url_app_name(self):
|
||||||
|
self._test_get_base_version_url('https://bar.org/volume/v1/123',
|
||||||
|
'https://bar.org/volume/')
|
||||||
|
self._test_get_base_version_url('https://bar.org/volume/v2/123',
|
||||||
|
'https://bar.org/volume/')
|
||||||
|
self._test_get_base_version_url('https://bar.org/volume/v3/123',
|
||||||
|
'https://bar.org/volume/')
|
||||||
|
|
Loading…
Reference in New Issue