Refactor: Split main.rs into modular structure#24
Merged
Conversation
Split the 794-line main.rs into focused modules for better maintainability, testability, and code organization. Closes #15 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7 tasks
- LoadModel: 22 tests covering all 4 variants (Concurrent, Rps, RampRps, DailyTraffic) including phase transitions, boundary values, cycle wrapping, and edge cases - parse_duration_string: 15 tests covering valid formats (m/h/d), whitespace trimming, and error cases (empty, invalid suffix, fractional, negative, non-numeric) - Config: 16 tests covering defaults, all load model types, optional fields, JSON payload, and panic on missing required vars Total: 62 tests passing (up from 7) Closes #16, Closes #17, Closes #18 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 9, 2026
- 12 integration tests covering end-to-end worker behavior - Tests GET/POST requests, JSON payloads, status code tracking - Tests metrics recording (requests_total, duration, status codes) - Tests error handling (connection refused, timeouts) - Tests RPS rate limiting with timing validation - Tests slow response handling All tests use wiremock 0.5 for mock HTTP server Total: 74 tests passing (62 unit + 12 integration) Closes #19 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 tasks
- Add lint job: cargo fmt --check, cargo clippy -- -D warnings - Add test job: cargo test --all-features --verbose - Build job now depends on test passing (test depends on lint) - Added caching for cargo registry and build artifacts - Only push Docker images on push events (not PRs) - Format all source code with cargo fmt CI pipeline now enforces: - Code formatting (rustfmt) - Lint rules (clippy with warnings as errors) - All tests passing (74 tests: 62 unit + 12 integration) Closes #20, Closes #21 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 9, 2026
Implemented issue #23: - Added ConfigError enum with descriptive error types - Replaced all .expect() calls with proper error returns - Added validate() method for URL, concurrent tasks, and mTLS validation - Added helper functions: env_required(), env_parse_or(), env_bool() - Added Config::for_testing() for test support - Updated main.rs to print helpful error messages on config failure - Updated all tests to check for proper errors instead of panics - Added 5 new validation tests All 79 tests passing (67 unit + 12 integration) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented issue #22: - Added tracing and tracing-subscriber dependencies - Initialized tracing subscriber with RUST_LOG and LOG_FORMAT support - Replaced all println!/eprintln! with structured logging - Added log levels: error, warn, info, debug - Added structured fields to all log messages - Worker lifecycle logging (starting, stopping, request completion) - JSON output format support for log aggregation - Updated help text with logging configuration - Added .gitignore for build artifacts Features: - RUST_LOG env var controls log level (error/warn/info/debug/trace) - LOG_FORMAT=json enables JSON output for log aggregation - Structured fields for filtering and searching - Timestamps and thread IDs included - Module targeting supported All 79 tests passing (67 unit + 12 integration) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
70774f5 to
4b7bb03
Compare
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
Module Structure
Test Coverage
Unit Tests (67)
Integration Tests (12)
Error Handling Improvements
ConfigError Enum - Descriptive error types:
Validation:
Benefits:
Structured Logging
Tracing Integration:
Configuration:
RUST_LOG- Control log level (e.g., info, debug, rust_loadtest=trace)LOG_FORMAT=json- Enable JSON output for log aggregationLog Levels:
Benefits:
CI/CD Pipeline
New Jobs:
Lint - Runs first on every push/PR
Test - Runs after lint passes
Build - Runs after tests pass
Pipeline Flow: Lint → Test → Build → Push
Verification
Closes #15, Closes #16, Closes #17, Closes #18, Closes #19, Closes #20, Closes #21, Closes #22, Closes #23