Track VPN pressure history
This commit is contained in:
@@ -910,6 +910,7 @@ func vpnFabricFlowPressureReport(snapshot vpnruntime.FabricFlowSchedulerSnapshot
|
||||
"pressure_score": snapshot.PressureScore,
|
||||
"pressure_reasons": append([]string{}, snapshot.PressureReasons...),
|
||||
"recommended_action": snapshot.RecommendedAction,
|
||||
"pressure_history": copyFabricFlowPressureHistory(snapshot.PressureHistory),
|
||||
"backpressure_active": snapshot.BackpressureActive,
|
||||
"bulk_pressure_active": snapshot.BulkPressureActive,
|
||||
"bulk_pressure_channel_count": snapshot.BulkPressureChannelCount,
|
||||
@@ -936,6 +937,18 @@ func vpnFabricFlowPressureReport(snapshot vpnruntime.FabricFlowSchedulerSnapshot
|
||||
return report
|
||||
}
|
||||
|
||||
func copyFabricFlowPressureHistory(in []vpnruntime.FabricFlowPressureHistorySample) []vpnruntime.FabricFlowPressureHistorySample {
|
||||
if len(in) == 0 {
|
||||
return []vpnruntime.FabricFlowPressureHistorySample{}
|
||||
}
|
||||
out := make([]vpnruntime.FabricFlowPressureHistorySample, 0, len(in))
|
||||
for _, sample := range in {
|
||||
sample.PressureReasons = append([]string{}, sample.PressureReasons...)
|
||||
out = append(out, sample)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func copyStringIntMap(in map[string]int) map[string]int {
|
||||
if len(in) == 0 {
|
||||
return map[string]int{}
|
||||
|
||||
@@ -1260,12 +1260,25 @@ func TestVPNFabricFlowPressureReportIncludesRecommendedAction(t *testing.T) {
|
||||
RouteRecoveredChannelCount: 0,
|
||||
RouteRecoveryMaxMillis: 0,
|
||||
RouteRecoveryAvgMillis: 0,
|
||||
PressureHistory: []vpnruntime.FabricFlowPressureHistorySample{
|
||||
{
|
||||
ObservedAt: "2026-05-16T12:00:00Z",
|
||||
PressureLevel: "warning",
|
||||
PressureScore: 35,
|
||||
PressureReasons: []string{"bulk_pressure"},
|
||||
RecommendedAction: "throttle_bulk",
|
||||
},
|
||||
},
|
||||
})
|
||||
if report["recommended_action"] != "throttle_bulk" ||
|
||||
report["pressure_score"] != 35 ||
|
||||
report["bulk_pressure_channel_count"] != 16 {
|
||||
t.Fatalf("unexpected flow pressure report: %+v", report)
|
||||
}
|
||||
history, ok := report["pressure_history"].([]vpnruntime.FabricFlowPressureHistorySample)
|
||||
if !ok || len(history) != 1 || history[0].RecommendedAction != "throttle_bulk" {
|
||||
t.Fatalf("unexpected flow pressure history: %+v", report["pressure_history"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergedEndpointCandidateObservationsKeepsNewest(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user