Skip to content

Commit

Permalink
Fixed issue rueckstiess#618
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinadi committed Jun 27, 2018
1 parent 4bccf42 commit 5cc1d61
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 25 additions & 0 deletions mtools/test/test_util_logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
"cursorid:1234567890123456789 ntoreturn:0 keyUpdates:0 "
"numYields: 23 locks(micros) r:24715 nreturned:1324 "
"reslen:256993 1445ms")
line_fassert = ("***aborting after fassert() failure")
line_empty = ("")

# fake system.profile documents
profile_doc1 = {"op": "query", "ns": "test.foo",
Expand Down Expand Up @@ -226,6 +228,29 @@ def test_logevent_value_extraction():
assert(le.nreturned == 13551)
assert(le.pattern == '{"ts": 1}')

def test_logevent_non_log_line():
""" Check that LogEvent correctly ignores non log lines"""
le = LogEvent(line_fassert)
assert(le.thread == None)
assert(le.operation == None)
assert(le.namespace == None)
assert(le.duration == None)
assert(le.numYields == None)
assert(le.r == None)
assert(le.ntoreturn == None)
assert(le.nreturned == None)
assert(le.pattern == None)

le = LogEvent(line_empty)
assert(le.thread == None)
assert(le.operation == None)
assert(le.namespace == None)
assert(le.duration == None)
assert(le.numYields == None)
assert(le.r == None)
assert(le.ntoreturn == None)
assert(le.nreturned == None)
assert(le.pattern == None)

def test_logevent_lazy_evaluation():
""" Check that all LogEvent variables are evaluated lazily. """
Expand Down
5 changes: 3 additions & 2 deletions mtools/util/logevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ def thread(self):

split_tokens = self.split_tokens

if not (self.datetime_nextpos or
len(split_tokens) <= self.datetime_nextpos):
if not self.datetime_nextpos:
return None
if len(split_tokens) <= self.datetime_nextpos:
return None

connection_token = split_tokens[self.datetime_nextpos]
Expand Down

0 comments on commit 5cc1d61

Please sign in to comment.