use crate::production_stress_testing_modules;
pub use crate::production_stress_testing_modules::{
create_constant_data, create_duplicate_x_data, create_edge_case_data, create_empty_data,
create_exponential_data, create_extreme_y_data, create_large_test_data, create_linear_data,
create_mismatched_data, create_monotonic_extreme_data, create_nan_inf_data,
create_oscillatory_data, create_pseudo_random_data, create_quadratic_data,
create_rapid_change_data, create_single_point_data, create_sparse_data, create_step_data,
create_stress_tester, create_stress_tester_with_config, create_unsorted_x_data,
generate_test_data, get_error_test_data_types, get_general_test_data_types,
get_pathological_data_types, run_production_stress_tests, run_quick_stress_tests,
run_stress_tests_with_config, BaselinePerformance, ErrorInfo, IssueSeverity, MemoryUsageStats,
PerformanceAnalysis, ProductionImpact, ProductionReadiness, ProductionStressTester,
ScalabilityAssessment, StressPerformanceMetrics, StressTestCategory, StressTestConfig,
StressTestIssue, StressTestReport, StressTestResult, StressTestSummary, TestStatus,
};
pub use crate::production_stress_testing_modules::prelude::*;
use crate::error::{InterpolateError, InterpolateResult};
use crate::traits::InterpolationFloat;
pub type ProductionStressTesterF32 = ProductionStressTester<f32>;
pub type ProductionStressTesterF64 = ProductionStressTester<f64>;
pub fn quick_production_readiness_check() -> InterpolateResult<ProductionReadiness> {
let report = run_quick_stress_tests::<f64>()?;
Ok(report.production_readiness)
}
pub fn quick_production_readiness_check_f32() -> InterpolateResult<ProductionReadiness> {
let report = run_quick_stress_tests::<f32>()?;
Ok(report.production_readiness)
}
pub fn run_targeted_stress_tests<T: InterpolationFloat + std::panic::RefUnwindSafe>(
categories: &[StressTestCategory],
) -> InterpolateResult<StressTestReport> {
let mut tester = ProductionStressTester::<T>::new();
let _requested_categories = categories;
tester.run_comprehensive_stress_tests()
}
pub fn validate_for_production<T: InterpolationFloat + std::panic::RefUnwindSafe>(
) -> InterpolateResult<bool> {
let report = run_production_stress_tests::<T>()?;
match report.production_readiness {
ProductionReadiness::Ready | ProductionReadiness::ReadyWithMonitoring => Ok(true),
_ => Ok(false),
}
}
pub fn generate_deployment_checklist<T: InterpolationFloat + std::panic::RefUnwindSafe>(
) -> InterpolateResult<Vec<String>> {
let report = run_production_stress_tests::<T>()?;
let mut checklist = Vec::new();
checklist.push("✓ Run comprehensive stress tests".to_string());
if report.summary.tests_failed > 0 {
checklist.push(format!(
"✗ Fix {} failing tests",
report.summary.tests_failed
));
} else {
checklist.push("✓ All stress tests passing".to_string());
}
if !report.critical_issues.is_empty() {
checklist.push(format!(
"✗ Address {} critical issues",
report.critical_issues.len()
));
} else {
checklist.push("✓ No critical issues detected".to_string());
}
if report.summary.overall_degradation_factor > 5.0 {
checklist.push("✗ Optimize performance (high degradation detected)".to_string());
} else {
checklist.push("✓ Performance within acceptable limits".to_string());
}
if report.summary.memory_efficiency_score < 70.0 {
checklist.push("✗ Improve memory efficiency".to_string());
} else {
checklist.push("✓ Memory usage is efficient".to_string());
}
if !report
.performance_analysis
.scalability_assessment
.can_handle_10x_load
{
checklist.push("✗ Test and optimize for expected production scale".to_string());
} else {
checklist.push("✓ System can handle expected load".to_string());
}
checklist.push("◦ Set up performance monitoring".to_string());
checklist.push("◦ Configure alerting for edge cases".to_string());
checklist.push("◦ Document known limitations".to_string());
checklist.push("◦ Prepare rollback procedures".to_string());
for recommendation in &report.production_recommendations {
checklist.push(format!("◦ {}", recommendation));
}
Ok(checklist)
}
pub mod info {
pub use crate::production_stress_testing_modules::info::*;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[ignore = "Long-running stress test - tests large data sizes up to 500k points"]
fn test_quick_production_readiness_check() {
let result = quick_production_readiness_check();
assert!(result.is_ok());
let readiness = result.expect("Operation failed");
assert!(matches!(
readiness,
ProductionReadiness::Ready
| ProductionReadiness::ReadyWithMonitoring
| ProductionReadiness::NeedsPerformanceTuning
| ProductionReadiness::NeedsBugFixes
| ProductionReadiness::NotReady
));
}
#[test]
#[ignore = "Long-running stress test - f32 version of production readiness check"]
fn test_quick_production_readiness_check_f32() {
let result = quick_production_readiness_check_f32();
assert!(result.is_ok());
}
#[test]
#[ignore = "Long-running stress test - comprehensive production validation"]
fn test_validate_for_production() {
let result = validate_for_production::<f64>();
assert!(result.is_ok());
let _is_ready = result.expect("Operation failed");
}
#[test]
#[ignore = "Long-running stress test - generates deployment checklist after full testing"]
fn test_generate_deployment_checklist() {
let result = generate_deployment_checklist::<f64>();
assert!(result.is_ok());
let checklist = result.expect("Operation failed");
assert!(!checklist.is_empty());
assert!(checklist.iter().any(|item| item.contains("stress tests")));
}
#[test]
#[ignore = "Long-running stress test - runs targeted stress test categories"]
fn test_targeted_stress_tests() {
let categories = vec![
StressTestCategory::ExtremeDataSize,
StressTestCategory::ErrorHandling,
];
let result = run_targeted_stress_tests::<f64>(&categories);
assert!(result.is_ok());
}
#[test]
fn test_module_api_integration() {
let config = StressTestConfig::default();
let _tester = ProductionStressTester::<f64>::with_config(config);
let result = generate_test_data::<f64>("linear", 100);
assert!(result.is_ok());
let types = get_pathological_data_types();
assert!(!types.is_empty());
}
#[test]
fn test_type_aliases() {
let _tester_f32: ProductionStressTesterF32 = ProductionStressTester::new();
let _tester_f64: ProductionStressTesterF64 = ProductionStressTester::new();
}
#[test]
fn test_prelude_imports() {
use super::production_stress_testing_modules::prelude::*;
let _tester = create_stress_tester::<f64>();
let _config = StressTestConfig::default();
let _status = TestStatus::Passed;
let _readiness = ProductionReadiness::Ready;
}
#[test]
fn test_comprehensive_workflow() {
let config = StressTestConfig {
max_data_size: 1_000, stress_iterations: 2, test_timeout: 5, memory_limit: Some(64 * 1024 * 1024), test_extreme_cases: false, max_performance_degradation: 10.0,
};
let tester = create_stress_tester_with_config::<f64>(config);
assert_eq!(tester.config.max_data_size, 1_000);
let linear_data = create_linear_data::<f64>(50);
assert!(linear_data.is_ok());
let constant_data = create_constant_data::<f64>(50);
assert!(constant_data.is_ok());
let empty_data = create_empty_data::<f64>();
assert!(empty_data.is_ok());
for data_type in ["linear", "quadratic", "exponential"].iter() {
let result = generate_test_data::<f64>(data_type, 50);
assert!(result.is_ok(), "Failed to generate {} data", data_type);
}
}
#[test]
#[ignore = "Long-running stress test - validates deployment checklist content"]
fn test_deployment_checklist_content() {
let result = generate_deployment_checklist::<f64>();
assert!(result.is_ok());
let checklist = result.expect("Operation failed");
assert!(checklist.iter().any(|item| item.contains("monitoring")));
let has_check_marks = checklist.iter().any(|item| item.contains("✓"));
let has_cross_marks = checklist.iter().any(|item| item.contains("✗"));
let has_circles = checklist.iter().any(|item| item.contains("◦"));
assert!(has_check_marks || has_cross_marks || has_circles);
}
}