Replace kwargs with specific arguments

Replace kwargs in create_volume_type by 2
arguments: description and is_public

Change-Id: I2b8f932aa4b303605d4060fd44936d126f14c184
This commit is contained in:
maxinjian 2017-05-19 11:44:34 -04:00
parent d1905515b1
commit 687260796b
11 changed files with 66 additions and 37 deletions

View File

@ -869,7 +869,8 @@
CinderVolumeTypes.create_and_get_volume_type: CinderVolumeTypes.create_and_get_volume_type:
- -
args: {} args:
description: "rally tests creating types"
runner: runner:
type: "constant" type: "constant"
times: 5 times: 5
@ -884,7 +885,8 @@
CinderVolumeTypes.create_and_delete_volume_type: CinderVolumeTypes.create_and_delete_volume_type:
- -
args: {} args:
description: "rally tests creating types"
runner: runner:
type: "constant" type: "constant"
times: 5 times: 5
@ -965,6 +967,7 @@
CinderVolumeTypes.create_volume_type_and_encryption_type: CinderVolumeTypes.create_volume_type_and_encryption_type:
- -
args: args:
description: "rally tests creating types"
provider: "LuksEncryptor" provider: "LuksEncryptor"
cipher: "aes-xts-plain64" cipher: "aes-xts-plain64"
key_size: 512 key_size: 512
@ -1051,6 +1054,7 @@
CinderVolumeTypes.create_and_set_volume_type_keys: CinderVolumeTypes.create_and_set_volume_type_keys:
- -
args: args:
description: "rally tests creating types"
volume_type_key: volume_type_key:
volume_backend_name: "LVM_iSCSI" volume_backend_name: "LVM_iSCSI"
runner: runner:

View File

@ -27,36 +27,38 @@ LOG = logging.getLogger(__name__)
@validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_services", services=[consts.Service.CINDER])
@validation.add("restricted_parameters", param_names="name")
@validation.add("required_platform", platform="openstack", admin=True) @validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]}, @scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_delete_volume_type") name="CinderVolumeTypes.create_and_delete_volume_type")
class CreateAndDeleteVolumeType(cinder_utils.CinderBasic): class CreateAndDeleteVolumeType(cinder_utils.CinderBasic):
def run(self, **kwargs): def run(self, description=None, is_public=True):
"""Create and delete a volume Type. """Create and delete a volume Type.
:param kwargs: Optional parameters used during volume :param description: Description of the volume type
type creation. :param is_public: Volume type visibility
""" """
volume_type = self.admin_cinder.create_volume_type(**kwargs) volume_type = self.admin_cinder.create_volume_type(
description=description,
is_public=is_public)
self.admin_cinder.delete_volume_type(volume_type) self.admin_cinder.delete_volume_type(volume_type)
@validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_services", services=[consts.Service.CINDER])
@validation.add("restricted_parameters", param_names="name")
@validation.add("required_platform", platform="openstack", admin=True) @validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]}, @scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_get_volume_type") name="CinderVolumeTypes.create_and_get_volume_type")
class CreateAndGetVolumeType(cinder_utils.CinderBasic): class CreateAndGetVolumeType(cinder_utils.CinderBasic):
def run(self, **kwargs): def run(self, description=None, is_public=True):
"""Create a volume Type, then get the details of the type. """Create a volume Type, then get the details of the type.
:param kwargs: Optional parameters used during volume :param description: Description of the volume type
type creation. :param is_public: Volume type visibility
""" """
volume_type = self.admin_cinder.create_volume_type(**kwargs) volume_type = self.admin_cinder.create_volume_type(
description=description,
is_public=is_public)
self.admin_cinder.get_volume_type(volume_type) self.admin_cinder.get_volume_type(volume_type)
@ -118,7 +120,6 @@ class CreateAndListVolumeTypes(cinder_utils.CinderBasic):
err_msg=msg) err_msg=msg)
@validation.add("restricted_parameters", param_names="name")
@validation.add("required_params", params=[("create_specs", "provider")]) @validation.add("required_params", params=[("create_specs", "provider")])
@validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_services", services=[consts.Service.CINDER])
@validation.add("required_platform", platform="openstack", admin=True) @validation.add("required_platform", platform="openstack", admin=True)
@ -128,7 +129,8 @@ class CreateAndListVolumeTypes(cinder_utils.CinderBasic):
class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic): class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic):
def run(self, create_specs=None, provider=None, cipher=None, def run(self, create_specs=None, provider=None, cipher=None,
key_size=None, control_location="front-end", **kwargs): key_size=None, control_location="front-end", description=None,
is_public=True):
"""Create encryption type """Create encryption type
This scenario first creates a volume type, then creates an encryption This scenario first creates a volume type, then creates an encryption
@ -143,10 +145,12 @@ class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic):
:param control_location: Notional service where encryption is :param control_location: Notional service where encryption is
performed. Valid values are "front-end" performed. Valid values are "front-end"
or "back-end." or "back-end."
:param kwargs: Optional parameters used during volume :param description: Description of the volume type
type creation. :param is_public: Volume type visibility
""" """
volume_type = self.admin_cinder.create_volume_type(**kwargs) volume_type = self.admin_cinder.create_volume_type(
description=description,
is_public=is_public)
if create_specs is None: if create_specs is None:
specs = { specs = {
"provider": provider, "provider": provider,
@ -210,20 +214,21 @@ class CreateAndListEncryptionType(cinder_utils.CinderBasic):
@validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_services", services=[consts.Service.CINDER])
@validation.add("restricted_parameters", param_names="name")
@validation.add("required_platform", platform="openstack", admin=True) @validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]}, @scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_set_volume_type_keys") name="CinderVolumeTypes.create_and_set_volume_type_keys")
class CreateAndSetVolumeTypeKeys(cinder_utils.CinderBasic): class CreateAndSetVolumeTypeKeys(cinder_utils.CinderBasic):
def run(self, volume_type_key, **kwargs): def run(self, volume_type_key, description=None, is_public=True):
"""Create and set a volume type's extra specs. """Create and set a volume type's extra specs.
:param volume_type_key: A dict of key/value pairs to be set :param volume_type_key: A dict of key/value pairs to be set
:param kwargs: Optional parameters used during volume :param description: Description of the volume type
type creation. :param is_public: Volume type visibility
""" """
volume_type = self.admin_cinder.create_volume_type(**kwargs) volume_type = self.admin_cinder.create_volume_type(
description=description,
is_public=is_public)
self.admin_cinder.set_volume_type_keys(volume_type, self.admin_cinder.set_volume_type_keys(volume_type,
metadata=volume_type_key) metadata=volume_type_key)

