diff options
| author | Alistair Coles <alistair.coles@hp.com> | 2015-09-08 10:22:32 +0100 |
|---|---|---|
| committer | Alistair Coles <alistair.coles@hp.com> | 2015-09-08 10:22:32 +0100 |
| commit | 1841bd6010e91859a4fe97afa4da980b8daa1e03 (patch) | |
| tree | 67c36173db898a760ca266506c90241dbd19a16d /tests/unit/test_shell.py | |
| parent | 7cd2a01cda4ac592dee465d4acf8a0b246354328 (diff) | |
| download | python-swiftclient-1841bd6010e91859a4fe97afa4da980b8daa1e03.tar.gz | |
Initialise delete_object mock before it is called
Attempt to fix the linked bug by initialising the mock instance for
Connection.delete_object before calling the SwiftService upload
method, so that the delete_object mock already exists before the
delete_segments jobs that run in multiple threads call it. Otherwise
there is a risk that the delete_segment job threads could race while
creating either the delete_object mock or the
delete_object.return_value mock, resulting in each thread getting a
different instance. That would explain the intermittent test failures
reported in the bug.
Change-Id: Ia82697c093529076b0bbcc6bccd577afdf0839e1
Partial-Bug: #1480223
Diffstat (limited to 'tests/unit/test_shell.py')
| -rw-r--r-- | tests/unit/test_shell.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py index e2b87d0..66bf328 100644 --- a/tests/unit/test_shell.py +++ b/tests/unit/test_shell.py @@ -538,6 +538,9 @@ class TestShell(unittest.TestCase): b' {"name": "container2/old_seg2"}]' ) connection.return_value.put_object.return_value = EMPTY_ETAG + # create the delete_object child mock here in attempt to fix + # https://bugs.launchpad.net/python-swiftclient/+bug/1480223 + connection.return_value.delete_object.return_value = None swiftclient.shell.main(argv) connection.return_value.put_object.assert_called_with( 'container', @@ -604,9 +607,11 @@ class TestShell(unittest.TestCase): 'last_modified': '123T456'}]], [None, []] ] - connection.return_value.put_object.return_value = ( - 'd41d8cd98f00b204e9800998ecf8427e') + connection.return_value.put_object.return_value = EMPTY_ETAG swiftclient.shell.main(argv) + # create the delete_object child mock here in attempt to fix + # https://bugs.launchpad.net/python-swiftclient/+bug/1480223 + connection.return_value.delete_object.return_value = None connection.return_value.put_object.assert_called_with( 'container', self.tmpfile.lstrip('/'), |
