Merge "Add validation for empty file system backup on Undercloud"
This commit is contained in:
commit
7cbad7c199
@ -161,14 +161,18 @@ class CreateFileSystemBackup(base.Action):
|
|||||||
""" % (self.outfile, separated_string, self.outfile)
|
""" % (self.outfile, separated_string, self.outfile)
|
||||||
|
|
||||||
proc_failed = False
|
proc_failed = False
|
||||||
try:
|
if self.sources_path:
|
||||||
subprocess.check_call(script, shell=True)
|
try:
|
||||||
except subprocess.CalledProcessError:
|
subprocess.check_call(script, shell=True)
|
||||||
proc_failed = True
|
except subprocess.CalledProcessError:
|
||||||
msg = 'File system backup failed'
|
proc_failed = True
|
||||||
os.remove(self.outfile)
|
msg = 'File system backup failed'
|
||||||
|
os.remove(self.outfile)
|
||||||
|
else:
|
||||||
|
msg = ('File system backup created succesfully at: %s'
|
||||||
|
% self.outfile)
|
||||||
else:
|
else:
|
||||||
msg = 'File system backup created succesfully at: ' + self.outfile
|
msg = 'File system backup has no files to backup'
|
||||||
|
|
||||||
if proc_failed:
|
if proc_failed:
|
||||||
# Delete failed backup here
|
# Delete failed backup here
|
||||||
|
@ -101,6 +101,9 @@ class CreateFileSystemBackupTest(base.TestCase):
|
|||||||
self.fsback = undercloud.CreateFileSystemBackup(
|
self.fsback = undercloud.CreateFileSystemBackup(
|
||||||
'/home/stack/,/etc/hosts',
|
'/home/stack/,/etc/hosts',
|
||||||
'/var/tmp/undercloud-backup-ef9b_H')
|
'/var/tmp/undercloud-backup-ef9b_H')
|
||||||
|
self.fsemptyback = undercloud.CreateFileSystemBackup(
|
||||||
|
'',
|
||||||
|
'/var/tmp/undercloud-backup-ef9b_H')
|
||||||
|
|
||||||
@mock.patch('tripleo_common.actions.base.TripleOAction.get_object_client')
|
@mock.patch('tripleo_common.actions.base.TripleOAction.get_object_client')
|
||||||
@mock.patch('subprocess.check_call')
|
@mock.patch('subprocess.check_call')
|
||||||
@ -120,6 +123,16 @@ class CreateFileSystemBackupTest(base.TestCase):
|
|||||||
'\n ')
|
'\n ')
|
||||||
mock_check_call.assert_called_once_with(assert_string, shell=True)
|
mock_check_call.assert_called_once_with(assert_string, shell=True)
|
||||||
|
|
||||||
|
@mock.patch('tripleo_common.actions.base.TripleOAction.get_object_client')
|
||||||
|
@mock.patch('subprocess.check_call')
|
||||||
|
def test_create_empty_file_system_backup(
|
||||||
|
self,
|
||||||
|
mock_check_call,
|
||||||
|
mock_get_object_client):
|
||||||
|
self.fsemptyback.logger = mock.Mock()
|
||||||
|
self.fsemptyback.run(mock_get_object_client)
|
||||||
|
mock_check_call.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
class CreateBackupDirTest(base.TestCase):
|
class CreateBackupDirTest(base.TestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user