View File

@ -1,7 +1,9 @@
{ {
"CinderVolumeTypes.create_and_delete_volume_type": [ "CinderVolumeTypes.create_and_delete_volume_type": [
{ {
"args": {}, "args": {
"description": "rally tests creating types"
},
"runner": { "runner": {
"type": "constant", "type": "constant",
"times": 5, "times": 5,

View File

@ -1,7 +1,8 @@
--- ---
CinderVolumeTypes.create_and_delete_volume_type: CinderVolumeTypes.create_and_delete_volume_type:
- -
args: {} args:
description: "rally tests creating types"
runner: runner:
type: "constant" type: "constant"
times: 5 times: 5

View File

@ -1,7 +1,9 @@
{ {
"CinderVolumeTypes.create_and_get_volume_type": [ "CinderVolumeTypes.create_and_get_volume_type": [
{ {
"args": {}, "args": {
"description": "rally tests creating types"
},
"runner": { "runner": {
"type": "constant", "type": "constant",
"times": 5, "times": 5,

View File

@ -1,7 +1,8 @@
--- ---
CinderVolumeTypes.create_and_get_volume_type: CinderVolumeTypes.create_and_get_volume_type:
- -
args: {} args:
description: "rally tests creating types"
runner: runner:
type: "constant" type: "constant"
times: 5 times: 5

View File

@ -2,6 +2,7 @@
"CinderVolumeTypes.create_and_set_volume_type_keys": [ "CinderVolumeTypes.create_and_set_volume_type_keys": [
{ {
"args": { "args": {
"description": "rally tests creating types",
"volume_type_key": { "volume_type_key": {
"volume_backend_name": "LVM_iSCSI" "volume_backend_name": "LVM_iSCSI"
} }

View File

@ -2,6 +2,7 @@
CinderVolumeTypes.create_and_set_volume_type_keys: CinderVolumeTypes.create_and_set_volume_type_keys:
- -
args: args:
description: "rally tests creating types"
volume_type_key: volume_type_key:
volume_backend_name: "LVM_iSCSI" volume_backend_name: "LVM_iSCSI"
runner: runner:

View File

@ -2,6 +2,7 @@
"CinderVolumeTypes.create_volume_type_and_encryption_type": [ "CinderVolumeTypes.create_volume_type_and_encryption_type": [
{ {
"args": { "args": {
"description": "rally tests creating types",
"provider": "LuksEncryptor", "provider": "LuksEncryptor",
"cipher": "aes-xts-plain64", "cipher": "aes-xts-plain64",
"key_size": 512, "key_size": 512,

View File

@ -2,6 +2,7 @@
CinderVolumeTypes.create_volume_type_and_encryption_type: CinderVolumeTypes.create_volume_type_and_encryption_type:
- -
args: args:
description: "rally tests creating types"
provider: "LuksEncryptor" provider: "LuksEncryptor"
cipher: "aes-xts-plain64" cipher: "aes-xts-plain64"
key_size: 512 key_size: 512

View File

@ -46,17 +46,22 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
def test_create_and_get_volume_type(self): def test_create_and_get_volume_type(self):
mock_service = self.mock_cinder.return_value mock_service = self.mock_cinder.return_value
scenario = volume_types.CreateAndGetVolumeType(self._get_context()) scenario = volume_types.CreateAndGetVolumeType(self._get_context())
scenario.run(fakeargs="f") description = "rally tests creating types"
mock_service.create_volume_type.assert_called_once_with(fakeargs="f") is_public = False
scenario.run(description=description, is_public=is_public)
mock_service.create_volume_type.assert_called_once_with(
description=description, is_public=is_public)
mock_service.get_volume_type.assert_called_once_with( mock_service.get_volume_type.assert_called_once_with(
mock_service.create_volume_type.return_value) mock_service.create_volume_type.return_value)
def test_create_and_delete_volume_type(self): def test_create_and_delete_volume_type(self):
mock_service = self.mock_cinder.return_value mock_service = self.mock_cinder.return_value
scenario = volume_types.CreateAndDeleteVolumeType(self._get_context()) scenario = volume_types.CreateAndDeleteVolumeType(self._get_context())
scenario.run(fakeargs="fakeargs") description = "rally tests creating types"
is_public = False
scenario.run(description=description, is_public=is_public)
mock_service.create_volume_type.assert_called_once_with( mock_service.create_volume_type.assert_called_once_with(
fakeargs="fakeargs") description=description, is_public=is_public)
mock_service.delete_volume_type.assert_called_once_with( mock_service.delete_volume_type.assert_called_once_with(
mock_service.create_volume_type.return_value) mock_service.create_volume_type.return_value)
@ -176,7 +181,8 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
mock_service = self.mock_cinder.return_value mock_service = self.mock_cinder.return_value
scenario = volume_types.CreateVolumeTypeAndEncryptionType( scenario = volume_types.CreateVolumeTypeAndEncryptionType(
self._get_context()) self._get_context())
description = "rally tests creating types"
is_public = False
# case: create_specs is None # case: create_specs is None
specs = { specs = {
"provider": "prov", "provider": "prov",
@ -185,18 +191,19 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
"control_location": "cl" "control_location": "cl"
} }
scenario.run(create_specs=None, provider="prov", cipher="cip", scenario.run(create_specs=None, provider="prov", cipher="cip",
key_size="ks", control_location="cl", fakeargs="fakeargs") key_size="ks", control_location="cl",
description=description, is_public=is_public)
mock_service.create_volume_type.assert_called_once_with( mock_service.create_volume_type.assert_called_once_with(
fakeargs="fakeargs") description=description, is_public=is_public)
mock_service.create_encryption_type.assert_called_once_with( mock_service.create_encryption_type.assert_called_once_with(
mock_service.create_volume_type.return_value, specs=specs) mock_service.create_volume_type.return_value, specs=specs)
# case: create_specs is not None # case: create_specs is not None
scenario.run(create_specs="fakecreatespecs", provider="prov", scenario.run(create_specs="fakecreatespecs", provider="prov",
cipher="cip", key_size="ks", control_location="cl", cipher="cip", key_size="ks", control_location="cl",
fakeargs="fakeargs") description=description, is_public=is_public)
mock_service.create_volume_type.assert_called_with( mock_service.create_volume_type.assert_called_with(
fakeargs="fakeargs") description=description, is_public=is_public)
mock_service.create_encryption_type.assert_called_with( mock_service.create_encryption_type.assert_called_with(
mock_service.create_volume_type.return_value, mock_service.create_volume_type.return_value,
specs="fakecreatespecs") specs="fakecreatespecs")
@ -238,12 +245,15 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
def test_create_and_set_volume_type_keys(self): def test_create_and_set_volume_type_keys(self):
mock_service = self.mock_cinder.return_value mock_service = self.mock_cinder.return_value
volume_type_key = {"volume_backend_name": "LVM_iSCSI"} volume_type_key = {"volume_backend_name": "LVM_iSCSI"}
description = "rally tests creating types"
is_public = False
scenario = volume_types.CreateAndSetVolumeTypeKeys( scenario = volume_types.CreateAndSetVolumeTypeKeys(
self._get_context()) self._get_context())
scenario.run(volume_type_key, fakeargs="fakeargs") scenario.run(volume_type_key, description=description,
is_public=is_public)
mock_service.create_volume_type.assert_called_once_with( mock_service.create_volume_type.assert_called_once_with(
fakeargs="fakeargs") description=description, is_public=is_public)
mock_service.set_volume_type_keys.assert_called_once_with( mock_service.set_volume_type_keys.assert_called_once_with(
mock_service.create_volume_type.return_value, mock_service.create_volume_type.return_value,
metadata=volume_type_key) metadata=volume_type_key)