Merge "Add Cinder create_and_list_volume_backups scenario"
This commit is contained in:
commit
067e711bd1
@ -410,3 +410,41 @@
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
CinderVolumes.create_and_list_volume_backups:
|
||||
-
|
||||
args:
|
||||
size: 1
|
||||
detailed: True
|
||||
do_delete: True
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 2
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
roles:
|
||||
- "Member"
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
-
|
||||
args:
|
||||
size: 1
|
||||
detailed: True
|
||||
do_delete: False
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 2
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
roles:
|
||||
- "Member"
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
@ -308,3 +308,21 @@
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
CinderVolumes.create_and_list_volume_backups:
|
||||
-
|
||||
args:
|
||||
size: 1
|
||||
detailed: True
|
||||
do_delete: True
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 2
|
||||
concurrency: 1
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
@ -323,6 +323,15 @@ class CinderScenario(scenario.OpenStackScenario):
|
||||
check_interval=CONF.benchmark.cinder_volume_create_poll_interval
|
||||
)
|
||||
|
||||
@base.atomic_action_timer("cinder.list_backups")
|
||||
def _list_backups(self, detailed=True):
|
||||
"""Return user volume backups list.
|
||||
|
||||
:param detailed: True if detailed information about backup
|
||||
should be listed
|
||||
"""
|
||||
return self.clients("cinder").backups.list(detailed)
|
||||
|
||||
def get_random_server(self):
|
||||
server_id = random.choice(self.context["tenant"]["servers"])
|
||||
return self.clients("nova").servers.get(server_id)
|
||||
|
@ -479,3 +479,32 @@ class CinderVolumes(utils.CinderScenario,
|
||||
if do_delete:
|
||||
self._delete_volume(volume)
|
||||
self._delete_backup(backup)
|
||||
|
||||
@validation.required_cinder_services("cinder-backup")
|
||||
@validation.required_services(consts.Service.CINDER)
|
||||
@validation.required_openstack(users=True)
|
||||
@base.scenario(context={"cleanup": ["cinder"]})
|
||||
def create_and_list_volume_backups(self, size, detailed=True,
|
||||
do_delete=True,
|
||||
create_volume_kwargs=None,
|
||||
create_backup_kwargs=None):
|
||||
"""Create and then list a volume backup.
|
||||
|
||||
|
||||
:param size: volume size in GB
|
||||
:param detailed: True if detailed information about backup
|
||||
should be listed
|
||||
:param do_delete: if True, a volume backup will be deleted
|
||||
:param create_volume_kwargs: optional args to create a volume
|
||||
:param create_backup_kwargs: optional args to create a volume backup
|
||||
"""
|
||||
create_volume_kwargs = create_volume_kwargs or {}
|
||||
create_backup_kwargs = create_backup_kwargs or {}
|
||||
|
||||
volume = self._create_volume(size, **create_volume_kwargs)
|
||||
backup = self._create_backup(volume.id, **create_backup_kwargs)
|
||||
self._list_backups(detailed)
|
||||
|
||||
if do_delete:
|
||||
self._delete_volume(volume)
|
||||
self._delete_backup(backup)
|
||||
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"CinderVolumes.create_and_list_volume_backups": [
|
||||
{
|
||||
"args": {
|
||||
"size": 1,
|
||||
"detailed": true,
|
||||
"do_delete": true
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 2,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 1,
|
||||
"users_per_tenant": 1
|
||||
},
|
||||
"roles": ["Member"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
---
|
||||
CinderVolumes.create_and_list_volume_backups:
|
||||
-
|
||||
args:
|
||||
size: 1
|
||||
detailed: True
|
||||
do_delete: True
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 2
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
roles:
|
||||
- "Member"
|
@ -294,6 +294,14 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.restore_backup")
|
||||
|
||||
def test__list_backups(self):
|
||||
return_backups_list = self.scenario._list_backups()
|
||||
self.assertEqual(
|
||||
self.clients("cinder").backups.list.return_value,
|
||||
return_backups_list)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"cinder.list_backups")
|
||||
|
||||
def test__get_random_server(self):
|
||||
servers = [1, 2, 3]
|
||||
context = {"user": {"tenant_id": "fake"},
|
||||
|
@ -408,15 +408,15 @@ class CinderServersTestCase(test.ScenarioTestCase):
|
||||
self.assertFalse(scenario._delete_volume.called)
|
||||
self.assertFalse(scenario._delete_backup.called)
|
||||
|
||||
def _get_scenario(self, fake_volume, fake_backup, fake_restore):
|
||||
def _get_scenario(self, fake_volume, fake_backup, fake_restore=None):
|
||||
scenario = volumes.CinderVolumes()
|
||||
|
||||
scenario._create_volume = mock.MagicMock(return_value=fake_volume)
|
||||
scenario._create_backup = mock.MagicMock(return_value=fake_backup)
|
||||
scenario._restore_backup = mock.MagicMock(return_value=fake_restore)
|
||||
scenario._list_backups = mock.MagicMock()
|
||||
scenario._delete_volume = mock.MagicMock()
|
||||
scenario._delete_backup = mock.MagicMock()
|
||||
|
||||
return scenario
|
||||
|
||||
def test_create_and_restore_volume_backup(self):
|
||||
@ -448,3 +448,33 @@ class CinderServersTestCase(test.ScenarioTestCase):
|
||||
scenario._restore_backup.assert_called_once_with(fake_backup.id)
|
||||
self.assertFalse(scenario._delete_volume.called)
|
||||
self.assertFalse(scenario._delete_backup.called)
|
||||
|
||||
def test_create_and_list_volume_backups(self):
|
||||
fake_volume = mock.MagicMock()
|
||||
fake_backup = mock.MagicMock()
|
||||
scenario = self._get_scenario(fake_volume, fake_backup)
|
||||
|
||||
volume_kwargs = {"some_var": "zaq"}
|
||||
scenario.create_and_list_volume_backups(
|
||||
1, detailed=True, do_delete=True,
|
||||
create_volume_kwargs=volume_kwargs)
|
||||
scenario._create_volume.assert_called_once_with(1, **volume_kwargs)
|
||||
scenario._create_backup.assert_called_once_with(fake_volume.id)
|
||||
scenario._list_backups.assert_called_once_with(True)
|
||||
scenario._delete_volume.assert_called_once_with(fake_volume)
|
||||
scenario._delete_backup.assert_called_once_with(fake_backup)
|
||||
|
||||
def test_create_and_list_volume_backups_no_delete(self):
|
||||
fake_volume = mock.MagicMock()
|
||||
fake_backup = mock.MagicMock()
|
||||
scenario = self._get_scenario(fake_volume, fake_backup)
|
||||
|
||||
volume_kwargs = {"some_var": "zaq"}
|
||||
scenario.create_and_list_volume_backups(
|
||||
1, detailed=True, do_delete=False,
|
||||
create_volume_kwargs=volume_kwargs)
|
||||
scenario._create_volume.assert_called_once_with(1, **volume_kwargs)
|
||||
scenario._create_backup.assert_called_once_with(fake_volume.id)
|
||||
scenario._list_backups.assert_called_once_with(True)
|
||||
self.assertFalse(scenario._delete_volume.called)
|
||||
self.assertFalse(scenario._delete_backup.called)
|
||||
|
Loading…
Reference in New Issue
Block a user