-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
The application reads numerous environment variables for configuration but has no tests for configuration parsing or validation logic. Invalid configurations can cause runtime panics or unexpected behavior.
Current Configuration Variables
| Variable | Type | Required | Default |
|---|---|---|---|
TARGET_URL |
String | Yes | - |
REQUEST_METHOD |
String | No | "GET" |
POST_BODY |
JSON String | No | - |
SKIP_TLS_VERIFY |
bool | No | false |
CLIENT_CERT_PATH |
Path | No | - |
CLIENT_KEY_PATH |
Path | No | - |
RESOLVE_TARGET_ADDR |
IP:Port | No | - |
CUSTOM_HEADERS |
String | No | - |
LOAD_MODEL |
String | No | "concurrent" |
MAX_CONCURRENT |
u32 | No | 10 |
TARGET_RPS |
f64 | No | - |
MIN_RPS |
f64 | No | - |
MAX_RPS |
f64 | No | - |
RAMP_DURATION |
Duration | No | - |
TEST_DURATION |
Duration | No | "1m" |
PEAK_RPS |
f64 | No | - |
MIDDAY_RPS |
f64 | No | - |
NIGHT_RPS |
f64 | No | - |
| Various phase durations | Duration | No | - |
Test Cases Required
Required Variables
- Missing
TARGET_URLproduces clear error - Empty
TARGET_URLproduces clear error - Invalid URL format produces clear error
Load Model Selection
-
LOAD_MODEL=concurrentselects Concurrent model -
LOAD_MODEL=rpsselects Rps model (requires TARGET_RPS) -
LOAD_MODEL=rampselects RampRps model (requires MIN_RPS, MAX_RPS, RAMP_DURATION) -
LOAD_MODEL=dailyselects DailyTraffic model - Unknown LOAD_MODEL value produces clear error
- Missing required params for model produces clear error
mTLS Configuration
- Both
CLIENT_CERT_PATHandCLIENT_KEY_PATHrequired together - Only cert without key produces error
- Only key without cert produces error
- Invalid cert path produces clear error
- Invalid key path produces clear error
Numeric Validation
- Negative
MAX_CONCURRENTproduces error - Zero
MAX_CONCURRENTproduces error or warning - Negative RPS values produce error
-
MIN_RPS > MAX_RPSproduces error
Duration Validation
- Invalid duration format produces clear error
- Zero duration produces warning or error
- Extremely long durations are accepted
DNS Override
- Valid
RESOLVE_TARGET_ADDRformat (IP:port) accepted - Invalid format produces clear error
- IPv6 addresses handled correctly
Acceptance Criteria
- All environment variables have test coverage
- Missing required variables produce clear errors
- Invalid values produce descriptive error messages
- Default values are documented and tested
- mTLS requires both cert and key
- Load model parameters validated for each model type
Implementation Notes
This issue pairs well with #15 (Extract Config struct). Tests should:
- Use
temp_envor similar crate to set env vars in tests - Create a
Config::from_env()function that can be unit tested - Return
Result<Config, ConfigError>instead of panicking
Example Test Structure
#[cfg(test)]
mod config_tests {
use super::*;
use temp_env::with_vars;
#[test]
fn test_missing_target_url_error() {
with_vars(vec![("TARGET_URL", None::<&str>)], || {
let result = Config::from_env();
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("TARGET_URL"));
});
}
#[test]
fn test_rps_model_requires_target_rps() {
with_vars(vec![
("TARGET_URL", Some("https://example.com")),
("LOAD_MODEL", Some("rps")),
// TARGET_RPS intentionally missing
], || {
let result = Config::from_env();
assert!(result.is_err());
});
}
#[test]
fn test_mtls_requires_both_cert_and_key() {
with_vars(vec![
("TARGET_URL", Some("https://example.com")),
("CLIENT_CERT_PATH", Some("/path/to/cert.pem")),
// CLIENT_KEY_PATH intentionally missing
], || {
let result = Config::from_env();
assert!(result.is_err());
});
}
}Dependencies
- Consider using
temp_envcrate for testing environment variables - This issue should be done after or alongside Refactor: Split main.rs into modular structure #15 (modular refactor)
Priority
Medium - Configuration errors currently cause panics with stack traces. Better validation would improve user experience.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request