blob: 83c27e1a33beeba0ddba3c03235bc58e3e303891 [file] [log] [blame]
Nayna Patel4a5024c2013-11-18 07:08:23 +00001# Copyright 2013 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
16from tempest.api.volume import base
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080017from tempest.lib import decorators
Nayna Patel4a5024c2013-11-18 07:08:23 +000018
19
Ken'ichi Ohmichie8afb8c2017-03-27 11:25:37 -070020class VolumeHostsAdminTestsJSON(base.BaseVolumeAdminTest):
Nayna Patel4a5024c2013-11-18 07:08:23 +000021
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080022 @decorators.idempotent_id('d5f3efa2-6684-4190-9ced-1c2f526352ad')
Nayna Patel4a5024c2013-11-18 07:08:23 +000023 def test_list_hosts(self):
bkopilov62d21752016-06-08 10:16:11 +030024 hosts = self.admin_hosts_client.list_hosts()['hosts']
jeremy.zhang44c2e0f2017-04-26 20:52:34 +080025 self.assertGreaterEqual(len(hosts), 2,
26 "The count of volume hosts is < 2, "
27 "response of list hosts is: %s" % hosts)
28
jeremy.zhang44c2e0f2017-04-26 20:52:34 +080029 @decorators.idempotent_id('21168d57-b373-4b71-a3ac-f2c88f0c5d31')
30 def test_show_host(self):
31 hosts = self.admin_hosts_client.list_hosts()['hosts']
32 self.assertGreaterEqual(len(hosts), 2,
33 "The count of volume hosts is < 2, "
34 "response of list hosts is: %s" % hosts)
35
jeremy.zhangaf55ae32017-08-18 11:36:46 +080036 # Note(jeremyZ): The show host API is to show volume usage info on the
37 # specified cinder-volume host. If the host does not run cinder-volume
38 # service, or the cinder-volume service is disabled on the host, the
39 # show host API should fail (return code: 404). The cinder-volume host
40 # is presented in format: <host-name>@driver-name.
41 c_vol_hosts = [host['host_name'] for host in hosts
Federico Ressi2d6bcaa2018-04-11 12:37:36 +020042 if (host['service'] == 'cinder-volume' and
43 host['service-state'] == 'enabled')]
jeremy.zhangaf55ae32017-08-18 11:36:46 +080044 self.assertNotEmpty(c_vol_hosts,
45 "No available cinder-volume host is found, "
46 "all hosts that found are: %s" % hosts)
jeremy.zhang44c2e0f2017-04-26 20:52:34 +080047
jeremy.zhangaf55ae32017-08-18 11:36:46 +080048 # Check each cinder-volume host.
jeremy.zhangaf55ae32017-08-18 11:36:46 +080049 for host in c_vol_hosts:
50 host_details = self.admin_hosts_client.show_host(host)['host']
51 self.assertNotEmpty(host_details)