diff options
author | diosmosis <benaka@piwik.pro> | 2014-12-09 05:38:04 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-12-09 05:38:04 +0300 |
commit | a216ebc3682a0ffc046bb460793b68013acb4cfd (patch) | |
tree | b12356cce54c85a7b352635cb9ff2368c83c40de /misc | |
parent | 3d3ec54ae84754a2c17b07a837406921fa10c178 (diff) |
Add netscaler logs to python tests for log importer.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/log-analytics/tests/logs/netscaler.log | 5 | ||||
-rw-r--r-- | misc/log-analytics/tests/tests.py | 37 |
2 files changed, 42 insertions, 0 deletions
diff --git a/misc/log-analytics/tests/logs/netscaler.log b/misc/log-analytics/tests/logs/netscaler.log new file mode 100644 index 0000000000..0eb5d310b3 --- /dev/null +++ b/misc/log-analytics/tests/logs/netscaler.log @@ -0,0 +1,5 @@ +#Version: 1.0 +#Software: Netscaler Web Logging(NSWL) +#Date: 2014-02-18 11:55:13 +#Fields: date time c-ip cs-username sc-servicename s-ip s-port cs-method cs-uri-stem cs-uri-query sc-status cs-bytes sc-bytes time-taken cs-version cs(User-Agent) cs(Cookie) cs(Referer) +2012-08-16 11:55:13 172.20.1.0 - HTTP 192.168.6.254 8080 GET /Citrix/XenApp/Wan/auth/login.jsp - 302 247 355 0 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022) - - diff --git a/misc/log-analytics/tests/tests.py b/misc/log-analytics/tests/tests.py index bf548f4416..5cde40d34e 100644 --- a/misc/log-analytics/tests/tests.py +++ b/misc/log-analytics/tests/tests.py @@ -369,3 +369,40 @@ def test_iis_custom_format(): assert hits[2]['is_robot'] == False assert hits[2]['full_path'] == u'/hello/world/6,681965' assert hits[2]['user_agent'] == u'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36' + +def test_netscaler_parsing(): + """test parsing of netscaler logs (which are similar to IIS logs)""" + + file_ = 'logs/netscaler.log' + + # have to override previous globals override for this test + import_logs.config.options.custom_iis_fields = {} + Recorder.recorders = [] + import_logs.parser = import_logs.Parser() + import_logs.config.format = None + import_logs.config.options.enable_http_redirects = True + import_logs.config.options.enable_http_errors = True + import_logs.config.options.replay_tracking = False + import_logs.parser.parse(file_) + + hits = [hit.__dict__ for hit in Recorder.recorders] + + assert hits[0]['status'] == u'302' + assert hits[0]['userid'] == None + assert hits[0]['is_error'] == False + assert hits[0]['extension'] == u'jsp' + assert hits[0]['is_download'] == False + assert hits[0]['referrer'] == '' + assert hits[0]['args'] == {} + assert hits[0]['generation_time_milli'] == 0 + assert hits[0]['host'] == 'foo' + assert hits[0]['filename'] == 'logs/netscaler.log' + assert hits[0]['is_redirect'] == True + assert hits[0]['date'] == datetime.datetime(2012, 8, 16, 11, 55, 13) + assert hits[0]['lineno'] == 4 + assert hits[0]['ip'] == u'172.20.1.0' + assert hits[0]['query_string'] == '' + assert hits[0]['path'] == u'/Citrix/XenApp/Wan/auth/login.jsp' + assert hits[0]['is_robot'] == False + assert hits[0]['full_path'] == u'/Citrix/XenApp/Wan/auth/login.jsp' + assert hits[0]['user_agent'] == u'Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022)'
\ No newline at end of file |