blob: affed6bf2175878766281c8da16ed83d9001e0fc [file] [log] [blame]
lkuchlanb6baff82016-06-01 11:55:47 +03001# Copyright 2016 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import operator
17
18from tempest.api.volume import base
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080019from tempest.lib import decorators
lkuchlanb6baff82016-06-01 11:55:47 +030020
21
Ken'ichi Ohmichie8afb8c2017-03-27 11:25:37 -070022class BackendsCapabilitiesAdminTestsJSON(base.BaseVolumeAdminTest):
lkuchlanb6baff82016-06-01 11:55:47 +030023
24 CAPABILITIES = ('namespace',
25 'vendor_name',
26 'volume_backend_name',
27 'pool_name',
28 'driver_version',
29 'storage_protocol',
30 'display_name',
31 'description',
32 'visibility',
33 'properties')
34
35 @classmethod
36 def resource_setup(cls):
Ken'ichi Ohmichie8afb8c2017-03-27 11:25:37 -070037 super(BackendsCapabilitiesAdminTestsJSON, cls).resource_setup()
lkuchlanb6baff82016-06-01 11:55:47 +030038 # Get host list, formation: host@backend-name
39 cls.hosts = [
40 pool['name'] for pool in
lkuchlan7bba16c2016-09-04 12:36:04 +030041 cls.admin_scheduler_stats_client.list_pools()['pools']
lkuchlanb6baff82016-06-01 11:55:47 +030042 ]
43
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080044 @decorators.idempotent_id('3750af44-5ea2-4cd4-bc3e-56e7e6caf854')
lkuchlanb6baff82016-06-01 11:55:47 +030045 def test_get_capabilities_backend(self):
46 # Test backend properties
lkuchlan7bba16c2016-09-04 12:36:04 +030047 backend = self.admin_capabilities_client.show_backend_capabilities(
lkuchlanb6baff82016-06-01 11:55:47 +030048 self.hosts[0])
49
50 # Verify getting capabilities parameters from a backend
51 for key in self.CAPABILITIES:
52 self.assertIn(key, backend)
53
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080054 @decorators.idempotent_id('a9035743-d46a-47c5-9cb7-3c80ea16dea0')
lkuchlanb6baff82016-06-01 11:55:47 +030055 def test_compare_volume_stats_values(self):
56 # Test values comparison between show_backend_capabilities
57 # to show_pools
58 VOLUME_STATS = ('vendor_name',
59 'volume_backend_name',
60 'storage_protocol')
61
62 # Get list backend capabilities using show_pools
63 cinder_pools = [
64 pool['capabilities'] for pool in
lkuchlan7bba16c2016-09-04 12:36:04 +030065 self.admin_scheduler_stats_client.list_pools(detail=True)['pools']
lkuchlanb6baff82016-06-01 11:55:47 +030066 ]
67
68 # Get list backends capabilities using show_backend_capabilities
69 capabilities = [
lkuchlan7bba16c2016-09-04 12:36:04 +030070 self.admin_capabilities_client.show_backend_capabilities(
lkuchlanb6baff82016-06-01 11:55:47 +030071 host=host) for host in self.hosts
72 ]
73
74 # Returns a tuple of VOLUME_STATS values
Dmitriy Rabotjagov6a6fe592018-09-19 11:58:29 +030075 expected_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
76 cinder_pools)))
77 observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
78 capabilities)))
lkuchlanb6baff82016-06-01 11:55:47 +030079 self.assertEqual(expected_list, observed_list)