Skip to content

Fix #1: cross-platform health check + Fix #5: independent log parser test fixtures#46

Open
cashmeout2313 wants to merge 1 commit into
weilixiong:mainfrom
cashmeout2313:main
Open

Fix #1: cross-platform health check + Fix #5: independent log parser test fixtures#46
cashmeout2313 wants to merge 1 commit into
weilixiong:mainfrom
cashmeout2313:main

Conversation

@cashmeout2313

Copy link
Copy Markdown

Fixes #1

Changes

tools/health_check.py — Cross-platform health check

  • Added fallback paths for check_memory_usage() on non-Linux:
    1. macOS: uses vm_stat + pagesize via subprocess
    2. Any platform: tries psutil if available
    3. Gracefully returns WARNING when no mechanism works
  • Replaced check_load_average() direct /proc/loadavg read with
    os.getloadavg() (cross-platform: Linux, macOS, BSD), falling
    back gracefully if unavailable
  • All original Linux /proc paths retained as primary with
    try/except fallback chain

tools/tests/ — Independent log parser test fixtures

Closes #5

New tools/tests/ package with hand-crafted fixture files (not
generated by parser code):

  • fixtures/json_logs.log — 15 JSON-structured log entries with
    various severity levels and key schemas (timestamp/time/@timestamp,
    level/severity/lvl, service/logger/app)
  • fixtures/nginx_access.log — 15 Nginx combined-format access log
    entries with 2xx/4xx/5xx status codes
  • fixtures/plain_text.log — 15 timestamped log entries with
    [service] LEVEL: format
  • fixtures/syslog_messages.log — 15 syslog-formatted messages
    from kernel, sshd, dockerd, kubelet, postgres, nginx, etc.

Test files:

  • test_log_parsers.py — 28 test cases across 4 test classes
    validating JSON, Nginx, plain-text, and syslog parsing against
    the known-correct fixture data
  • test_health_check.py — 2 smoke tests for the health check return
    shape

All 30 tests pass.

- 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
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 [$50 BOUNTY] [Python] Add cross-platform health check fallbacks

1 participant