fixed tests
This commit is contained in:
parent
85fb01d346
commit
fe25507166
@ -21,6 +21,30 @@ from swift.stats import access_processor
|
||||
|
||||
class TestAccessProcessor(unittest.TestCase):
|
||||
|
||||
def test_log_line_parser_query_args(self):
|
||||
p = access_processor.AccessLogProcessor({})
|
||||
log_line = [str(x) for x in range(18)]
|
||||
log_line[1] = 'proxy-server'
|
||||
log_line[4] = '1/Jan/3/4/5/6'
|
||||
query = 'foo'
|
||||
for param in access_processor.LISTING_PARAMS:
|
||||
query += '&%s=blah' % param
|
||||
log_line[6] = '/v1/a/c/o?%s' % query
|
||||
log_line = 'x'*16 + ' '.join(log_line)
|
||||
res = p.log_line_parser(log_line)
|
||||
expected = {'code': 8, 'processing_time': '17', 'auth_token': '11',
|
||||
'month': '01', 'second': '6', 'year': '3', 'tz': '+0000',
|
||||
'http_version': '7', 'object_name': 'o', 'etag': '14',
|
||||
'method': '5', 'trans_id': '15', 'client_ip': '2',
|
||||
'bytes_out': 13, 'container_name': 'c', 'day': '1',
|
||||
'minute': '5', 'account': 'a', 'hour': '4',
|
||||
'referrer': '9', 'request': '/v1/a/c/o',
|
||||
'user_agent': '10', 'bytes_in': 12, 'lb_ip': '3'}
|
||||
for param in access_processor.LISTING_PARAMS:
|
||||
expected[param] = 1
|
||||
expected['query'] = query
|
||||
self.assertEquals(res, expected)
|
||||
|
||||
def test_log_line_parser_field_count(self):
|
||||
p = access_processor.AccessLogProcessor({})
|
||||
# too few fields
|
||||
|
@ -131,7 +131,6 @@ use = egg:swift#proxy
|
||||
'http_version': 'HTTP/1.0',
|
||||
'object_name': 'bar',
|
||||
'etag': '-',
|
||||
'foo': 1,
|
||||
'method': 'GET',
|
||||
'trans_id': 'txfa431231-7f07-42fd-8fc7-7da9d8cc1f90',
|
||||
'client_ip': '1.2.3.4',
|
||||
|
Loading…
Reference in New Issue
Block a user