Commit a3004ad5 authored by Tricia Crichton's avatar Tricia Crichton Committed by Commit Bot

[ChromeDriver] Enable replay of Readable timestamps from Windows

The Readable Timestamps generated on windows have only millisecond
precision (3 digits). Added this to the match pattern for header lines.

Bug: chromedriver:3095
Change-Id: I5e1cc551ace72258cad49742f33adb5d638ab3b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769239Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tricia Crichton <triciac@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691637}
parent da248657
...@@ -586,10 +586,10 @@ class _Parser(object): ...@@ -586,10 +586,10 @@ class _Parser(object):
r"^\[[0-9]{10}\.[0-9]{3}\]\[INFO\]: \[[a-f0-9]*\]") r"^\[[0-9]{10}\.[0-9]{3}\]\[INFO\]: \[[a-f0-9]*\]")
# Matches headers for client commands/responses when readable-timestamp # Matches headers for client commands/responses when readable-timestamp
#option is selected #option is selected. Depending on OS, final component may be 3 or 6 digits
_CLIENT_PREAMBLE_REGEX_READABLE = re.compile( _CLIENT_PREAMBLE_REGEX_READABLE = re.compile(
r"^\[[0-9]{2}-[0-9]{2}-[0-9]{4} " r"^\[[0-9]{2}-[0-9]{2}-[0-9]{4} "
"[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}\]\[INFO\]: \[[a-f0-9]*\]") "[0-9]{2}:[0-9]{2}:[0-9]{2}.([0-9]{3}){1,2}\]\[INFO\]: \[[a-f0-9]*\]")
def __init__(self, log_file): def __init__(self, log_file):
"""Initialize the _Parser instance. """Initialize the _Parser instance.
......
...@@ -43,9 +43,12 @@ _RESPONSE_ONLY = ('[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce] ' ...@@ -43,9 +43,12 @@ _RESPONSE_ONLY = ('[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce] '
'RESPONSE GetTitle {\n"param2": 42\n}\n') 'RESPONSE GetTitle {\n"param2": 42\n}\n')
_PAYLOAD_SCRIPT = ('[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]' _PAYLOAD_SCRIPT = ('[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]'
' RESPONSE GetTitle {\n"param2": "function(){func()}"\n}\n') ' RESPONSE GetTitle {\n"param2": "function(){func()}"\n}\n')
_PAYLOAD_READABLE_TIME = ( _PAYLOAD_READABLE_TIME_LINUX = (
'[08-12-2019 15:45:34.824002][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]' '[08-12-2019 15:45:34.824002][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]'
' RESPONSE GetTitle {\n"param2": "function(){func()}"\n}\n') ' RESPONSE GetTitle {\n"param2": "function(){func()}"\n}\n')
_PAYLOAD_READABLE_TIME_WINDOWS = (
'[08-12-2019 15:45:34.824][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]'
' RESPONSE GetTitle {\n"param2": "function(){func()}"\n}\n')
_BAD_SCRIPT = ('[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]' _BAD_SCRIPT = ('[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]'
' RESPONSE GetTitle {\n"param2": "))}\\})}/{)}({(})}"\n}\n') ' RESPONSE GetTitle {\n"param2": "))}\\})}/{)}({(})}"\n}\n')
_MULTI_SESSION = ('[1531428669.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce] ' _MULTI_SESSION = ('[1531428669.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce] '
...@@ -118,14 +121,22 @@ class ChromeDriverClientReplayUnitTest(unittest.TestCase): ...@@ -118,14 +121,22 @@ class ChromeDriverClientReplayUnitTest(unittest.TestCase):
("[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]" ("[1531428670.535][INFO]: [b15232d5497ec0d8300a5a1ea56f33ce]"
" RESPONSE GetTitle {\n")) " RESPONSE GetTitle {\n"))
def testGetNextClientHeaderLine_readableTime(self): def testGetNextClientHeaderLine_readableTimeLinux(self):
string_buffer = StringIO.StringIO(_PAYLOAD_READABLE_TIME) string_buffer = StringIO.StringIO(_PAYLOAD_READABLE_TIME_LINUX)
command_sequence = client_replay.CommandSequence() command_sequence = client_replay.CommandSequence()
command_sequence._parser = client_replay._Parser(string_buffer) command_sequence._parser = client_replay._Parser(string_buffer)
self.assertEquals(command_sequence._parser._GetNextClientHeaderLine(), self.assertEquals(command_sequence._parser._GetNextClientHeaderLine(),
("[08-12-2019_15:45:34.824002][INFO]:" ("[08-12-2019_15:45:34.824002][INFO]:"
" [b15232d5497ec0d8300a5a1ea56f33ce] RESPONSE GetTitle {\n")) " [b15232d5497ec0d8300a5a1ea56f33ce] RESPONSE GetTitle {\n"))
def testGetNextClientHeaderLine_readableTimeWindows(self):
string_buffer = StringIO.StringIO(_PAYLOAD_READABLE_TIME_WINDOWS)
command_sequence = client_replay.CommandSequence()
command_sequence._parser = client_replay._Parser(string_buffer)
self.assertEquals(command_sequence._parser._GetNextClientHeaderLine(),
("[08-12-2019_15:45:34.824][INFO]:"
" [b15232d5497ec0d8300a5a1ea56f33ce] RESPONSE GetTitle {\n"))
def testIngestLoggedResponse(self): def testIngestLoggedResponse(self):
string_buffer = StringIO.StringIO(_RESPONSE_ONLY) string_buffer = StringIO.StringIO(_RESPONSE_ONLY)
command_sequence = client_replay.CommandSequence() command_sequence = client_replay.CommandSequence()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment