feat(automation): 增加重登熔断与登录预算配置
This commit is contained in:
@@ -161,6 +161,48 @@ class TestFailureClassification(_Base):
|
||||
assert ck_relogin.classify_failure("") == "network"
|
||||
|
||||
|
||||
class TestFailureCircuit(_Base):
|
||||
def test_hard_failure_ratio_pauses_job(self):
|
||||
paused, hard, ratio = ck_relogin.evaluate_failure_circuit(
|
||||
{
|
||||
"scanned": 10,
|
||||
"invalid": 7,
|
||||
"email_quota": 0,
|
||||
},
|
||||
{},
|
||||
)
|
||||
|
||||
assert paused is True
|
||||
assert hard == 7
|
||||
assert ratio == 0.7
|
||||
|
||||
def test_email_quota_does_not_trigger_circuit(self):
|
||||
paused, hard, ratio = ck_relogin.evaluate_failure_circuit(
|
||||
{
|
||||
"scanned": 10,
|
||||
"invalid": 10,
|
||||
"email_quota": 10,
|
||||
},
|
||||
{},
|
||||
)
|
||||
|
||||
assert paused is False
|
||||
assert hard == 0
|
||||
assert ratio == 0
|
||||
|
||||
def test_minimum_sample_size_is_respected(self):
|
||||
paused, _, _ = ck_relogin.evaluate_failure_circuit(
|
||||
{
|
||||
"scanned": 5,
|
||||
"invalid": 5,
|
||||
"email_quota": 0,
|
||||
},
|
||||
{"failure_pause_min_scanned": 10},
|
||||
)
|
||||
|
||||
assert paused is False
|
||||
|
||||
|
||||
class TestBackoff(_Base):
|
||||
def test_ladder_is_escalating(self):
|
||||
now = datetime(2026, 10, 2, 12, 0, tzinfo=UTC)
|
||||
|
||||
Reference in New Issue
Block a user