From 58356772fa179eb6fc5f692b89311009ccf56b2c Mon Sep 17 00:00:00 2001 From: Fausto Marzi Date: Sun, 21 Jun 2015 14:02:58 +0100 Subject: [PATCH] Fix for random test failure on restore.py This patch fixes a random failure that was happening during the jenkins build. Change-Id: I1f13fc9b047e8014acbf645c86c93de7e963145b --- tests/commons.py | 21 ++++++++++++--------- tests/test_restore.py | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/commons.py b/tests/commons.py index df91761a..d16e56ba 100644 --- a/tests/commons.py +++ b/tests/commons.py @@ -205,7 +205,8 @@ class FakeBackup: class FakeMultiProcessing: - def __init__(self, *args, **kwargs): + + def __init__(self): return None class Queue: @@ -252,8 +253,9 @@ class FakeMultiProcessing: class Process: def __init__(self, target=True, args=True): + self.target = target + self.args = args self.exitcode = 0 - return None def start(self): return True @@ -317,8 +319,9 @@ class FakeMultiProcessing1: class Process: def __init__(self, target=True, args=True): + self.target = target + self.args = args self.exitcode = 1 - return None def start(self): return True @@ -762,12 +765,12 @@ class BackupOpt1: 'test-hostname_test-backup-name_1234567_0', 'test-hostname_test-backup-name_1234568_1', 'test-hostname_test-backup-name_1234569_2', - 'test-hostname_test-backup-name_1234569_3', - 'test-hostname_test-backup-name_1234569_4', - 'test-hostname_test-backup-name_1234569_5', - 'tar_metadata_test-hostname_test-backup-name_1234569_5', - 'tar_metadata_test-hostname_test-backup-name_1234569_4', - 'tar_metadata_test-hostname_test-backup-name_1234569_3', + 'test-hostname_test-backup-name_1234570_3', + 'test-hostname_test-backup-name_1234571_4', + 'test-hostname_test-backup-name_1234572_5', + 'tar_metadata_test-hostname_test-backup-name_1234572_5', + 'tar_metadata_test-hostname_test-backup-name_1234571_4', + '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_1234568_1', 'tar_metadata_test-hostname_test-backup-name_1234567_0'] diff --git a/tests/test_restore.py b/tests/test_restore.py index 9044c6bb..d5eea6d2 100644 --- a/tests/test_restore.py +++ b/tests/test_restore.py @@ -68,18 +68,27 @@ class TestRestore: def test_restore_fs_sort_obj(self, monkeypatch): - backup_opt = BackupOpt1() fakelogging = FakeLogging() - + # TEST 1 + backup_opt = BackupOpt1() + fakemultiprocessing = FakeMultiProcessing() monkeypatch.setattr(logging, 'critical', fakelogging.critical) monkeypatch.setattr(logging, 'warning', fakelogging.warning) monkeypatch.setattr(logging, 'exception', fakelogging.exception) monkeypatch.setattr(logging, 'error', fakelogging.error) - + monkeypatch.setattr(multiprocessing, 'Process', fakemultiprocessing.Process) assert restore_fs_sort_obj(backup_opt) is None + # TEST 2 backup_opt = BackupOpt1() 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) def test_restore_cinder_by_glance(self):