Nayna Patel | 4a5024c | 2013-11-18 07:08:23 +0000 | [diff] [blame] | 1 | # 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 | |
| 16 | from tempest.api.volume import base |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 17 | from tempest.lib import decorators |
Nayna Patel | 4a5024c | 2013-11-18 07:08:23 +0000 | [diff] [blame] | 18 | |
| 19 | |
Ken'ichi Ohmichi | e8afb8c | 2017-03-27 11:25:37 -0700 | [diff] [blame] | 20 | class VolumeHostsAdminTestsJSON(base.BaseVolumeAdminTest): |
Nayna Patel | 4a5024c | 2013-11-18 07:08:23 +0000 | [diff] [blame] | 21 | |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 22 | @decorators.idempotent_id('d5f3efa2-6684-4190-9ced-1c2f526352ad') |
Nayna Patel | 4a5024c | 2013-11-18 07:08:23 +0000 | [diff] [blame] | 23 | def test_list_hosts(self): |
bkopilov | 62d2175 | 2016-06-08 10:16:11 +0300 | [diff] [blame] | 24 | hosts = self.admin_hosts_client.list_hosts()['hosts'] |
jeremy.zhang | 44c2e0f | 2017-04-26 20:52:34 +0800 | [diff] [blame] | 25 | self.assertGreaterEqual(len(hosts), 2, |
| 26 | "The count of volume hosts is < 2, " |
| 27 | "response of list hosts is: %s" % hosts) |
| 28 | |
jeremy.zhang | 44c2e0f | 2017-04-26 20:52:34 +0800 | [diff] [blame] | 29 | @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.zhang | af55ae3 | 2017-08-18 11:36:46 +0800 | [diff] [blame] | 36 | # 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 Ressi | 2d6bcaa | 2018-04-11 12:37:36 +0200 | [diff] [blame] | 42 | if (host['service'] == 'cinder-volume' and |
| 43 | host['service-state'] == 'enabled')] |
jeremy.zhang | af55ae3 | 2017-08-18 11:36:46 +0800 | [diff] [blame] | 44 | self.assertNotEmpty(c_vol_hosts, |
| 45 | "No available cinder-volume host is found, " |
| 46 | "all hosts that found are: %s" % hosts) |
jeremy.zhang | 44c2e0f | 2017-04-26 20:52:34 +0800 | [diff] [blame] | 47 | |
jeremy.zhang | af55ae3 | 2017-08-18 11:36:46 +0800 | [diff] [blame] | 48 | # Check each cinder-volume host. |
jeremy.zhang | af55ae3 | 2017-08-18 11:36:46 +0800 | [diff] [blame] | 49 | for host in c_vol_hosts: |
| 50 | host_details = self.admin_hosts_client.show_host(host)['host'] |
| 51 | self.assertNotEmpty(host_details) |