feat(seckill): 增加只读预演并强化代理风控切换
This commit is contained in:
@@ -29,6 +29,39 @@ func TestProxyDrillPlanAndTargets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateProxyDrillMatchesRuntimeGate(t *testing.T) {
|
||||
plan := proxyDrillPlan{active: 4, standby: 2}
|
||||
cases := []struct {
|
||||
name string
|
||||
healthyActive int
|
||||
healthyStandby int
|
||||
extracted int
|
||||
wantSuccess bool
|
||||
wantWarning bool
|
||||
}{
|
||||
{name: "all healthy", healthyActive: 4, healthyStandby: 2, extracted: 6, wantSuccess: true},
|
||||
{name: "standby shortage still starts", healthyActive: 4, healthyStandby: 1, extracted: 5, wantSuccess: true, wantWarning: true},
|
||||
{name: "active failure blocks", healthyActive: 3, healthyStandby: 2, extracted: 6, wantSuccess: false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
success, errMessage, warning := evaluateProxyDrill(plan, tc.healthyActive, tc.healthyStandby, tc.extracted)
|
||||
if success != tc.wantSuccess {
|
||||
t.Fatalf("success=%v, want %v", success, tc.wantSuccess)
|
||||
}
|
||||
if tc.wantSuccess && errMessage != "" {
|
||||
t.Fatalf("unexpected error: %s", errMessage)
|
||||
}
|
||||
if !tc.wantSuccess && errMessage == "" {
|
||||
t.Fatal("active failure should return an error")
|
||||
}
|
||||
if (warning != "") != tc.wantWarning {
|
||||
t.Fatalf("warning=%q, wantWarning=%v", warning, tc.wantWarning)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractProxyDrillPoolDeduplicates(t *testing.T) {
|
||||
apiServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
for i := 0; i < 8; i++ {
|
||||
|
||||
Reference in New Issue
Block a user