lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 1 | # 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 | |
| 16 | import operator |
| 17 | |
| 18 | from tempest.api.volume import base |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 19 | from tempest.lib import decorators |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 20 | |
| 21 | |
Ken'ichi Ohmichi | e8afb8c | 2017-03-27 11:25:37 -0700 | [diff] [blame] | 22 | class BackendsCapabilitiesAdminTestsJSON(base.BaseVolumeAdminTest): |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 23 | |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 24 | @classmethod |
| 25 | def resource_setup(cls): |
Ken'ichi Ohmichi | e8afb8c | 2017-03-27 11:25:37 -0700 | [diff] [blame] | 26 | super(BackendsCapabilitiesAdminTestsJSON, cls).resource_setup() |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 27 | # Get host list, formation: host@backend-name |
| 28 | cls.hosts = [ |
| 29 | pool['name'] for pool in |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 30 | cls.admin_scheduler_stats_client.list_pools()['pools'] |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 31 | ] |
| 32 | |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 33 | @decorators.idempotent_id('3750af44-5ea2-4cd4-bc3e-56e7e6caf854') |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 34 | def test_get_capabilities_backend(self): |
| 35 | # Test backend properties |
zhufl | d4f40a4 | 2018-09-27 11:12:33 +0800 | [diff] [blame] | 36 | # Check response schema |
| 37 | self.admin_capabilities_client.show_backend_capabilities(self.hosts[0]) |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 38 | |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 39 | @decorators.idempotent_id('a9035743-d46a-47c5-9cb7-3c80ea16dea0') |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 40 | def test_compare_volume_stats_values(self): |
| 41 | # Test values comparison between show_backend_capabilities |
| 42 | # to show_pools |
| 43 | VOLUME_STATS = ('vendor_name', |
| 44 | 'volume_backend_name', |
| 45 | 'storage_protocol') |
| 46 | |
| 47 | # Get list backend capabilities using show_pools |
| 48 | cinder_pools = [ |
| 49 | pool['capabilities'] for pool in |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 50 | self.admin_scheduler_stats_client.list_pools(detail=True)['pools'] |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 51 | ] |
| 52 | |
| 53 | # Get list backends capabilities using show_backend_capabilities |
| 54 | capabilities = [ |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 55 | self.admin_capabilities_client.show_backend_capabilities( |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 56 | host=host) for host in self.hosts |
| 57 | ] |
| 58 | |
| 59 | # Returns a tuple of VOLUME_STATS values |
Dmitriy Rabotjagov | 6a6fe59 | 2018-09-19 11:58:29 +0300 | [diff] [blame] | 60 | expected_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS), |
| 61 | cinder_pools))) |
| 62 | observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS), |
| 63 | capabilities))) |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 64 | self.assertEqual(expected_list, observed_list) |