Fix for random test failure on restore.py
This patch fixes a random failure that was happening during the jenkins build. Change-Id: I1f13fc9b047e8014acbf645c86c93de7e963145b
This commit is contained in:
parent
1a69e26f34
commit
58356772fa
@ -205,7 +205,8 @@ class FakeBackup:
|
|||||||
|
|
||||||
|
|
||||||
class FakeMultiProcessing:
|
class FakeMultiProcessing:
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
|
def __init__(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Queue:
|
class Queue:
|
||||||
@ -252,8 +253,9 @@ class FakeMultiProcessing:
|
|||||||
|
|
||||||
class Process:
|
class Process:
|
||||||
def __init__(self, target=True, args=True):
|
def __init__(self, target=True, args=True):
|
||||||
|
self.target = target
|
||||||
|
self.args = args
|
||||||
self.exitcode = 0
|
self.exitcode = 0
|
||||||
return None
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
return True
|
return True
|
||||||
@ -317,8 +319,9 @@ class FakeMultiProcessing1:
|
|||||||
|
|
||||||
class Process:
|
class Process:
|
||||||
def __init__(self, target=True, args=True):
|
def __init__(self, target=True, args=True):
|
||||||
|
self.target = target
|
||||||
|
self.args = args
|
||||||
self.exitcode = 1
|
self.exitcode = 1
|
||||||
return None
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
return True
|
return True
|
||||||
@ -762,12 +765,12 @@ class BackupOpt1:
|
|||||||
'test-hostname_test-backup-name_1234567_0',
|
'test-hostname_test-backup-name_1234567_0',
|
||||||
'test-hostname_test-backup-name_1234568_1',
|
'test-hostname_test-backup-name_1234568_1',
|
||||||
'test-hostname_test-backup-name_1234569_2',
|
'test-hostname_test-backup-name_1234569_2',
|
||||||
'test-hostname_test-backup-name_1234569_3',
|
'test-hostname_test-backup-name_1234570_3',
|
||||||
'test-hostname_test-backup-name_1234569_4',
|
'test-hostname_test-backup-name_1234571_4',
|
||||||
'test-hostname_test-backup-name_1234569_5',
|
'test-hostname_test-backup-name_1234572_5',
|
||||||
'tar_metadata_test-hostname_test-backup-name_1234569_5',
|
'tar_metadata_test-hostname_test-backup-name_1234572_5',
|
||||||
'tar_metadata_test-hostname_test-backup-name_1234569_4',
|
'tar_metadata_test-hostname_test-backup-name_1234571_4',
|
||||||
'tar_metadata_test-hostname_test-backup-name_1234569_3',
|
'tar_metadata_test-hostname_test-backup-name_1234570_3',
|
||||||
'tar_metadata_test-hostname_test-backup-name_1234569_2',
|
'tar_metadata_test-hostname_test-backup-name_1234569_2',
|
||||||
'tar_metadata_test-hostname_test-backup-name_1234568_1',
|
'tar_metadata_test-hostname_test-backup-name_1234568_1',
|
||||||
'tar_metadata_test-hostname_test-backup-name_1234567_0']
|
'tar_metadata_test-hostname_test-backup-name_1234567_0']
|
||||||
|
@ -68,18 +68,27 @@ class TestRestore:
|
|||||||
|
|
||||||
def test_restore_fs_sort_obj(self, monkeypatch):
|
def test_restore_fs_sort_obj(self, monkeypatch):
|
||||||
|
|
||||||
backup_opt = BackupOpt1()
|
|
||||||
fakelogging = FakeLogging()
|
fakelogging = FakeLogging()
|
||||||
|
# TEST 1
|
||||||
|
backup_opt = BackupOpt1()
|
||||||
|
fakemultiprocessing = FakeMultiProcessing()
|
||||||
monkeypatch.setattr(logging, 'critical', fakelogging.critical)
|
monkeypatch.setattr(logging, 'critical', fakelogging.critical)
|
||||||
monkeypatch.setattr(logging, 'warning', fakelogging.warning)
|
monkeypatch.setattr(logging, 'warning', fakelogging.warning)
|
||||||
monkeypatch.setattr(logging, 'exception', fakelogging.exception)
|
monkeypatch.setattr(logging, 'exception', fakelogging.exception)
|
||||||
monkeypatch.setattr(logging, 'error', fakelogging.error)
|
monkeypatch.setattr(logging, 'error', fakelogging.error)
|
||||||
|
monkeypatch.setattr(multiprocessing, 'Process', fakemultiprocessing.Process)
|
||||||
assert restore_fs_sort_obj(backup_opt) is None
|
assert restore_fs_sort_obj(backup_opt) is None
|
||||||
|
|
||||||
|
# TEST 2
|
||||||
backup_opt = BackupOpt1()
|
backup_opt = BackupOpt1()
|
||||||
backup_opt.backup_name = 'abcdtest'
|
backup_opt.backup_name = 'abcdtest'
|
||||||
|
monkeypatch.setattr(multiprocessing, 'Process', fakemultiprocessing.Process)
|
||||||
|
pytest.raises(Exception, restore_fs_sort_obj, backup_opt)
|
||||||
|
|
||||||
|
# TEST 3
|
||||||
|
backup_opt = BackupOpt1()
|
||||||
|
fakemultiprocessing = FakeMultiProcessing1()
|
||||||
|
monkeypatch.setattr(multiprocessing, 'Process', fakemultiprocessing.Process)
|
||||||
pytest.raises(Exception, restore_fs_sort_obj, backup_opt)
|
pytest.raises(Exception, restore_fs_sort_obj, backup_opt)
|
||||||
|
|
||||||
def test_restore_cinder_by_glance(self):
|
def test_restore_cinder_by_glance(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user