feat(channels): add auto-disable-only channel test mode (#6728)

This commit is contained in:
Seefs
2026-08-10 12:47:44 +08:00
committed by GitHub
parent 823e26304a
commit 5d3423bec1
13 changed files with 146 additions and 11 deletions
+4 -1
View File
@@ -15,6 +15,7 @@ type MonitorSetting struct {
const (
ChannelTestModeScheduledAll = "scheduled_all"
ChannelTestModeAutoBanOnly = "auto_ban_only"
ChannelTestModePassiveRecovery = "passive_recovery"
)
@@ -45,7 +46,9 @@ func GetMonitorSetting() *MonitorSetting {
monitorSetting.AutoTestChannelEnabled = parsed
}
}
if monitorSetting.ChannelTestMode != ChannelTestModePassiveRecovery {
switch monitorSetting.ChannelTestMode {
case ChannelTestModeAutoBanOnly, ChannelTestModePassiveRecovery:
default:
monitorSetting.ChannelTestMode = ChannelTestModeScheduledAll
}
return &monitorSetting
@@ -41,3 +41,17 @@ func TestGetMonitorSetting_ChannelTestEnabledEnvCanEnableDisabledConfig(t *testi
assert.True(t, setting.AutoTestChannelEnabled)
assert.Equal(t, float64(12), setting.AutoTestChannelMinutes)
}
func TestGetMonitorSettingPreservesAutoBanOnlyMode(t *testing.T) {
orig := monitorSetting
t.Cleanup(func() { monitorSetting = orig })
t.Setenv("CHANNEL_TEST_ENABLED", "")
t.Setenv("CHANNEL_TEST_FREQUENCY", "")
monitorSetting = MonitorSetting{ChannelTestMode: ChannelTestModeAutoBanOnly}
setting := GetMonitorSetting()
require.NotNil(t, setting)
assert.Equal(t, ChannelTestModeAutoBanOnly, setting.ChannelTestMode)
}