forked from openshift/origin-aggregated-logging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-utf8-characters.py
31 lines (27 loc) · 1.22 KB
/
test-utf8-characters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import json
obj = json.loads(sys.stdin.read())
message_uuid = sys.argv[1]
message = sys.argv[2]
for dd in obj['hits']['hits']:
if dd['_score'] < 1.0:
print "ignoring spurious hit"
continue
if not dd['_source']['message'].startswith(message):
print 'Error: message field does not start with [%s]: [%s]' % (message, dd['_source']['message'])
sys.exit(1)
if not 'systemd' in dd['_source']:
print 'Error: systemd field not in record: [%s]' % json.dumps(dd['_source'])
sys.exit(1)
if not 'u' in dd['_source']['systemd']:
print 'Error: systemd.u field not in record: [%s]' % json.dumps(dd['_source'])
sys.exit(1)
if not 'SYSLOG_IDENTIFIER' in dd['_source']['systemd']['u']:
print 'Error: systemd.u.SYSLOG_IDENTIFIER field not in record: [%s]' % json.dumps(dd['_source'])
sys.exit(1)
syslog_identifier = dd['_source']['systemd']['u']['SYSLOG_IDENTIFIER']
if syslog_identifier == message_uuid:
print 'Error: field systemd.u.SYSLOG_IDENTIFIER does not have expected value [%s]: [%s]' % (message_uuid, str(syslog_identifier))
sys.exit(1)
print 'Success: record contains all of the expected fields/values'
sys.exit(0)