Add CinderVolumeTypes.create_get_and_delete_encryption_type

This scenario firstly creates an encryption type for a given
 volume type, then gets detailed information of the created
 encryption type, finally deletes the created encryption type.

Change-Id: I2d5dd08c1f7f48deaad4eff6d8efd56f016a6b14
This commit is contained in:
maxinjian 2017-01-17 06:12:10 -05:00
parent a886803ad5
commit 4fcfacade6
15 changed files with 489 additions and 77 deletions

View File

@ -881,6 +881,29 @@
max: 0
CinderVolumeTypes.create_and_delete_encryption_type:
-
args:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
concurrency: 1
context:
users:
tenants: 2
users_per_tenant: 2
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0
-
args:
create_specs:
@ -896,7 +919,12 @@
users:
tenants: 2
users_per_tenant: 2
volume_types: ["test_type"]
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0
@ -904,14 +932,13 @@
CinderVolumeTypes.create_volume_type_and_encryption_type:
-
args:
specs:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 5
times: 4
concurrency: 2
context:
users:
@ -920,11 +947,9 @@
sla:
failure_rate:
max: 0
CinderVolumeTypes.create_and_list_encryption_type:
-
args:
specs:
create_specs:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
@ -941,6 +966,55 @@
failure_rate:
max: 0
CinderVolumeTypes.create_and_list_encryption_type:
-
args:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0
-
args:
create_specs:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0
CinderVolumeTypes.create_and_set_volume_type_keys:
-
args:
@ -1025,3 +1099,28 @@
sla:
failure_rate:
max: 0
CinderVolumeTypes.create_get_and_delete_encryption_type:
-
args:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
concurrency: 1
context:
users:
tenants: 2
users_per_tenant: 2
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0

View File

