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 | |
| 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 Ohmichi | e8afb8c | 2017-03-27 11:25:37 -0700 | [diff] [blame] | 37 | super(BackendsCapabilitiesAdminTestsJSON, cls).resource_setup() |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 38 | # Get host list, formation: host@backend-name |
| 39 | cls.hosts = [ |
| 40 | pool['name'] for pool in |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 41 | cls.admin_scheduler_stats_client.list_pools()['pools'] |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 42 | ] |
| 43 | |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 44 | @decorators.idempotent_id('3750af44-5ea2-4cd4-bc3e-56e7e6caf854') |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 45 | def test_get_capabilities_backend(self): |
| 46 | # Test backend properties |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 47 | backend = self.admin_capabilities_client.show_backend_capabilities( |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 48 | 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 Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 54 | @decorators.idempotent_id('a9035743-d46a-47c5-9cb7-3c80ea16dea0') |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 55 | 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 |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 65 | self.admin_scheduler_stats_client.list_pools(detail=True)['pools'] |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 66 | ] |
| 67 | |
| 68 | # Get list backends capabilities using show_backend_capabilities |
| 69 | capabilities = [ |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 70 | self.admin_capabilities_client.show_backend_capabilities( |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 71 | host=host) for host in self.hosts |
| 72 | ] |
| 73 | |
| 74 | # Returns a tuple of VOLUME_STATS values |
Dmitriy Rabotjagov | 6a6fe59 | 2018-09-19 11:58:29 +0300 | [diff] [blame] | 75 | expected_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS), |
| 76 | cinder_pools))) |
| 77 | observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS), |
| 78 | capabilities))) |
lkuchlan | b6baff8 | 2016-06-01 11:55:47 +0300 | [diff] [blame] | 79 | self.assertEqual(expected_list, observed_list) |