Merge "Refactoring cinder create_volume_backup scenario"
This commit is contained in:
commit
43aa8a53b3
@ -437,16 +437,22 @@ class CinderVolumes(utils.CinderScenario,
|
|||||||
@validation.required_services(consts.Service.CINDER)
|
@validation.required_services(consts.Service.CINDER)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@base.scenario(context={"cleanup": ["cinder"]})
|
@base.scenario(context={"cleanup": ["cinder"]})
|
||||||
def create_volume_backup(self, size, do_delete=True, **kwargs):
|
def create_volume_backup(self, size, do_delete=True,
|
||||||
|
create_volume_kwargs=None,
|
||||||
|
create_backup_kwargs=None):
|
||||||
"""Create a volume backup.
|
"""Create a volume backup.
|
||||||
|
|
||||||
:param size: volume size in GB
|
:param size: volume size in GB
|
||||||
:param do_delete: if True, a volume and a volume backup will
|
:param do_delete: if True, a volume and a volume backup will
|
||||||
be deleted after creation.
|
be deleted after creation.
|
||||||
:param kwargs: optional args to create a volume backup
|
:param create_volume_kwargs: optional args to create a volume
|
||||||
|
:param create_backup_kwargs: optional args to create a volume backup
|
||||||
"""
|
"""
|
||||||
volume = self._create_volume(size, **kwargs)
|
create_volume_kwargs = create_volume_kwargs or {}
|
||||||
backup = self._create_backup(volume.id, **kwargs)
|
create_backup_kwargs = create_backup_kwargs or {}
|
||||||
|
|
||||||
|
volume = self._create_volume(size, **create_volume_kwargs)
|
||||||
|
backup = self._create_backup(volume.id, **create_backup_kwargs)
|
||||||
|
|
||||||
if do_delete:
|
if do_delete:
|
||||||
self._delete_volume(volume)
|
self._delete_volume(volume)
|
||||||
@ -467,10 +473,8 @@ class CinderVolumes(utils.CinderScenario,
|
|||||||
:param create_volume_kwargs: optional args to create a volume
|
:param create_volume_kwargs: optional args to create a volume
|
||||||
:param create_backup_kwargs: optional args to create a volume backup
|
:param create_backup_kwargs: optional args to create a volume backup
|
||||||
"""
|
"""
|
||||||
if create_volume_kwargs is None:
|
create_volume_kwargs = create_volume_kwargs or {}
|
||||||
create_volume_kwargs = {}
|
create_backup_kwargs = create_backup_kwargs or {}
|
||||||
if create_backup_kwargs is None:
|
|
||||||
create_backup_kwargs = {}
|
|
||||||
|
|
||||||
volume = self._create_volume(size, **create_volume_kwargs)
|
volume = self._create_volume(size, **create_volume_kwargs)
|
||||||
backup = self._create_backup(volume.id, **create_backup_kwargs)
|
backup = self._create_backup(volume.id, **create_backup_kwargs)
|
||||||
@ -490,7 +494,6 @@ class CinderVolumes(utils.CinderScenario,
|
|||||||
create_backup_kwargs=None):
|
create_backup_kwargs=None):
|
||||||
"""Create and then list a volume backup.
|
"""Create and then list a volume backup.
|
||||||
|
|
||||||
|
|
||||||
:param size: volume size in GB
|
:param size: volume size in GB
|
||||||
:param detailed: True if detailed information about backup
|
:param detailed: True if detailed information about backup
|
||||||
should be listed
|
should be listed
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
"args": {
|
"args": {
|
||||||
"size": 1,
|
"size": 1,
|
||||||
"detailed": true,
|
"detailed": true,
|
||||||
"do_delete": true
|
"do_delete": true,
|
||||||
|
"create_volume_kwargs": {},
|
||||||
|
"create_backup_kwargs": {}
|
||||||
},
|
},
|
||||||
"runner": {
|
"runner": {
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
size: 1
|
size: 1
|
||||||
detailed: True
|
detailed: True
|
||||||
do_delete: True
|
do_delete: True
|
||||||
|
create_volume_kwargs: {}
|
||||||
|
create_backup_kwargs: {}
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 2
|
times: 2
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
{
|
{
|
||||||
"args": {
|
"args": {
|
||||||
"size": 1,
|
"size": 1,
|
||||||
"do_delete": true
|
"do_delete": true,
|
||||||
|
"create_volume_kwargs": {},
|
||||||
|
"create_backup_kwargs": {}
|
||||||
},
|
},
|
||||||
"runner": {
|
"runner": {
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
args:
|
args:
|
||||||
size: 1
|
size: 1
|
||||||
do_delete: True
|
do_delete: True
|
||||||
|
create_volume_kwargs: {}
|
||||||
|
create_backup_kwargs: {}
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 2
|
times: 2
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
{
|
{
|
||||||
"args": {
|
"args": {
|
||||||
"size": 1,
|
"size": 1,
|
||||||
"do_delete": true
|
"do_delete": true,
|
||||||
|
"create_volume_kwargs": {},
|
||||||
|
"create_backup_kwargs": {}
|
||||||
},
|
},
|
||||||
"runner": {
|
"runner": {
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
args:
|
args:
|
||||||
size: 1
|
size: 1
|
||||||
do_delete: True
|
do_delete: True
|
||||||
|
create_volume_kwargs: {}
|
||||||
|
create_backup_kwargs: {}
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 2
|
times: 2
|
||||||
|
@ -377,34 +377,26 @@ class CinderServersTestCase(test.ScenarioTestCase):
|
|||||||
def test_create_volume_backup(self):
|
def test_create_volume_backup(self):
|
||||||
fake_volume = mock.MagicMock()
|
fake_volume = mock.MagicMock()
|
||||||
fake_backup = mock.MagicMock()
|
fake_backup = mock.MagicMock()
|
||||||
scenario = volumes.CinderVolumes()
|
scenario = self._get_scenario(fake_volume, fake_backup)
|
||||||
|
|
||||||
scenario._create_volume = mock.MagicMock(return_value=fake_volume)
|
volume_kwargs = {"some_var": "zaq"}
|
||||||
scenario._create_backup = mock.MagicMock(return_value=fake_backup)
|
scenario.create_volume_backup(
|
||||||
scenario._delete_volume = mock.MagicMock()
|
1, do_delete=True, create_volume_kwargs=volume_kwargs)
|
||||||
scenario._delete_backup = mock.MagicMock()
|
scenario._create_volume.assert_called_once_with(1, **volume_kwargs)
|
||||||
|
scenario._create_backup.assert_called_once_with(fake_volume.id)
|
||||||
scenario.create_volume_backup(1, do_delete=True, fakearg="f")
|
|
||||||
scenario._create_volume.assert_called_once_with(1, fakearg="f")
|
|
||||||
scenario._create_backup.assert_called_once_with(fake_volume.id,
|
|
||||||
fakearg="f")
|
|
||||||
scenario._delete_volume.assert_called_once_with(fake_volume)
|
scenario._delete_volume.assert_called_once_with(fake_volume)
|
||||||
scenario._delete_backup.assert_called_once_with(fake_backup)
|
scenario._delete_backup.assert_called_once_with(fake_backup)
|
||||||
|
|
||||||
def test_create_volume_backup_no_delete(self):
|
def test_create_volume_backup_no_delete(self):
|
||||||
fake_volume = mock.MagicMock()
|
fake_volume = mock.MagicMock()
|
||||||
fake_backup = mock.MagicMock()
|
fake_backup = mock.MagicMock()
|
||||||
scenario = volumes.CinderVolumes()
|
scenario = self._get_scenario(fake_volume, fake_backup)
|
||||||
|
|
||||||
scenario._create_volume = mock.MagicMock(return_value=fake_volume)
|
volume_kwargs = {"some_var": "zaq"}
|
||||||
scenario._create_backup = mock.MagicMock(return_value=fake_backup)
|
scenario.create_volume_backup(
|
||||||
scenario._delete_volume = mock.MagicMock()
|
1, do_delete=False, create_volume_kwargs=volume_kwargs)
|
||||||
scenario._delete_backup = mock.MagicMock()
|
scenario._create_volume.assert_called_once_with(1, **volume_kwargs)
|
||||||
|
scenario._create_backup.assert_called_once_with(fake_volume.id)
|
||||||
scenario.create_volume_backup(1, do_delete=False, fakearg="f")
|
|
||||||
scenario._create_volume.assert_called_once_with(1, fakearg="f")
|
|
||||||
scenario._create_backup.assert_called_once_with(fake_volume.id,
|
|
||||||
fakearg="f")
|
|
||||||
self.assertFalse(scenario._delete_volume.called)
|
self.assertFalse(scenario._delete_volume.called)
|
||||||
self.assertFalse(scenario._delete_backup.called)
|
self.assertFalse(scenario._delete_backup.called)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user