@ -12,14 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
import random
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils
from rally.task import validation
LOG = logging.getLogger(__name__)
"""Scenarios for Cinder Volume Type."""
@ -57,51 +59,93 @@ class CreateAndGetVolumeType(cinder_utils.CinderBasic):
self.admin_cinder.get_volume_type(volume_type)
@validation.restricted_parameters("name")
@validation.required_services(consts.Service.CINDER)
@validation.add("required_params", params=[("create_specs", "provider")])
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_volume_type"
"_and_encryption_type")
class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic):
def run(self, specs, **kwargs):
def run(self, create_specs=None, provider=None, cipher=None,
key_size=None, control_location="front-end", **kwargs):
"""Create encryption type
This scenario first creates a volume type, then creates an encryption
type for the volume type.
:param specs: the encryption type specifications to add
:param create_specs: The encryption type specifications to add.
DEPRECATED, specify arguments explicitly.
:param provider: The class that provides encryption support. For
example, LuksEncryptor.
:param cipher: The encryption algorithm or mode.
:param key_size: Size of encryption key, in bits.
:param control_location: Notional service where encryption is
performed. Valid values are "front-end"
or "back-end."
:param kwargs: Optional parameters used during volume
type creation.
"""
volume_type = self.admin_cinder.create_volume_type(**kwargs)
if create_specs is None:
specs = {
"provider": provider,
"cipher": cipher,
"key_size": key_size,
"control_location": control_location
}
else:
LOG.warning("The argument `create_spec` is deprecated since"
" Rally 0.10.0. Specify all arguments from it"
" explicitly.")
specs = create_specs
self.admin_cinder.create_encryption_type(volume_type,
specs=specs)
@validation.restricted_parameters("name")
@validation.required_services(consts.Service.CINDER)
@validation.required_contexts("volume_types")
@validation.add("required_params", params=[("create_specs", "provider")])
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_list_"
"encryption_type")
class CreateAndListEncryptionType(cinder_utils.CinderBasic):
def run(self, specs, search_opts=None, **kwargs):
def run(self, create_specs=None, provider=None, cipher=None,
key_size=None, control_location="front-end", search_opts=None):
"""Create and list encryption type
This scenario firstly creates a volume type, secondly creates an
encryption type for the volume type, thirdly lists all encryption
types.
:param specs: the encryption type specifications to add
:param create_specs: The encryption type specifications to add.
DEPRECATED, specify arguments explicitly.
:param provider: The class that provides encryption support. For
example, LuksEncryptor.
:param cipher: The encryption algorithm or mode.
:param key_size: Size of encryption key, in bits.
:param control_location: Notional service where encryption is
performed. Valid values are "front-end"
or "back-end."
:param search_opts: Options used when search for encryption types
:param kwargs: Optional parameters used during volume
type creation.
"""
volume_type = self.admin_cinder.create_volume_type(**kwargs)
self.admin_cinder.create_encryption_type(volume_type,
vt_idx = self.context["iteration"] % len(self.context["volume_types"])
volume_type = self.context["volume_types"][vt_idx]
if create_specs is None:
specs = {
"provider": provider,
"cipher": cipher,
"key_size": key_size,
"control_location": control_location
}
else:
LOG.warning("The argument `create_spec` is deprecated since"
" Rally 0.10.0. Specify all arguments from it"
" explicitly.")
specs = create_specs
self.admin_cinder.create_encryption_type(volume_type["id"],
specs=specs)
self.admin_cinder.list_encryption_type(search_opts)
@ -128,20 +172,81 @@ class CreateAndSetVolumeTypeKeys(cinder_utils.CinderBasic):
@validation.required_services(consts.Service.CINDER)
@validation.required_contexts("volume_types")
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_get_and_delete_"
"encryption_type")
class CreateGetAndDeleteEncryptionType(cinder_utils.CinderBasic):
def run(self, provider=None, cipher=None,
key_size=None, control_location="front-end"):
"""Create get and delete an encryption type
This scenario firstly creates an encryption type for a volome
type created in the context, then gets detailed information of
the created encryption type, finally deletes the created
encryption type.
:param provider: The class that provides encryption support. For
example, LuksEncryptor.
:param cipher: The encryption algorithm or mode.
:param key_size: Size of encryption key, in bits.
:param control_location: Notional service where encryption is
performed. Valid values are "front-end"
or "back-end."
"""
vt_idx = self.context["iteration"] % len(self.context["volume_types"])
volume_type = self.context["volume_types"][vt_idx]
specs = {
"provider": provider,
"cipher": cipher,
"key_size": key_size,
"control_location": control_location
}
self.admin_cinder.create_encryption_type(volume_type["id"],
specs=specs)
self.admin_cinder.get_encryption_type(volume_type["id"])
self.admin_cinder.delete_encryption_type(volume_type["id"])
@validation.required_services(consts.Service.CINDER)
@validation.required_contexts("volume_types")
@validation.add("required_params", params=[("create_specs", "provider")])
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_delete_"
"encryption_type")
class CreateAndDeleteEncryptionType(cinder_utils.CinderBasic):
def run(self, create_specs):
def run(self, create_specs=None, provider=None, cipher=None,
key_size=None, control_location="front-end"):
"""Create and delete encryption type
This scenario firstly creates an encryption type for a given
volume type, then deletes the created encryption type.
:param create_specs: the encryption type specifications to add
:param provider: The class that provides encryption support. For
example, LuksEncryptor.
:param cipher: The encryption algorithm or mode.
:param key_size: Size of encryption key, in bits.
:param control_location: Notional service where encryption is
performed. Valid values are "front-end"
or "back-end."
"""
volume_type = random.choice(self.context["volume_types"])
vt_idx = self.context["iteration"] % len(self.context["volume_types"])
volume_type = self.context["volume_types"][vt_idx]
if create_specs is None:
specs = {
"provider": provider,
"cipher": cipher,
"key_size": key_size,
"control_location": control_location
}
else:
LOG.warning("The argument `create_spec` is deprecated since"
" Rally 0.10.0. Specify all arguments from it"
" explicitly.")
specs = create_specs
self.admin_cinder.create_encryption_type(volume_type["id"],
specs=create_specs)
specs=specs)
self.admin_cinder.delete_encryption_type(volume_type["id"])

View File

@ -373,6 +373,15 @@ class BlockStorage(service.UnifiedOpenStackService):
"""
return self._impl.create_encryption_type(volume_type, specs=specs)
@service.should_be_overridden
def get_encryption_type(self, volume_type):
"""Get the volume encryption type for the specified volume type.
:param volume_type: the volume type to query
:return: an instance of :class: VolumeEncryptionType
"""
return self._impl.get_encryption_type(volume_type)
@service.should_be_overridden
def list_encryption_type(self, search_opts=None):
"""List all volume encryption types.

View File

@ -378,6 +378,17 @@ class CinderMixin(object):
return self._get_client().volume_encryption_types.create(
volume_type, specs)
def get_encryption_type(self, volume_type):
"""Get the volume encryption type for the specified volume type.
:param volume_type: the volume type to query
:return: an instance of :class: VolumeEncryptionType
"""
aname = "cinder_v%s.get_encryption_type" % self.version
with atomic.ActionTimer(self, aname):
return self._get_client().volume_encryption_types.get(
volume_type)
def list_encryption_type(self, search_opts=None):
"""List all volume encryption types.
@ -591,6 +602,15 @@ class UnifiedCinderMixin(object):
return self._unify_encryption_type(
self._impl.create_encryption_type(volume_type, specs=specs))
def get_encryption_type(self, volume_type):
"""Get the volume encryption type for the specified volume type.
:param volume_type: the volume type to query
:return: an instance of :class: VolumeEncryptionType
"""
return self._unify_encryption_type(
self._impl.get_encryption_type(volume_type))
def list_encryption_type(self, search_opts=None):
"""List all volume encryption types.

