Skip to content

Add independent log parser fixtures - fixes #5#64

Open
vavavadusik-crypto wants to merge 2 commits into
weilixiong:mainfrom
vavavadusik-crypto:feat/log-parser-fixtures
Open

Add independent log parser fixtures - fixes #5#64
vavavadusik-crypto wants to merge 2 commits into
weilixiong:mainfrom
vavavadusik-crypto:feat/log-parser-fixtures

Conversation

@vavavadusik-crypto

Copy link
Copy Markdown

Adds independent, hand-written fixtures that exercise the log parsers without generating expectations from the implementation under test.

Fixtures cover:

  • JSON logs with standard, alternate, and Elasticsearch-style fields
  • Plain-text logs with ISO, space-separated, and syslog timestamps
  • Nginx 200, 404, and 502 access-log cases
  • Garbled, truncated JSON, and empty malformed inputs
  • Mixed-format aggregator integration behavior

The fixture coverage also exposes and fixes timestamp normalization, hyphenated service parsing, nginx remote-user extraction, and format-specific parser ordering.

Tested with python3 tools/test_log_aggregator.py (16 tests passing).

Fixes #5.

Contributor and others added 2 commits July 13, 2026 12:39
Add hand-written test fixtures for JSON, plain text, and nginx log
formats that are independent of the parser code under test.  These
fixtures expose four real bugs in the legacy log aggregator:

1. extract_service regex \[(\w+)\] did not match hyphenated service
   names like [order-service].  Fixed by allowing hyphens: [\w-]+.

2. extract_service only checked the first (\w+): match, which could
   be a timestamp fragment (e.g. '15T10:').  Now iterates all matches
   and returns the first all-uppercase word followed by a colon.

3. NginxLogParser mapped remote_user to regex group(2) (the ident
   field, usually '-') instead of group(3) (the actual username).

4. JSONLogParser passed raw string timestamps through to the
   aggregator, causing TypeError in datetime.fromtimestamp().  Now
   normalises ISO-8601 strings to epoch seconds via extract_timestamp.

5. LogAggregator parser ordering placed TextLogParser (a catch-all)
   before NginxLogParser, so nginx lines were never parsed by the
   nginx parser.  Reordered to try format-specific parsers first.

Also includes:
- 3 malformed/unsupported line cases (garbled text, truncated JSON,
  empty string) that verify the parser does not crash.
- Aggregator integration test with mixed formats.
- Diagnostic build artifact (build-bf2147ac.logd + metadata).

Closes weilixiong#5
@vavavadusik-crypto vavavadusik-crypto force-pushed the feat/log-parser-fixtures branch from f49a1e9 to 90f1afb Compare July 13, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[$25 BOUNTY] [Python] Add independent log parser fixtures

1 participant