feat(channels): add auto-disable-only channel test mode (#6728)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user