Add CinderVolumeTypes.create_and_delete_encryption_type
This scenario firstly creates an encryption type for a given volume type, then deletes the created encryption type. Change-Id: I66d765f170ba7678e0a098bba2a5d6873b988dda
This commit is contained in:
parent
8625f5c3b2
commit
823562d55b
@ -867,6 +867,27 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
CinderVolumeTypes.create_and_delete_encryption_type:
|
||||
-
|
||||
args:
|
||||
create_specs:
|
||||
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_type"]
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
CinderVolumeTypes.create_volume_type_and_encryption_type:
|
||||
-
|
||||
args:
|
||||
|
@ -473,3 +473,15 @@ class CinderScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.admin_clients("cinder").volume_encryption_types.list(
|
||||
search_opts)
|
||||
|
||||
@atomic.action_timer("cinder.delete_encryption_type")
|
||||
def _delete_encryption_type(self, volume_type):
|
||||
"""Delete the encryption type information for the specified volume type.
|
||||
|
||||
:param volume_type: the volume type whose encryption type information
|
||||
must be deleted
|
||||
"""
|
||||
resp = self.admin_clients("cinder").volume_encryption_types.delete(
|
||||
volume_type)
|
||||
if (resp[0].status_code != 202):
|
||||
raise exceptions.EncryptionTypeDeleteException()
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import random
|
||||
|
||||
from rally import consts
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils
|
||||
@ -98,3 +100,24 @@ class CreateAndSetVolumeTypeKeys(cinder_utils.CinderScenario):
|
||||
volume_type = self._create_volume_type(**kwargs)
|
||||
|
||||
self._set_volume_type_keys(volume_type, volume_type_key)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.CINDER)
|
||||
@validation.required_contexts("volume_types")
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(context={"admin_cleanup": ["cinder"]},
|
||||
name="CinderVolumeTypes.create_and_delete_"
|
||||
"encryption_type")
|
||||
class CreateAndDeleteEncryptionType(cinder_utils.CinderScenario):
|
||||
|
||||
def run(self, create_specs):
|
||||
"""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
|
||||
"""
|
||||
volume_type = random.choice(self.context["volume_types"])
|
||||
self._create_encryption_type(volume_type["id"], create_specs)
|
||||
self._delete_encryption_type(volume_type["id"])
|
||||
|
@ -0,0 +1,31 @@
|
||||
{
|
||||
"CinderVolumeTypes.create_and_delete_encryption_type": [
|
||||
{
|
||||
"args": {
|
||||
"create_specs": {
|
||||
"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_type"]
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
CinderVolumeTypes.create_and_delete_encryption_type:
|
||||
-
|
||||
args:
|
||||
create_specs:
|
||||
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_type"]
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -381,6 +381,13 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.create_volume_type")
|
||||
|
||||
def test__delete_encryption_type(self):
|
||||
volume_type = mock.Mock()
|
||||
|
||||
self.assertRaises(exceptions.EncryptionTypeDeleteException,
|
||||
self.scenario._delete_encryption_type,
|
||||
volume_type)
|
||||
|
||||
def test__create_encryption_type(self):
|
||||
volume_type = mock.Mock()
|
||||
specs = {
|
||||
|
@ -24,6 +24,13 @@ class fake_type(object):
|
||||
|
||||
class CinderVolumeTypesTestCase(test.ScenarioTestCase):
|
||||
|
||||
def _get_context(self):
|
||||
context = test.get_test_context()
|
||||
context.update({
|
||||
"volume_types": [{"id": "fake_id",
|
||||
"name": "fake_name"}]})
|
||||
return context
|
||||
|
||||
def test_create_and_delete_volume_type(self):
|
||||
scenario = volume_types.CreateAndDeleteVolumeType(self.context)
|
||||
scenario._create_volume_type = mock.Mock()
|
||||
@ -34,6 +41,17 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
|
||||
scenario._delete_volume_type.assert_called_once_with(
|
||||
scenario._create_volume_type.return_value)
|
||||
|
||||
def test_create_and_delete_encryption_type(self):
|
||||
scenario = volume_types.CreateAndDeleteEncryptionType(
|
||||
self._get_context())
|
||||
scenario._create_encryption_type = mock.Mock()
|
||||
scenario._delete_encryption_type = mock.Mock()
|
||||
scenario.run(create_specs="fakecreatespecs")
|
||||
scenario._create_encryption_type.assert_called_once_with(
|
||||
"fake_id", "fakecreatespecs")
|
||||
scenario._delete_encryption_type.assert_called_once_with(
|
||||
"fake_id")
|
||||
|
||||
def test_create_volume_type_and_encryption_type(self):
|
||||
scenario = volume_types.CreateVolumeTypeAndEncryptionType(self.context)
|
||||
scenario._create_volume_type = mock.Mock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user