feat(e2e): add distributed E2E test framework with parametric traffic generation
Add run-e2e-test.sh with CLI parameters (--hits, --http-ratio, --dns, --tls, --src-ips, --keep-analysis, --up) for configurable traffic generation. Traffic runs from VM endpoints with multiple source IPs (alias IPs on eth0) to produce distinct sessions for the ML pipeline. Fix curl TLS flags (--tlsv1.2 instead of --tls-v1-2), skip redundant local verification in distributed mode, and fix dashboard is_available() cache that never retried after ClickHouse recovery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -106,31 +106,40 @@ def record_cycle_metrics(
|
||||
_emit_alerts(model_name, anomaly_rate, drift_rate, correlated_rate, latency_ms, drift_alert)
|
||||
|
||||
try:
|
||||
client.execute(
|
||||
f"INSERT INTO {db}.ml_performance_metrics VALUES",
|
||||
[{
|
||||
'cycle_at': now,
|
||||
'model_name': model_name,
|
||||
'total_sessions': n_total,
|
||||
'correlated_rate': round(float(correlated_rate), 4),
|
||||
'anomaly_rate': round(float(anomaly_rate), 4),
|
||||
'critical_count': n_critical,
|
||||
'high_count': n_high,
|
||||
'medium_count': n_medium,
|
||||
'low_count': n_low,
|
||||
'known_bot_count': n_known_bot,
|
||||
'anubis_deny_count': n_anubis_deny,
|
||||
'legit_browser_count': n_legit_browser,
|
||||
'drift_rate': round(float(drift_rate), 4),
|
||||
'drift_alert': drift_alert,
|
||||
'cycle_latency_ms': latency_ms,
|
||||
'features_valid': valid_features,
|
||||
'features_total': total_features,
|
||||
'baseline_size': baseline_size,
|
||||
'threshold': round(float(threshold), 6),
|
||||
'meta_learner_active': 1 if meta_learner_active else 0,
|
||||
}]
|
||||
# Vérifier que la table existe avant d'insérer (optionnelle)
|
||||
table_check = client.query(
|
||||
f"SELECT name FROM system.tables WHERE database = '{db}' AND name = 'ml_performance_metrics'"
|
||||
)
|
||||
if not table_check.result_rows:
|
||||
logger.debug("[Metrics] Table ml_performance_metrics absente — métriques non enregistrées")
|
||||
return
|
||||
|
||||
client.insert(
|
||||
f"{db}.ml_performance_metrics",
|
||||
[[
|
||||
now,
|
||||
model_name,
|
||||
n_total,
|
||||
round(float(correlated_rate), 4),
|
||||
round(float(anomaly_rate), 4),
|
||||
n_critical,
|
||||
n_high,
|
||||
n_medium,
|
||||
n_low,
|
||||
n_known_bot,
|
||||
n_anubis_deny,
|
||||
n_legit_browser,
|
||||
round(float(drift_rate), 4),
|
||||
drift_alert,
|
||||
latency_ms,
|
||||
valid_features,
|
||||
total_features,
|
||||
baseline_size,
|
||||
round(float(threshold), 6),
|
||||
1 if meta_learner_active else 0,
|
||||
]]
|
||||
)
|
||||
logger.debug(f"[Metrics] Cycle {cycle_id} enregistré ({latency_ms}ms)")
|
||||
except Exception as e:
|
||||
logger.warning(f"[Metrics] Erreur d'enregistrement des métriques : {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user