Modified REPLICATE request to use replication_ip

direct_client.direct_get_suffix_hashes doesn't use replication ip and
port for REPLICATE request. Since we have an option of doing
replication in separate network, we can add replication_ip and port
while creating rings if not it will get filled in with the regular
node's ip.
Change-Id: I34067df27042fc3146b795191ab8043ee1aed3ce
Closes-Bug:1566395
This commit is contained in:
Sivasathurappan Radhakrishnan
2016年04月05日 22:45:17 +00:00
parent da6031067e
commit 950b601a9c

View File

@@ -482,8 +482,9 @@ def direct_get_suffix_hashes(node, part, suffixes, conn_timeout=5,
path = '/%s' % '-'.join(suffixes)
with Timeout(conn_timeout):
conn = http_connect(node['ip'], node['port'], node['device'], part,
'REPLICATE', path, headers=gen_headers(headers))
conn = http_connect(node['replication_ip'], node['replication_port'],
node['device'], part, 'REPLICATE', path,
headers=gen_headers(headers))
with Timeout(response_timeout):
resp = conn.getresponse()
if not is_success(resp.status):

View File

@@ -19,6 +19,7 @@ import os
from contextlib import contextmanager
from hashlib import md5
import time
import pickle
import mock
import six
@@ -97,7 +98,8 @@ def mocked_http_conn(*args, **kwargs):
class TestDirectClient(unittest.TestCase):
def setUp(self):
self.node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda'}
self.node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda',
'replication_ip': '1.2.3.5', 'replication_port': '7000'}
self.part = '0'
self.account = u'\u062a account'
@@ -617,6 +619,18 @@ class TestDirectClient(unittest.TestCase):
self.assertEqual(err.http_status, 503)
self.assertTrue('DELETE' in str(err))
def test_direct_get_suffix_hashes(self):
data = {'a83': 'c130a2c17ed45102aada0f4eee69494ff'}
body = pickle.dumps(data)
with mocked_http_conn(200, {}, body) as conn:
resp = direct_client.direct_get_suffix_hashes(self.node,
self.part, ['a83'])
self.assertEqual(conn.method, 'REPLICATE')
self.assertEqual(conn.path, '/sda/0/a83')
self.assertEqual(conn.host, '1.2.3.5')
self.assertEqual(conn.port, '7000')
self.assertEqual(data, resp)
def test_direct_put_object_with_content_length(self):
contents = six.StringIO('123456')
Reference in New Issue
openstack/swift
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.