diff --git a/tempest/api/volume/admin/test_backends_capabilities.py b/tempest/api/volume/admin/test_backends_capabilities.py new file mode 100644 index 0000000000..8a2185356d --- /dev/null +++ b/tempest/api/volume/admin/test_backends_capabilities.py @@ -0,0 +1,79 @@ +# Copyright 2016 OpenStack Foundation +# All Rights Reserved. +# +# 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. + +import operator + +from tempest.api.volume import base +from tempest import test + + +class BackendsCapabilitiesAdminV2TestsJSON(base.BaseVolumeAdminTest): + + CAPABILITIES = ('namespace', + 'vendor_name', + 'volume_backend_name', + 'pool_name', + 'driver_version', + 'storage_protocol', + 'display_name', + 'description', + 'visibility', + 'properties') + + @classmethod + def resource_setup(cls): + super(BackendsCapabilitiesAdminV2TestsJSON, cls).resource_setup() + # Get host list, formation: host@backend-name + cls.hosts = [ + pool['name'] for pool in + cls.admin_volume_client.show_pools()['pools'] + ] + + @test.idempotent_id('3750af44-5ea2-4cd4-bc3e-56e7e6caf854') + def test_get_capabilities_backend(self): + # Test backend properties + backend = self.admin_volume_client.show_backend_capabilities( + self.hosts[0]) + + # Verify getting capabilities parameters from a backend + for key in self.CAPABILITIES: + self.assertIn(key, backend) + + @test.idempotent_id('a9035743-d46a-47c5-9cb7-3c80ea16dea0') + def test_compare_volume_stats_values(self): + # Test values comparison between show_backend_capabilities + # to show_pools + VOLUME_STATS = ('vendor_name', + 'volume_backend_name', + 'storage_protocol') + + # Get list backend capabilities using show_pools + cinder_pools = [ + pool['capabilities'] for pool in + self.admin_volume_client.show_pools(detail=True)['pools'] + ] + + # Get list backends capabilities using show_backend_capabilities + capabilities = [ + self.admin_volume_client.show_backend_capabilities( + host=host) for host in self.hosts + ] + + # Returns a tuple of VOLUME_STATS values + expected_list = map(operator.itemgetter(*VOLUME_STATS), + cinder_pools) + observed_list = map(operator.itemgetter(*VOLUME_STATS), + capabilities) + self.assertEqual(expected_list, observed_list) diff --git a/tempest/services/volume/base/base_volumes_client.py b/tempest/services/volume/base/base_volumes_client.py index d694c5350e..c2e2b92567 100755 --- a/tempest/services/volume/base/base_volumes_client.py +++ b/tempest/services/volume/base/base_volumes_client.py @@ -63,7 +63,11 @@ class BaseVolumesClient(rest_client.RestClient): return rest_client.ResponseBody(resp, body) def show_pools(self, detail=False): - # List all the volumes pools (hosts) + """List all the volumes pools (hosts). + + Output params: see http://developer.openstack.org/ + api-ref-blockstorage-v2.html#listPools + """ url = 'scheduler-stats/get_pools' if detail: url += '?detail=True' @@ -73,6 +77,19 @@ class BaseVolumesClient(rest_client.RestClient): self.expected_success(200, resp.status) return rest_client.ResponseBody(resp, body) + def show_backend_capabilities(self, host): + """Shows capabilities for a storage back end. + + Output params: see http://developer.openstack.org/ + api-ref-blockstorage-v2.html + #showBackendCapabilities + """ + url = 'capabilities/%s' % host + resp, body = self.get(url) + body = json.loads(body) + self.expected_success(200, resp.status) + return rest_client.ResponseBody(resp, body) + def show_volume(self, volume_id): """Returns the details of a single volume.""" url = "volumes/%s" % str(volume_id)