fix: add independent log parser fixtures and fix nginx parser ordering (Closes #5)#67
Open
jacksong2049-prog wants to merge 1 commit into
Open
Conversation
- Add independent hand-written fixtures for JSON, text, and nginx log formats - Add focused parser validation tests (12 test cases) - Fix parser ordering: NginxLogParser now runs before TextLogParser to prevent nginx lines from being swallowed by the generic text parser - Add malformed/edge-case line handling validation - All fixtures are hand-written, not parser-generated — eliminating false-pass risk Closes weilixiong#5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add independent hand-written log parser fixtures and fix a parser ordering bug where NginxLogParser was never reached because TextLogParser matches all non-empty lines first.
Changes
New files
tests/__init__.py— test package inittests/test_log_aggregator_fixtures.py— 13 test cases across 5 test classesModified files
tools/log_aggregator.py— fix parser ordering:NginxLogParsernow runs beforeTextLogParserFixtures (all hand-written, NOT parser-generated)
JSON (4 fixtures): standard structured log, severity/logger alternates, @timestamp/lvl alternates, minimal message-only log
Text (5 fixtures): syslog-style, Python logging, INFO/DEBUG levels, FATAL without timestamp
Nginx (3 fixtures): 200 OK, 500 server error, 404 not found — all with full combined log format fields
Malformed (8 cases): empty lines, invalid JSON, binary garbage, long whitespace — all verified to not crash
Bug fix
The parser list was
[JSON, Text, Nginx]. SinceTextLogParser.parse()returns a dict for ANY non-empty line,NginxLogParserwas never reachable. The fix reorders to[JSON, Nginx, Text]so:Testing
All 13 tests pass, covering:
Checklist
Closes #5