1use std::collections::HashMap;
4use std::time::Duration;
5
6#[derive(Debug, Clone)]
8pub struct IntegrationTestConfig {
9 pub execution_timeout: Duration,
11 pub max_concurrent_tests: usize,
13 pub storage_config: TestStorageConfig,
15 pub benchmark_config: BenchmarkConfig,
17 pub stress_config: StressTestConfig,
19 pub fault_injection_config: FaultInjectionConfig,
21 pub monitoring_config: MonitoringConfig,
23 pub environment_config: TestEnvironmentConfig,
25}
26
27impl Default for IntegrationTestConfig {
28 fn default() -> Self {
29 Self {
30 execution_timeout: Duration::from_secs(300),
31 max_concurrent_tests: 4,
32 storage_config: TestStorageConfig::default(),
33 benchmark_config: BenchmarkConfig::default(),
34 stress_config: StressTestConfig::default(),
35 fault_injection_config: FaultInjectionConfig::default(),
36 monitoring_config: MonitoringConfig::default(),
37 environment_config: TestEnvironmentConfig::default(),
38 }
39 }
40}
41
42#[derive(Debug, Clone)]
44pub struct TestStorageConfig {
45 pub enable_persistent_storage: bool,
47 pub storage_format: StorageFormat,
49 pub retention_policy: RetentionPolicy,
51 pub compression: CompressionConfig,
53}
54
55impl Default for TestStorageConfig {
56 fn default() -> Self {
57 Self {
58 enable_persistent_storage: true,
59 storage_format: StorageFormat::JSON,
60 retention_policy: RetentionPolicy::KeepLast(1000),
61 compression: CompressionConfig::default(),
62 }
63 }
64}
65
66#[derive(Debug, Clone, PartialEq, Eq)]
68pub enum StorageFormat {
69 JSON,
70 Binary,
71 Database,
72 CSV,
73}
74
75#[derive(Debug, Clone)]
77pub enum RetentionPolicy {
78 KeepLast(usize),
80 KeepForDuration(Duration),
82 KeepAll,
84 Custom(String),
86}
87
88#[derive(Debug, Clone)]
90pub struct CompressionConfig {
91 pub enable_compression: bool,
93 pub algorithm: CompressionAlgorithm,
95 pub level: u8,
97}
98
99impl Default for CompressionConfig {
100 fn default() -> Self {
101 Self {
102 enable_compression: true,
103 algorithm: CompressionAlgorithm::Gzip,
104 level: 6,
105 }
106 }
107}
108
109#[derive(Debug, Clone, PartialEq, Eq)]
111pub enum CompressionAlgorithm {
112 Gzip,
113 Zstd,
114 Lz4,
115 None,
116}
117
118#[derive(Debug, Clone)]
120pub struct BenchmarkConfig {
121 pub enable_benchmarking: bool,
123 pub benchmark_suites: Vec<BenchmarkSuite>,
125 pub baseline_config: BaselineConfig,
127 pub statistical_config: StatisticalConfig,
129}
130
131impl Default for BenchmarkConfig {
132 fn default() -> Self {
133 Self {
134 enable_benchmarking: true,
135 benchmark_suites: vec![
136 BenchmarkSuite::Performance,
137 BenchmarkSuite::Scalability,
138 BenchmarkSuite::Accuracy,
139 ],
140 baseline_config: BaselineConfig::default(),
141 statistical_config: StatisticalConfig::default(),
142 }
143 }
144}
145
146#[derive(Debug, Clone, PartialEq, Eq)]
148pub enum BenchmarkSuite {
149 Performance,
151 Scalability,
153 Accuracy,
155 ResourceUtilization,
157 IntegrationComplexity,
159 Custom(String),
161}
162
163#[derive(Debug, Clone)]
165pub struct BaselineConfig {
166 pub use_historical: bool,
168 pub update_strategy: BaselineUpdateStrategy,
170 pub performance_thresholds: PerformanceThresholds,
172}
173
174impl Default for BaselineConfig {
175 fn default() -> Self {
176 Self {
177 use_historical: true,
178 update_strategy: BaselineUpdateStrategy::Automatic,
179 performance_thresholds: PerformanceThresholds::default(),
180 }
181 }
182}
183
184#[derive(Debug, Clone, PartialEq, Eq)]
186pub enum BaselineUpdateStrategy {
187 Automatic,
189 Manual,
191 TimeBased(Duration),
193 Never,
195}
196
197#[derive(Debug, Clone)]
199pub struct PerformanceThresholds {
200 pub max_execution_time: Duration,
202 pub min_solution_quality: f64,
204 pub max_resource_usage: f64,
206 pub max_error_rate: f64,
208}
209
210impl Default for PerformanceThresholds {
211 fn default() -> Self {
212 Self {
213 max_execution_time: Duration::from_secs(60),
214 min_solution_quality: 0.8,
215 max_resource_usage: 0.9,
216 max_error_rate: 0.05,
217 }
218 }
219}
220
221#[derive(Debug, Clone)]
223pub struct StatisticalConfig {
224 pub confidence_level: f64,
226 pub num_runs: usize,
228 pub statistical_tests: Vec<StatisticalTest>,
230 pub outlier_detection: OutlierDetection,
232}
233
234impl Default for StatisticalConfig {
235 fn default() -> Self {
236 Self {
237 confidence_level: 0.95,
238 num_runs: 10,
239 statistical_tests: vec![
240 StatisticalTest::TTest,
241 StatisticalTest::KolmogorovSmirnov,
242 StatisticalTest::MannWhitney,
243 ],
244 outlier_detection: OutlierDetection::IQR,
245 }
246 }
247}
248
249#[derive(Debug, Clone, PartialEq, Eq)]
251pub enum StatisticalTest {
252 TTest,
254 KolmogorovSmirnov,
256 MannWhitney,
258 Wilcoxon,
260 ChiSquared,
262}
263
264#[derive(Debug, Clone, PartialEq, Eq)]
266pub enum OutlierDetection {
267 IQR,
269 ZScore,
271 ModifiedZScore,
273 IsolationForest,
275 None,
277}
278
279#[derive(Debug, Clone)]
281pub struct StressTestConfig {
282 pub enable_stress_testing: bool,
284 pub stress_scenarios: Vec<StressScenario>,
286 pub max_stress_level: f64,
288 pub ramp_up_strategy: RampUpStrategy,
290 pub failure_criteria: FailureCriteria,
292}
293
294impl Default for StressTestConfig {
295 fn default() -> Self {
296 Self {
297 enable_stress_testing: true,
298 stress_scenarios: vec![
299 StressScenario::HighLoad,
300 StressScenario::ResourceContention,
301 StressScenario::NetworkLatency,
302 ],
303 max_stress_level: 0.95,
304 ramp_up_strategy: RampUpStrategy::Linear,
305 failure_criteria: FailureCriteria::default(),
306 }
307 }
308}
309
310#[derive(Debug, Clone, PartialEq, Eq)]
312pub enum StressScenario {
313 HighLoad,
315 ResourceContention,
317 NetworkLatency,
319 MemoryPressure,
321 ConcurrentAccess,
323 Custom(String),
325}
326
327#[derive(Debug, Clone, PartialEq, Eq)]
329pub enum RampUpStrategy {
330 Linear,
332 Exponential,
334 StepWise,
336 Random,
338}
339
340#[derive(Debug, Clone)]
342pub struct FailureCriteria {
343 pub max_failures: usize,
345 pub failure_rate_threshold: f64,
347 pub response_time_threshold: Duration,
349 pub resource_exhaustion_threshold: f64,
351}
352
353impl Default for FailureCriteria {
354 fn default() -> Self {
355 Self {
356 max_failures: 5,
357 failure_rate_threshold: 0.1,
358 response_time_threshold: Duration::from_secs(10),
359 resource_exhaustion_threshold: 0.95,
360 }
361 }
362}
363
364#[derive(Debug, Clone)]
366pub struct FaultInjectionConfig {
367 pub enable_fault_injection: bool,
369 pub fault_types: Vec<FaultType>,
371 pub timing_strategy: InjectionTiming,
373 pub test_recovery: bool,
375 pub chaos_config: ChaosConfig,
377}
378
379impl Default for FaultInjectionConfig {
380 fn default() -> Self {
381 Self {
382 enable_fault_injection: true,
383 fault_types: vec![
384 FaultType::NetworkFailure,
385 FaultType::ComponentFailure,
386 FaultType::ResourceExhaustion,
387 ],
388 timing_strategy: InjectionTiming::Random,
389 test_recovery: true,
390 chaos_config: ChaosConfig::default(),
391 }
392 }
393}
394
395#[derive(Debug, Clone, PartialEq, Eq)]
397pub enum FaultType {
398 NetworkFailure,
400 ComponentFailure,
402 ResourceExhaustion,
404 DataCorruption,
406 TimingIssues,
408 ConfigurationErrors,
410 Custom(String),
412}
413
414#[derive(Debug, Clone, PartialEq, Eq)]
416pub enum InjectionTiming {
417 Random,
419 Scheduled(Vec<Duration>),
421 TriggerBased(Vec<String>),
423 Continuous,
425}
426
427#[derive(Debug, Clone)]
429pub struct ChaosConfig {
430 pub enable_chaos: bool,
432 pub experiments: Vec<ChaosExperiment>,
434 pub blast_radius: BlastRadius,
436 pub safety_measures: SafetyMeasures,
438}
439
440impl Default for ChaosConfig {
441 fn default() -> Self {
442 Self {
443 enable_chaos: false, experiments: vec![],
445 blast_radius: BlastRadius::Limited,
446 safety_measures: SafetyMeasures::default(),
447 }
448 }
449}
450
451#[derive(Debug, Clone)]
453pub struct ChaosExperiment {
454 pub name: String,
456 pub experiment_type: ChaosType,
458 pub targets: Vec<String>,
460 pub duration: Duration,
462 pub success_criteria: Vec<String>,
464}
465
466#[derive(Debug, Clone, PartialEq, Eq)]
468pub enum ChaosType {
469 ServiceDegradation,
471 ResourceStarvation,
473 NetworkPartitioning,
475 DependencyFailure,
477 Custom(String),
479}
480
481#[derive(Debug, Clone, PartialEq, Eq)]
483pub enum BlastRadius {
484 Limited,
486 Controlled,
488 SystemWide,
490}
491
492#[derive(Debug, Clone)]
494pub struct SafetyMeasures {
495 pub auto_rollback_triggers: Vec<String>,
497 pub max_impact_duration: Duration,
499 pub emergency_stop: Vec<String>,
501 pub health_checks: Vec<String>,
503}
504
505impl Default for SafetyMeasures {
506 fn default() -> Self {
507 Self {
508 auto_rollback_triggers: vec![
509 "cpu_usage_critical".to_string(),
510 "memory_exhausted".to_string(),
511 ],
512 max_impact_duration: Duration::from_secs(300),
513 emergency_stop: vec!["system_failure".to_string(), "data_corruption".to_string()],
514 health_checks: vec!["system_health".to_string(), "component_status".to_string()],
515 }
516 }
517}
518
519#[derive(Debug, Clone)]
521pub struct MonitoringConfig {
522 pub enable_monitoring: bool,
524 pub monitoring_interval: Duration,
526 pub monitored_metrics: Vec<MonitoredMetric>,
528 pub alert_config: AlertConfig,
530 pub reporting_config: ReportingConfig,
532}
533
534impl Default for MonitoringConfig {
535 fn default() -> Self {
536 Self {
537 enable_monitoring: true,
538 monitoring_interval: Duration::from_secs(1),
539 monitored_metrics: vec![
540 MonitoredMetric::CpuUtilization,
541 MonitoredMetric::MemoryUsage,
542 MonitoredMetric::ErrorRate,
543 MonitoredMetric::ResponseTime,
544 ],
545 alert_config: AlertConfig::default(),
546 reporting_config: ReportingConfig::default(),
547 }
548 }
549}
550
551#[derive(Debug, Clone, PartialEq, Eq, Hash)]
553pub enum MonitoredMetric {
554 CpuUtilization,
556 MemoryUsage,
558 NetworkIO,
560 DiskIO,
562 ErrorRate,
564 ResponseTime,
566 Throughput,
568 ActiveConnections,
570 Custom(String),
572}
573
574#[derive(Debug, Clone)]
576pub struct AlertConfig {
577 pub enable_alerts: bool,
579 pub thresholds: HashMap<MonitoredMetric, f64>,
581 pub channels: Vec<AlertChannel>,
583 pub frequency_limits: FrequencyLimits,
585}
586
587impl Default for AlertConfig {
588 fn default() -> Self {
589 let mut thresholds = HashMap::new();
590 thresholds.insert(MonitoredMetric::ErrorRate, 0.1);
591 thresholds.insert(MonitoredMetric::MemoryUsage, 0.9);
592 thresholds.insert(MonitoredMetric::CpuUtilization, 0.95);
593
594 Self {
595 enable_alerts: true,
596 thresholds,
597 channels: vec![AlertChannel::Console],
598 frequency_limits: FrequencyLimits::default(),
599 }
600 }
601}
602
603#[derive(Debug, Clone, PartialEq, Eq)]
605pub enum AlertChannel {
606 Console,
608 Log,
610 Email(String),
612 Webhook(String),
614 Custom(String),
616}
617
618#[derive(Debug, Clone)]
620pub struct FrequencyLimits {
621 pub max_per_minute: usize,
623 pub cooldown_period: Duration,
625 pub enable_aggregation: bool,
627}
628
629impl Default for FrequencyLimits {
630 fn default() -> Self {
631 Self {
632 max_per_minute: 10,
633 cooldown_period: Duration::from_secs(60),
634 enable_aggregation: true,
635 }
636 }
637}
638
639#[derive(Debug, Clone)]
641pub struct ReportingConfig {
642 pub enable_automated_reporting: bool,
644 pub report_formats: Vec<ReportFormat>,
646 pub generation_frequency: ReportFrequency,
648 pub distribution: ReportDistribution,
650}
651
652impl Default for ReportingConfig {
653 fn default() -> Self {
654 Self {
655 enable_automated_reporting: true,
656 report_formats: vec![ReportFormat::HTML, ReportFormat::JSON],
657 generation_frequency: ReportFrequency::AfterTestSuite,
658 distribution: ReportDistribution::default(),
659 }
660 }
661}
662
663#[derive(Debug, Clone, PartialEq, Eq)]
665pub enum ReportFormat {
666 HTML,
668 JSON,
670 PDF,
672 CSV,
674 XML,
676}
677
678#[derive(Debug, Clone, PartialEq, Eq)]
680pub enum ReportFrequency {
681 AfterEachTest,
683 AfterTestSuite,
685 Scheduled(Duration),
687 Manual,
689}
690
691#[derive(Debug, Clone)]
693pub struct ReportDistribution {
694 pub email_recipients: Vec<String>,
696 pub file_paths: Vec<String>,
698 pub http_endpoints: Vec<String>,
700 pub custom_targets: Vec<String>,
702}
703
704impl Default for ReportDistribution {
705 fn default() -> Self {
706 Self {
707 email_recipients: vec![],
708 file_paths: vec!["./test_reports/".to_string()],
709 http_endpoints: vec![],
710 custom_targets: vec![],
711 }
712 }
713}
714
715#[derive(Debug, Clone)]
717pub struct TestEnvironmentConfig {
718 pub environment_name: String,
720 pub environment_variables: HashMap<String, String>,
722 pub resource_allocation: ResourceAllocationConfig,
724 pub cleanup_config: CleanupConfig,
726}
727
728impl Default for TestEnvironmentConfig {
729 fn default() -> Self {
730 Self {
731 environment_name: "default".to_string(),
732 environment_variables: HashMap::new(),
733 resource_allocation: ResourceAllocationConfig::default(),
734 cleanup_config: CleanupConfig::default(),
735 }
736 }
737}
738
739#[derive(Debug, Clone)]
741pub struct ResourceAllocationConfig {
742 pub max_cpu_cores: usize,
744 pub max_memory: usize,
746 pub max_disk_space: usize,
748 pub network_bandwidth_limit: Option<usize>,
750}
751
752impl Default for ResourceAllocationConfig {
753 fn default() -> Self {
754 Self {
755 max_cpu_cores: num_cpus::get(),
756 max_memory: 8 * 1024 * 1024 * 1024, max_disk_space: 100 * 1024 * 1024 * 1024, network_bandwidth_limit: None,
759 }
760 }
761}
762
763#[derive(Debug, Clone)]
765pub struct CleanupConfig {
766 pub auto_cleanup: bool,
768 pub cleanup_timeout: Duration,
770 pub preserve_on_failure: bool,
772 pub custom_scripts: Vec<String>,
774}
775
776impl Default for CleanupConfig {
777 fn default() -> Self {
778 Self {
779 auto_cleanup: true,
780 cleanup_timeout: Duration::from_secs(30),
781 preserve_on_failure: true,
782 custom_scripts: vec![],
783 }
784 }
785}