blob: 13517040a1043565f54af5ed0a5cc6b730453141 [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
lkuchlanb6baff82016-06-01 11:55:47 +030024 @classmethod
25 def resource_setup(cls):
Ken'ichi Ohmichie8afb8c2017-03-27 11:25:37 -070026 super(BackendsCapabilitiesAdminTestsJSON, cls).resource_setup()
lkuchlanb6baff82016-06-01 11:55:47 +030027 # Get host list, formation: host@backend-name
28 cls.hosts = [
29 pool['name'] for pool in
lkuchlan7bba16c2016-09-04 12:36:04 +030030 cls.admin_scheduler_stats_client.list_pools()['pools']
lkuchlanb6baff82016-06-01 11:55:47 +030031 ]
32
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080033 @decorators.idempotent_id('3750af44-5ea2-4cd4-bc3e-56e7e6caf854')
lkuchlanb6baff82016-06-01 11:55:47 +030034 def test_get_capabilities_backend(self):
35 # Test backend properties
zhufld4f40a42018-09-27 11:12:33 +080036 # Check response schema
37 self.admin_capabilities_client.show_backend_capabilities(self.hosts[0])
lkuchlanb6baff82016-06-01 11:55:47 +030038
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080039 @decorators.idempotent_id('a9035743-d46a-47c5-9cb7-3c80ea16dea0')
lkuchlanb6baff82016-06-01 11:55:47 +030040 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
lkuchlan7bba16c2016-09-04 12:36:04 +030050 self.admin_scheduler_stats_client.list_pools(detail=True)['pools']
lkuchlanb6baff82016-06-01 11:55:47 +030051 ]
52
53 # Get list backends capabilities using show_backend_capabilities
54 capabilities = [
lkuchlan7bba16c2016-09-04 12:36:04 +030055 self.admin_capabilities_client.show_backend_capabilities(
lkuchlanb6baff82016-06-01 11:55:47 +030056 host=host) for host in self.hosts
57 ]
58
59 # Returns a tuple of VOLUME_STATS values
Dmitriy Rabotjagov6a6fe592018-09-19 11:58:29 +030060 expected_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
61 cinder_pools)))
62 observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
63 capabilities)))
lkuchlanb6baff82016-06-01 11:55:47 +030064 self.assertEqual(expected_list, observed_list)