Fix #1: cross-platform health check + Fix #5: independent log parser test fixtures#46
Open
cashmeout2313 wants to merge 1 commit into
Open
Fix #1: cross-platform health check + Fix #5: independent log parser test fixtures#46cashmeout2313 wants to merge 1 commit into
cashmeout2313 wants to merge 1 commit into
Conversation
- Fix health_check.py to work on non-Linux (macOS, Windows) via vm_stat, os.getloadavg(), and psutil fallbacks - Add independent test fixtures for log parser (JSON, Nginx, syslog, plain text formats) generated from realistic production log samples - Add comprehensive parser tests (28 cases) that validate against known-correct fixture data rather than parser-generated output
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.
Fixes #1
Changes
tools/health_check.py— Cross-platform health checkcheck_memory_usage()on non-Linux:vm_stat+pagesizevia subprocesspsutilif availablecheck_load_average()direct/proc/loadavgread withos.getloadavg()(cross-platform: Linux, macOS, BSD), fallingback gracefully if unavailable
/procpaths retained as primary withtry/except fallback chain
tools/tests/— Independent log parser test fixturesCloses #5
New
tools/tests/package with hand-crafted fixture files (notgenerated by parser code):
fixtures/json_logs.log— 15 JSON-structured log entries withvarious severity levels and key schemas (
timestamp/time/@timestamp,level/severity/lvl,service/logger/app)fixtures/nginx_access.log— 15 Nginx combined-format access logentries with 2xx/4xx/5xx status codes
fixtures/plain_text.log— 15 timestamped log entries with[service] LEVEL:formatfixtures/syslog_messages.log— 15 syslog-formatted messagesfrom kernel, sshd, dockerd, kubelet, postgres, nginx, etc.
Test files:
test_log_parsers.py— 28 test cases across 4 test classesvalidating JSON, Nginx, plain-text, and syslog parsing against
the known-correct fixture data
test_health_check.py— 2 smoke tests for the health check returnshape
All 30 tests pass.