Merge "Prevent down nodes failing PUTs with non-ascii obj names"

This commit is contained in:
Jenkins 2016-07-06 22:03:50 +00:00 committed by Gerrit Code Review
commit 561284e3d4
3 changed files with 19 additions and 3 deletions

View File

@ -535,7 +535,7 @@ class Application(object):
' re: %(info)s'),
{'type': typ, 'ip': node['ip'],
'port': node['port'], 'device': node['device'],
'info': additional_info},
'info': additional_info.decode('utf-8')},
**kwargs)
def modify_wsgi_pipeline(self, pipe):

View File

@ -32,6 +32,7 @@ import eventlet
from eventlet.green import socket
from tempfile import mkdtemp
from shutil import rmtree
import json
from swift.common.utils import Timestamp, NOTICE
@ -223,7 +224,8 @@ class FakeRing(Ring):
for x in range(self.replicas):
ip = '10.0.0.%s' % x
port = self._base_port + x
self._devs.append({
# round trip through json to ensure unicode like real rings
self._devs.append(json.loads(json.dumps({
'ip': ip,
'replication_ip': ip,
'port': port,
@ -232,7 +234,7 @@ class FakeRing(Ring):
'zone': x % 3,
'region': x % 2,
'id': x,
})
})))
@property
def replica_count(self):

View File

@ -856,6 +856,20 @@ class TestReplicatedObjController(BaseObjectControllerMixin,
node_error_count(self.app, object_ring.devs[1]),
self.app.error_suppression_limit + 1)
def test_PUT_connect_exception_with_unicode_path_and_locale(self):
expected = 201
statuses = (
Exception('Connection refused: Please insert ten dollars'),
201, 201)
req = swob.Request.blank('/v1/AUTH_kilroy/%ED%88%8E/%E9%90%89',
method='PUT',
body='life is utf-gr8')
with set_http_connect(*statuses):
resp = req.get_response(self.app)
self.assertEqual(resp.status_int, expected)
def test_PUT_error_during_transfer_data(self):
class FakeReader(object):
def read(self, size):