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)
|
||||
|
||||
proc_failed = False
|
||||
try:
|
||||
subprocess.check_call(script, shell=True)
|
||||
except subprocess.CalledProcessError:
|
||||
proc_failed = True
|
||||
msg = 'File system backup failed'
|
||||
os.remove(self.outfile)
|
||||
if self.sources_path:
|
||||
try:
|
||||
subprocess.check_call(script, shell=True)
|
||||
except subprocess.CalledProcessError:
|
||||
proc_failed = True
|
||||
msg = 'File system backup failed'
|
||||
os.remove(self.outfile)
|
||||
else:
|
||||
msg = ('File system backup created succesfully at: %s'
|
||||
% self.outfile)
|
||||
else:
|
||||
msg = 'File system backup created succesfully at: ' + self.outfile
|
||||
msg = 'File system backup has no files to backup'
|
||||
|
||||
if proc_failed:
|
||||
# Delete failed backup here
|
||||
|
@ -101,6 +101,9 @@ class CreateFileSystemBackupTest(base.TestCase):
|
||||
self.fsback = undercloud.CreateFileSystemBackup(
|
||||
'/home/stack/,/etc/hosts',
|
||||
'/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('subprocess.check_call')
|
||||
@ -120,6 +123,16 @@ class CreateFileSystemBackupTest(base.TestCase):
|
||||
'\n ')
|
||||
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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user