summaryrefslogtreecommitdiff
path: root/test/unit/container/test_sync.py
diff options
context:
space:
mode:
authorChristian Schwede <christian.schwede@enovance.com>2015-02-18 10:17:23 +0000
committerChristian Schwede <christian.schwede@enovance.com>2015-04-10 10:06:40 +0000
commit16ee994c1ea4ddcfaeae26babada6382daa69bc9 (patch)
tree7d68b7514caa8f4dbeb4ef643dd0b79dd6ff3f42 /test/unit/container/test_sync.py
parenteb6a4cbec5dbd74b169f49ebc2083f2857b9bd28 (diff)
downloadswift-16ee994c1ea4ddcfaeae26babada6382daa69bc9.tar.gz
Set connection timeout in container sync
Container sync might get stuck without a connection timeout if the remote proxy is not responding. This patch sets a default timeout of 5.0 seconds for the connection attempt. The value is much higher than other connection timeouts inside Swift (0.5); however there might be a much higher latency to the remote peer, thus playing it safe. There is also a retry if the attempt timed out. Note that this setting only applies to the connection request itself. Setting this timeout does not apply when the remote proxy goes away during a request. Also added a short test to ensure urlopen is called with the timeout value. Co-Authored-By: Alistair Coles <alistair.coles@hp.com> Change-Id: Ic08a55157fa91fe1316653781adf4d66eead61bc Partial-Bug: 1419916
Diffstat (limited to 'test/unit/container/test_sync.py')
-rw-r--r--test/unit/container/test_sync.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/unit/container/test_sync.py b/test/unit/container/test_sync.py
index 645c7935c..aa5cebc28 100644
--- a/test/unit/container/test_sync.py
+++ b/test/unit/container/test_sync.py
@@ -652,7 +652,7 @@ class TestContainerSync(unittest.TestCase):
fake_logger = FakeLogger()
def fake_delete_object(path, name=None, headers=None, proxy=None,
- logger=None):
+ logger=None, timeout=None):
self.assertEquals(path, 'http://sync/to/path')
self.assertEquals(name, 'object')
if realm:
@@ -666,6 +666,7 @@ class TestContainerSync(unittest.TestCase):
{'x-container-sync-key': 'key', 'x-timestamp': '1.2'})
self.assertEquals(proxy, 'http://proxy')
self.assertEqual(logger, fake_logger)
+ self.assertEqual(timeout, 5.0)
sync.delete_object = fake_delete_object
cs = sync.ContainerSync({}, container_ring=FakeRing())
@@ -759,7 +760,8 @@ class TestContainerSync(unittest.TestCase):
fake_logger = FakeLogger()
def fake_put_object(sync_to, name=None, headers=None,
- contents=None, proxy=None, logger=None):
+ contents=None, proxy=None, logger=None,
+ timeout=None):
self.assertEquals(sync_to, 'http://sync/to/path')
self.assertEquals(name, 'object')
if realm:
@@ -780,6 +782,7 @@ class TestContainerSync(unittest.TestCase):
self.assertEquals(contents.read(), 'contents')
self.assertEquals(proxy, 'http://proxy')
self.assertEqual(logger, fake_logger)
+ self.assertEqual(timeout, 5.0)
sync.put_object = fake_put_object