Merge "Change multi-backend configuration to a list"
This commit is contained in:
commit
9d843d9c30
@ -11,7 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
import six
|
||||||
from tempest.api.volume import base
|
from tempest.api.volume import base
|
||||||
from tempest.common.utils import data_utils
|
from tempest.common.utils import data_utils
|
||||||
from tempest import config
|
from tempest import config
|
||||||
@ -34,9 +34,14 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def resource_setup(cls):
|
def resource_setup(cls):
|
||||||
super(VolumeMultiBackendV2Test, cls).resource_setup()
|
super(VolumeMultiBackendV2Test, cls).resource_setup()
|
||||||
|
# support 2 backends names, deprecated_for_removal.
|
||||||
cls.backend1_name = CONF.volume.backend1_name
|
# keep support 2 backend names, in case they are not empty
|
||||||
cls.backend2_name = CONF.volume.backend2_name
|
if CONF.volume.backend1_name and CONF.volume.backend2_name:
|
||||||
|
cls.backend_names = {CONF.volume.backend1_name,
|
||||||
|
CONF.volume.backend2_name}
|
||||||
|
else:
|
||||||
|
# read backend name from a list .
|
||||||
|
cls.backend_names = set(CONF.volume.backend_names)
|
||||||
|
|
||||||
cls.name_field = cls.special_fields['name_field']
|
cls.name_field = cls.special_fields['name_field']
|
||||||
cls.volume_type_id_list = []
|
cls.volume_type_id_list = []
|
||||||
@ -44,15 +49,15 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
|
|||||||
cls.volume_id_list_without_prefix = []
|
cls.volume_id_list_without_prefix = []
|
||||||
|
|
||||||
# Volume/Type creation (uses volume_backend_name)
|
# Volume/Type creation (uses volume_backend_name)
|
||||||
cls._create_type_and_volume(cls.backend1_name, False)
|
# It is not allowed to create the same backend name twice
|
||||||
# Volume/Type creation (uses capabilities:volume_backend_name)
|
if len(cls.backend_names) < 2:
|
||||||
cls._create_type_and_volume(cls.backend1_name, True)
|
raise cls.skipException("Requires at least two different "
|
||||||
|
"backend names")
|
||||||
if cls.backend1_name != cls.backend2_name:
|
for backend_name in cls.backend_names:
|
||||||
# Volume/Type creation (uses backend2_name)
|
# Volume/Type creation (uses backend_name)
|
||||||
cls._create_type_and_volume(cls.backend2_name, False)
|
cls._create_type_and_volume(backend_name, False)
|
||||||
# Volume/Type creation (uses capabilities:volume_backend_name)
|
# Volume/Type creation (uses capabilities:volume_backend_name)
|
||||||
cls._create_type_and_volume(cls.backend2_name, True)
|
cls._create_type_and_volume(backend_name, True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _create_type_and_volume(self, backend_name_key, with_prefix):
|
def _create_type_and_volume(self, backend_name_key, with_prefix):
|
||||||
@ -104,32 +109,28 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
|
|||||||
@test.idempotent_id('c1a41f3f-9dad-493e-9f09-3ff197d477cc')
|
@test.idempotent_id('c1a41f3f-9dad-493e-9f09-3ff197d477cc')
|
||||||
def test_backend_name_reporting(self):
|
def test_backend_name_reporting(self):
|
||||||
# get volume id which created by type without prefix
|
# get volume id which created by type without prefix
|
||||||
volume_id = self.volume_id_list_without_prefix[0]
|
for volume_id in self.volume_id_list_without_prefix:
|
||||||
self._test_backend_name_reporting_by_volume_id(volume_id)
|
self._test_backend_name_reporting_by_volume_id(volume_id)
|
||||||
|
|
||||||
@test.idempotent_id('f38e647f-ab42-4a31-a2e7-ca86a6485215')
|
@test.idempotent_id('f38e647f-ab42-4a31-a2e7-ca86a6485215')
|
||||||
def test_backend_name_reporting_with_prefix(self):
|
def test_backend_name_reporting_with_prefix(self):
|
||||||
# get volume id which created by type with prefix
|
# get volume id which created by type with prefix
|
||||||
volume_id = self.volume_id_list_with_prefix[0]
|
for volume_id in self.volume_id_list_with_prefix:
|
||||||
self._test_backend_name_reporting_by_volume_id(volume_id)
|
self._test_backend_name_reporting_by_volume_id(volume_id)
|
||||||
|
|
||||||
@test.idempotent_id('46435ab1-a0af-4401-8373-f14e66b0dd58')
|
@test.idempotent_id('46435ab1-a0af-4401-8373-f14e66b0dd58')
|
||||||
def test_backend_name_distinction(self):
|
def test_backend_name_distinction(self):
|
||||||
if self.backend1_name == self.backend2_name:
|
# get volume ids which created by type without prefix
|
||||||
raise self.skipException("backends configured with same name")
|
self._test_backend_name_distinction(self.volume_id_list_without_prefix)
|
||||||
# get volume id which created by type without prefix
|
|
||||||
volume1_id = self.volume_id_list_without_prefix[0]
|
|
||||||
volume2_id = self.volume_id_list_without_prefix[1]
|
|
||||||
self._test_backend_name_distinction(volume1_id, volume2_id)
|
|
||||||
|
|
||||||
@test.idempotent_id('4236305b-b65a-4bfc-a9d2-69cb5b2bf2ed')
|
@test.idempotent_id('4236305b-b65a-4bfc-a9d2-69cb5b2bf2ed')
|
||||||
def test_backend_name_distinction_with_prefix(self):
|
def test_backend_name_distinction_with_prefix(self):
|
||||||
if self.backend1_name == self.backend2_name:
|
# get volume ids which created by type without prefix
|
||||||
raise self.skipException("backends configured with same name")
|
self._test_backend_name_distinction(self.volume_id_list_with_prefix)
|
||||||
# get volume id which created by type without prefix
|
|
||||||
volume1_id = self.volume_id_list_with_prefix[0]
|
def _get_volume_host(self, volume_id):
|
||||||
volume2_id = self.volume_id_list_with_prefix[1]
|
return self.admin_volume_client.show_volume(
|
||||||
self._test_backend_name_distinction(volume1_id, volume2_id)
|
volume_id)['volume']['os-vol-host-attr:host']
|
||||||
|
|
||||||
def _test_backend_name_reporting_by_volume_id(self, volume_id):
|
def _test_backend_name_reporting_by_volume_id(self, volume_id):
|
||||||
# this test checks if os-vol-attr:host is populated correctly after
|
# this test checks if os-vol-attr:host is populated correctly after
|
||||||
@ -143,19 +144,16 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
|
|||||||
volume_id)
|
volume_id)
|
||||||
self.assertTrue(len(volume1_host.split("@")) > 1, msg)
|
self.assertTrue(len(volume1_host.split("@")) > 1, msg)
|
||||||
|
|
||||||
def _test_backend_name_distinction(self, volume1_id, volume2_id):
|
def _test_backend_name_distinction(self, volume_id_list):
|
||||||
# this test checks that the two volumes created at setUp don't
|
# this test checks that the volumes created at setUp don't
|
||||||
# belong to the same backend (if they are, than the
|
# belong to the same backend (if they are, than the
|
||||||
# volume backend distinction is not working properly)
|
# volume backend distinction is not working properly)
|
||||||
volume = self.admin_volume_client.show_volume(volume1_id)['volume']
|
volume_hosts = [self._get_volume_host(volume) for volume in
|
||||||
volume1_host = volume['os-vol-host-attr:host']
|
volume_id_list]
|
||||||
|
# assert that volumes are each created on separate hosts:
|
||||||
volume = self.admin_volume_client.show_volume(volume2_id)['volume']
|
msg = ("volumes %s were created in the same backend" % ", "
|
||||||
volume2_host = volume['os-vol-host-attr:host']
|
.join(volume_hosts))
|
||||||
|
six.assertCountEqual(self, volume_hosts, set(volume_hosts), msg)
|
||||||
msg = ("volumes %s and %s were created in the same backend" %
|
|
||||||
(volume1_id, volume2_id))
|
|
||||||
self.assertNotEqual(volume1_host, volume2_host, msg)
|
|
||||||
|
|
||||||
|
|
||||||
class VolumeMultiBackendV1Test(VolumeMultiBackendV2Test):
|
class VolumeMultiBackendV1Test(VolumeMultiBackendV2Test):
|
||||||
|
@ -722,11 +722,21 @@ VolumeGroup = [
|
|||||||
'publicURL', 'adminURL', 'internalURL'],
|
'publicURL', 'adminURL', 'internalURL'],
|
||||||
help="The endpoint type to use for the volume service."),
|
help="The endpoint type to use for the volume service."),
|
||||||
cfg.StrOpt('backend1_name',
|
cfg.StrOpt('backend1_name',
|
||||||
default='BACKEND_1',
|
default='',
|
||||||
help="Name of the backend1 (must be declared in cinder.conf)"),
|
help='Name of the backend1 (must be declared in cinder.conf)',
|
||||||
|
deprecated_for_removal=True),
|
||||||
cfg.StrOpt('backend2_name',
|
cfg.StrOpt('backend2_name',
|
||||||
default='BACKEND_2',
|
default='',
|
||||||
help="Name of the backend2 (must be declared in cinder.conf)"),
|
help='Name of the backend2 (must be declared in cinder.conf)',
|
||||||
|
deprecated_for_removal=True),
|
||||||
|
cfg.ListOpt('backend_names',
|
||||||
|
default=['BACKEND_1', 'BACKEND_2'],
|
||||||
|
help='A list of backend names seperated by comma .'
|
||||||
|
'The backend name must be declared in cinder.conf',
|
||||||
|
deprecated_opts=[cfg.DeprecatedOpt('BACKEND_1',
|
||||||
|
group='volume'),
|
||||||
|
cfg.DeprecatedOpt('BACKEND_2',
|
||||||
|
group='volume')]),
|
||||||
cfg.StrOpt('storage_protocol',
|
cfg.StrOpt('storage_protocol',
|
||||||
default='iSCSI',
|
default='iSCSI',
|
||||||
help='Backend protocol to target when creating volume types'),
|
help='Backend protocol to target when creating volume types'),
|
||||||
|
Loading…
Reference in New Issue
Block a user