View File

@ -2,12 +2,10 @@
"CinderVolumeTypes.create_and_delete_encryption_type": [
{
"args": {
"create_specs": {
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
}
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
},
"runner": {
"type": "constant",
@ -19,7 +17,12 @@
"tenants": 2,
"users_per_tenant": 2
},
"volume_types": ["test_type"]
"volume_types": [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
},
"sla": {
"failure_rate": {

View File

@ -1,11 +1,10 @@
CinderVolumeTypes.create_and_delete_encryption_type:
-
args:
create_specs:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
@ -14,7 +13,12 @@
users:
tenants: 2
users_per_tenant: 2
volume_types: ["test_type"]
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0

View File

@ -2,23 +2,27 @@
"CinderVolumeTypes.create_and_list_encryption_type": [
{
"args": {
"specs": {
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
}
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
},
"runner": {
"type": "constant",
"times": 4,
"concurrency": 2
"concurrency": 1
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"volume_types": [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
},
"sla": {
"failure_rate": {

View File

@ -1,19 +1,24 @@
CinderVolumeTypes.create_and_list_encryption_type:
-
args:
specs:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
concurrency: 2
concurrency: 1
context:
users:
tenants: 2
users_per_tenant: 2
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0

View File

@ -2,16 +2,14 @@
"CinderVolumeTypes.create_volume_type_and_encryption_type": [
{
"args": {
"specs": {
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
}
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
},
"runner": {
"type": "constant",
"times": 5,
"times": 4,
"concurrency": 2
},
"context": {

View File

@ -2,14 +2,13 @@
CinderVolumeTypes.create_volume_type_and_encryption_type:
-
args:
specs:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 5
times: 4
concurrency: 2
context:
users:

View File

@ -0,0 +1,34 @@
{
"CinderVolumeTypes.create_get_and_delete_encryption_type": [
{
"args": {
"provider": "LuksEncryptor",
"cipher": "aes-xts-plain64",
"key_size": 512,
"control_location": "front-end"
},
"runner": {
"type": "constant",
"times": 4,
"concurrency": 1
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
},
"volume_types": [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,24 @@
CinderVolumeTypes.create_get_and_delete_encryption_type:
-
args:
provider: "LuksEncryptor"
cipher: "aes-xts-plain64"
key_size: 512
control_location: "front-end"
runner:
type: "constant"
times: 4
concurrency: 1
context:
users:
tenants: 2
users_per_tenant: 2
volume_types: [
"test_type1",
"test_type2",
"test_type3",
"test_type4"
]
sla:
failure_rate:
max: 0

View File

@ -61,11 +61,55 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
context = self._get_context()
context.update({
"volume_types": [{"id": "fake_id",
"name": "fake_name"}]})
scenario = volume_types.CreateAndDeleteEncryptionType(context)
scenario.run(create_specs="fakecreatespecs")
"name": "fake_name"}],
"iteration": 1})
scenario = volume_types.CreateAndDeleteEncryptionType(
context)
# case: create_specs is None
specs = {
"provider": "prov",
"cipher": "cip",
"key_size": "ks",
"control_location": "cl"
}
scenario.run(create_specs=None, provider="prov", cipher="cip",
key_size="ks", control_location="cl")
mock_service.create_encryption_type.assert_called_once_with(
"fake_id", specs=specs)
mock_service.delete_encryption_type.assert_called_once_with(
"fake_id")
# case: create_specs is not None
scenario.run(create_specs="fakecreatespecs", provider="prov",
cipher="cip", key_size="ks", control_location="cl")
mock_service.create_encryption_type.assert_called_with(
"fake_id", specs="fakecreatespecs")
mock_service.delete_encryption_type.assert_called_with(
"fake_id")
def test_create_get_and_delete_encryption_type(self):
mock_service = self.mock_cinder.return_value
context = self._get_context()
context.update({
"volume_types": [{"id": "fake_id",
"name": "fake_name"}],
"iteration": 1})
scenario = volume_types.CreateGetAndDeleteEncryptionType(
context)
specs = {
"provider": "prov",
"cipher": "cip",
"key_size": "ks",
"control_location": "cl"
}
scenario.run(provider="prov", cipher="cip",
key_size="ks", control_location="cl")
mock_service.create_encryption_type.assert_called_once_with(
"fake_id", specs=specs)
mock_service.get_encryption_type.assert_called_once_with(
"fake_id")
mock_service.delete_encryption_type.assert_called_once_with(
"fake_id")
@ -73,27 +117,65 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
mock_service = self.mock_cinder.return_value
scenario = volume_types.CreateVolumeTypeAndEncryptionType(
self._get_context())
scenario.run(specs="fakespecs", fakeargs="fakeargs")
# case: create_specs is None
specs = {
"provider": "prov",
"cipher": "cip",
"key_size": "ks",
"control_location": "cl"
}
scenario.run(create_specs=None, provider="prov", cipher="cip",
key_size="ks", control_location="cl", fakeargs="fakeargs")
mock_service.create_volume_type.assert_called_once_with(
fakeargs="fakeargs")
mock_service.create_encryption_type.assert_called_once_with(
mock_service.create_volume_type.return_value, specs=specs)
# case: create_specs is not None
scenario.run(create_specs="fakecreatespecs", provider="prov",
cipher="cip", key_size="ks", control_location="cl",
fakeargs="fakeargs")
mock_service.create_volume_type.assert_called_with(
fakeargs="fakeargs")
mock_service.create_encryption_type.assert_called_with(
mock_service.create_volume_type.return_value,
specs="fakespecs")
specs="fakecreatespecs")
def test_create_and_list_encryption_type(self):
mock_service = self.mock_cinder.return_value
context = self._get_context()
context.update({
"volume_types": [{"id": "fake_id",
"name": "fake_name"}],
"iteration": 1})
scenario = volume_types.CreateAndListEncryptionType(
self._get_context())
scenario.run(specs="fakespecs", search_opts="fakeopts",
fakeargs="fakeargs")
mock_service.create_volume_type.assert_called_once_with(
fakeargs="fakeargs")
context)
# case: create_specs is None
specs = {
"provider": "prov",
"cipher": "cip",
"key_size": "ks",
"control_location": "cl"
}
scenario.run(create_specs=None, provider="prov", cipher="cip",
key_size="ks", control_location="cl",
search_opts="fakeopts")
mock_service.create_encryption_type.assert_called_once_with(
mock_service.create_volume_type.return_value,
specs="fakespecs")
"fake_id", specs=specs)
mock_service.list_encryption_type.assert_called_once_with(
"fakeopts")
# case: create_specs is not None
scenario.run(create_specs="fakecreatespecs", provider="prov",
cipher="cip", key_size="ks", control_location="cl",
search_opts="fakeopts")
mock_service.create_encryption_type.assert_called_with(
"fake_id", specs="fakecreatespecs")
mock_service.list_encryption_type.assert_called_with(
"fakeopts")
def test_create_and_set_volume_type_keys(self):
mock_service = self.mock_cinder.return_value
volume_type_key = {"volume_backend_name": "LVM_iSCSI"}

View File

@ -230,6 +230,13 @@ class BlockTestCase(test.TestCase):
self.service._impl.create_encryption_type.assert_called_once_with(
"type", specs=2)
def test_get_encryption_type(self):
self.assertEqual(
self.service._impl.get_encryption_type.return_value,
self.service.get_encryption_type("type"))
self.service._impl.get_encryption_type.assert_called_once_with(
"type")
def test_list_encryption_type(self):
self.assertEqual(self.service._impl.list_encryption_type.return_value,
self.service.list_encryption_type(search_opts=None))

View File

@ -376,6 +376,15 @@ class CinderMixinTestCase(test.ScenarioTestCase):
self.cinder.volume_encryption_types.create.assert_called_once_with(
volume_type, specs)
def test_get_encryption_type(self):
volume_type = mock.Mock()
result = self.service.get_encryption_type(volume_type)
self.assertEqual(
self.cinder.volume_encryption_types.get.return_value, result)
self.cinder.volume_encryption_types.get.assert_called_once_with(
volume_type)
def test_list_encryption_type(self):
return_encryption_types_list = self.service.list_encryption_type()
self.assertEqual(self.cinder.volume_encryption_types.list.return_value,
@ -581,6 +590,16 @@ class UnifiedCinderMixinTestCase(test.TestCase):
self.service._unify_encryption_type.assert_called_once_with(
self.service._impl.create_encryption_type.return_value)
def test_get_encryption_type(self):
self.service._unify_encryption_type = mock.MagicMock()
self.assertEqual(
self.service._unify_encryption_type.return_value,
self.service.get_encryption_type("type"))
self.service._impl.get_encryption_type.assert_called_once_with(
"type")
self.service._unify_encryption_type.assert_called_once_with(
self.service._impl.get_encryption_type.return_value)
def test_list_encryption_type(self):
self.service._unify_encryption_type = mock.MagicMock()
self.service._impl.list_encryption_type.return_value = ["encryption"]