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
This commit is contained in:
parent
7cd2a01cda
commit
1841bd6010
@ -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('/'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user