fixed tests, typos, and added error handling
This commit is contained in:
@@ -1200,7 +1200,7 @@ class BaseApplication(object):
|
|||||||
:param start_response: WSGI callable
|
:param start_response: WSGI callable
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if self.mamcache is None:
|
if self.memcache is None:
|
||||||
self.memcache = cache_from_env(env)
|
self.memcache = cache_from_env(env)
|
||||||
req = self.update_request(Request(env))
|
req = self.update_request(Request(env))
|
||||||
if 'eventlet.posthooks' in env:
|
if 'eventlet.posthooks' in env:
|
||||||
|
@@ -243,7 +243,10 @@ class LogProcessorDaemon(Daemon):
|
|||||||
'processed_files.pickle.gz',
|
'processed_files.pickle.gz',
|
||||||
compressed=True)
|
compressed=True)
|
||||||
buf = ''.join(x for x in processed_files_stream)
|
buf = ''.join(x for x in processed_files_stream)
|
||||||
already_processed_files = cPickle.loads(buf)
|
if buf:
|
||||||
|
already_processed_files = cPickle.loads(buf)
|
||||||
|
else:
|
||||||
|
already_processed_files = set()
|
||||||
except:
|
except:
|
||||||
already_processed_files = set()
|
already_processed_files = set()
|
||||||
self.logger.debug('found %d processed files' % len(already_processed_files))
|
self.logger.debug('found %d processed files' % len(already_processed_files))
|
||||||
@@ -313,9 +316,6 @@ class LogProcessorDaemon(Daemon):
|
|||||||
# cleanup
|
# cleanup
|
||||||
s = cPickle.dumps(processed_files, cPickle.HIGHEST_PROTOCOL)
|
s = cPickle.dumps(processed_files, cPickle.HIGHEST_PROTOCOL)
|
||||||
f = cStringIO.StringIO(s)
|
f = cStringIO.StringIO(s)
|
||||||
self.log_processor.internal_proxy.create_container(
|
|
||||||
self.log_processor_account,
|
|
||||||
self.log_processor_container)
|
|
||||||
self.log_processor.internal_proxy.upload_file(f,
|
self.log_processor.internal_proxy.upload_file(f,
|
||||||
self.log_processor_account,
|
self.log_processor_account,
|
||||||
self.log_processor_container,
|
self.log_processor_container,
|
||||||
|
@@ -33,7 +33,7 @@ class DumbInternalProxy(object):
|
|||||||
def data():
|
def data():
|
||||||
yield 'obj\n'
|
yield 'obj\n'
|
||||||
yield 'data'
|
yield 'data'
|
||||||
return code, data
|
return code, data()
|
||||||
|
|
||||||
class TestLogProcessor(unittest.TestCase):
|
class TestLogProcessor(unittest.TestCase):
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class TestLogProcessor(unittest.TestCase):
|
|||||||
'/v1/acct/foo/bar?format=json&foo HTTP/1.0 200 - '\
|
'/v1/acct/foo/bar?format=json&foo HTTP/1.0 200 - '\
|
||||||
'curl tk4e350daf-9338-4cc6-aabb-090e49babfbd '\
|
'curl tk4e350daf-9338-4cc6-aabb-090e49babfbd '\
|
||||||
'6 95 - txfa431231-7f07-42fd-8fc7-7da9d8cc1f90 - 0.0262'
|
'6 95 - txfa431231-7f07-42fd-8fc7-7da9d8cc1f90 - 0.0262'
|
||||||
stats_test_line = 'account,1,2,3,1283378584.881391'
|
stats_test_line = 'account,1,2,3'
|
||||||
proxy_config = {'log-processor': {
|
proxy_config = {'log-processor': {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -152,11 +152,10 @@ class TestLogProcessor(unittest.TestCase):
|
|||||||
def get_object_data(*a,**kw):
|
def get_object_data(*a,**kw):
|
||||||
return [self.stats_test_line]
|
return [self.stats_test_line]
|
||||||
p.get_object_data = get_object_data
|
p.get_object_data = get_object_data
|
||||||
result = p.process_one_file('stats', 'a', 'c', 'o')
|
result = p.process_one_file('stats', 'a', 'c', 'y/m/d/h/o')
|
||||||
expected = {'account':
|
expected = {'account':
|
||||||
{'count': 1,
|
{'count': 1,
|
||||||
'object_count': 2,
|
'object_count': 2,
|
||||||
'container_count': 1,
|
'container_count': 1,
|
||||||
'bytes_used': 3,
|
'bytes_used': 3}}
|
||||||
'created_at': '1283378584.881391'}}
|
|
||||||
self.assertEquals(result, expected)
|
self.assertEquals(result, expected)
|
Reference in New Issue
Block a user