move test_GET_pipeline to BaseTestObjectController
Change-Id: I1f26483dbc5935052ec8df0c874ee38070b84d5b
This commit is contained in:
parent
647ee83906
commit
c4c9d5a40b
|
@ -2521,6 +2521,74 @@ class BaseTestObjectController(object):
|
|||
self.assertEqual(len(error_lines), 0) # sanity
|
||||
self.assertEqual(len(warn_lines), 0) # sanity
|
||||
|
||||
@unpatch_policies
|
||||
def test_GET_pipeline(self):
|
||||
conf = _test_context['conf']
|
||||
conf['client_timeout'] = 0.1
|
||||
prosrv = proxy_server.Application(conf, logger=debug_logger('proxy'))
|
||||
with in_process_proxy(
|
||||
prosrv, socket_timeout=conf['client_timeout']) as prolis:
|
||||
self.put_container(self.policy.name, self.policy.name,
|
||||
prolis=prolis)
|
||||
|
||||
obj = b'0123456' * 11 * 17
|
||||
|
||||
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||
fd = sock.makefile('rwb')
|
||||
fd.write(('PUT /v1/a/%s/go-get-it HTTP/1.1\r\n'
|
||||
'Host: localhost\r\n'
|
||||
'Content-Length: %d\r\n'
|
||||
'X-Storage-Token: t\r\n'
|
||||
'X-Object-Meta-Color: chartreuse\r\n'
|
||||
'Content-Type: application/octet-stream\r\n'
|
||||
'\r\n' % (
|
||||
self.policy.name,
|
||||
len(obj),
|
||||
)).encode('ascii'))
|
||||
fd.write(obj)
|
||||
fd.flush()
|
||||
headers = readuntil2crlfs(fd)
|
||||
exp = b'HTTP/1.1 201'
|
||||
self.assertEqual(headers[:len(exp)], exp)
|
||||
|
||||
fd.write(('GET /v1/a/%s/go-get-it HTTP/1.1\r\n'
|
||||
'Host: localhost\r\n'
|
||||
'X-Storage-Token: t\r\n'
|
||||
'\r\n' % self.policy.name).encode('ascii'))
|
||||
fd.flush()
|
||||
headers = readuntil2crlfs(fd)
|
||||
exp = b'HTTP/1.1 200'
|
||||
self.assertEqual(headers[:len(exp)], exp)
|
||||
for line in headers.splitlines():
|
||||
if b'Content-Length' in line:
|
||||
h, v = line.split()
|
||||
content_length = int(v.strip())
|
||||
break
|
||||
else:
|
||||
self.fail("Didn't find content-length in %r" % (headers,))
|
||||
|
||||
gotten_obj = fd.read(content_length)
|
||||
self.assertEqual(gotten_obj, obj)
|
||||
|
||||
sleep(0.3) # client_timeout should kick us off
|
||||
|
||||
fd.write(('GET /v1/a/%s/go-get-it HTTP/1.1\r\n'
|
||||
'Host: localhost\r\n'
|
||||
'X-Storage-Token: t\r\n'
|
||||
'\r\n' % self.policy.name).encode('ascii'))
|
||||
fd.flush()
|
||||
# makefile is a little weird, but this is disconnected
|
||||
self.assertEqual(b'', fd.read())
|
||||
# I expected this to raise a socket error
|
||||
self.assertEqual(b'', sock.recv(1024))
|
||||
# ... but we ARE disconnected
|
||||
with self.assertRaises(socket.error) as caught:
|
||||
sock.send(b'test')
|
||||
self.assertEqual(caught.exception.errno, errno.EPIPE)
|
||||
# and logging confirms we've timed out
|
||||
last_debug_msg = prosrv.logger.get_lines_for_level('debug')[-1]
|
||||
self.assertIn('timed out', last_debug_msg)
|
||||
|
||||
|
||||
@patch_policies([StoragePolicy(0, 'zero', True,
|
||||
object_ring=FakeRing(base_port=3000))])
|
||||
|
@ -2538,6 +2606,7 @@ class TestReplicatedObjectController(
|
|||
logger=self.logger,
|
||||
account_ring=FakeRing(),
|
||||
container_ring=FakeRing())
|
||||
self.policy = POLICIES[0]
|
||||
super(TestReplicatedObjectController, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -8195,73 +8264,6 @@ class BaseTestECObjectController(BaseTestObjectController):
|
|||
os.rename(self.ec_policy.object_ring.serialized_path + '.bak',
|
||||
self.ec_policy.object_ring.serialized_path)
|
||||
|
||||
def test_GET_ec_pipeline(self):
|
||||
conf = _test_context['conf']
|
||||
conf['client_timeout'] = 0.1
|
||||
prosrv = proxy_server.Application(conf, logger=debug_logger('proxy'))
|
||||
with in_process_proxy(
|
||||
prosrv, socket_timeout=conf['client_timeout']) as prolis:
|
||||
self.put_container(self.ec_policy.name, self.ec_policy.name,
|
||||
prolis=prolis)
|
||||
|
||||
obj = b'0123456' * 11 * 17
|
||||
|
||||
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||
fd = sock.makefile('rwb')
|
||||
fd.write(('PUT /v1/a/%s/go-get-it HTTP/1.1\r\n'
|
||||
'Host: localhost\r\n'
|
||||
'Content-Length: %d\r\n'
|
||||
'X-Storage-Token: t\r\n'
|
||||
'X-Object-Meta-Color: chartreuse\r\n'
|
||||
'Content-Type: application/octet-stream\r\n'
|
||||
'\r\n' % (
|
||||
self.ec_policy.name,
|
||||
len(obj),
|
||||
)).encode('ascii'))
|
||||
fd.write(obj)
|
||||
fd.flush()
|
||||
headers = readuntil2crlfs(fd)
|
||||
exp = b'HTTP/1.1 201'
|
||||
self.assertEqual(headers[:len(exp)], exp)
|
||||
|
||||
fd.write(('GET /v1/a/%s/go-get-it HTTP/1.1\r\n'
|
||||
'Host: localhost\r\n'
|
||||
'X-Storage-Token: t\r\n'
|
||||
'\r\n' % self.ec_policy.name).encode('ascii'))
|
||||
fd.flush()
|
||||
headers = readuntil2crlfs(fd)
|
||||
exp = b'HTTP/1.1 200'
|
||||
self.assertEqual(headers[:len(exp)], exp)
|
||||
for line in headers.splitlines():
|
||||
if b'Content-Length' in line:
|
||||
h, v = line.split()
|
||||
content_length = int(v.strip())
|
||||
break
|
||||
else:
|
||||
self.fail("Didn't find content-length in %r" % (headers,))
|
||||
|
||||
gotten_obj = fd.read(content_length)
|
||||
self.assertEqual(gotten_obj, obj)
|
||||
|
||||
sleep(0.3) # client_timeout should kick us off
|
||||
|
||||
fd.write(('GET /v1/a/%s/go-get-it HTTP/1.1\r\n'
|
||||
'Host: localhost\r\n'
|
||||
'X-Storage-Token: t\r\n'
|
||||
'\r\n' % self.ec_policy.name).encode('ascii'))
|
||||
fd.flush()
|
||||
# makefile is a little weird, but this is disconnected
|
||||
self.assertEqual(b'', fd.read())
|
||||
# I expected this to raise a socket error
|
||||
self.assertEqual(b'', sock.recv(1024))
|
||||
# ... but we ARE disconnected
|
||||
with self.assertRaises(socket.error) as caught:
|
||||
sock.send(b'test')
|
||||
self.assertEqual(caught.exception.errno, errno.EPIPE)
|
||||
# and logging confirms we've timed out
|
||||
last_debug_msg = prosrv.logger.get_lines_for_level('debug')[-1]
|
||||
self.assertIn('timed out', last_debug_msg)
|
||||
|
||||
def test_ec_client_disconnect(self):
|
||||
prolis = _test_sockets[0]
|
||||
|
||||
|
@ -8492,7 +8494,7 @@ class BaseTestECObjectController(BaseTestObjectController):
|
|||
class TestECObjectController(BaseTestECObjectController, unittest.TestCase):
|
||||
def setUp(self):
|
||||
skip_if_no_xattrs()
|
||||
self.ec_policy = POLICIES[3]
|
||||
self.policy = self.ec_policy = POLICIES[3]
|
||||
super(TestECObjectController, self).setUp()
|
||||
|
||||
|
||||
|
@ -8500,7 +8502,7 @@ class TestECDuplicationObjectController(
|
|||
BaseTestECObjectController, unittest.TestCase):
|
||||
def setUp(self):
|
||||
skip_if_no_xattrs()
|
||||
self.ec_policy = POLICIES[4]
|
||||
self.policy = self.ec_policy = POLICIES[4]
|
||||
super(TestECDuplicationObjectController, self).setUp()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue