From 8b4d2773d21930c07877f6cbbb45a53bda694a6d Mon Sep 17 00:00:00 2001 From: ckt1031 <65409152+ckt1031@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:06:12 +0800 Subject: [PATCH] feat: enhanced channel test --- controller/channel-test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index 956b67e7..0d8892b2 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -261,12 +261,17 @@ func testAllChannels(notify bool) error { err, openaiErr := testChannel(channel, *testRequest) tok := time.Now() milliseconds := tok.Sub(tik).Milliseconds() + channelBeninDisabled := false if milliseconds > disableThreshold { err = errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0)) disableChannel(channel.Id, channel.Name, err.Error()) - } else if shouldDisableChannel(openaiErr, -1) { + channelBeninDisabled = true + } + if shouldDisableChannel(openaiErr, -1) { disableChannel(channel.Id, channel.Name, err.Error()) - } else if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled { + channelBeninDisabled = true + } + if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled && !channelBeninDisabled { enableChannel(channel.Id, channel.Name) } channel.UpdateResponseTime(milliseconds)