feat: sync deployed v1.0.0-rc.38-custom.67
This commit is contained in:
1 parent
d09216bbde
commit
8e6ed0317b
154 files changed
+39540
-20509
No files matched your search
@@ -38,7 +38,7 @@ func TestLiveUserResults(t *testing.T) {
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Cleanup(func() { liveResults.Delete(tc.name) })
|
||||
RecordRelayResult(tc.ctx, &relaycommon.RelayInfo{UsingGroup: tc.name, TokenId: tc.token, IsChannelTest: tc.test, StartTime: time.Now()}, tc.err)
|
||||
RecordRelayResult(tc.ctx, &relaycommon.RelayInfo{UsingGroup: tc.name, TokenId: tc.token, IsChannelTest: tc.test, IsStream: true, StartTime: time.Now()}, tc.err)
|
||||
result := LatestUserResults(context.Background(), []string{tc.name})[tc.name]
|
||||
assert.Equal(t, tc.want, result.At > 0)
|
||||
if tc.want {
|
||||
@@ -60,6 +60,8 @@ func TestUserResultsAreOrderedAndSurviveRestart(t *testing.T) {
|
||||
client.Close()
|
||||
})
|
||||
ctx := context.Background()
|
||||
require.NoError(t, client.Set(ctx, "status:user-result:group", "9999999999999:false", time.Minute).Err())
|
||||
assert.Empty(t, LatestUserResults(ctx, []string{"group"}))
|
||||
check := func(want UserRequestResult) {
|
||||
assert.Equal(t, want, LatestUserResults(ctx, []string{"group"})["group"])
|
||||
liveResults.Delete("group")
|
||||
@@ -76,9 +78,33 @@ func TestUserResultsAreOrderedAndSurviveRestart(t *testing.T) {
|
||||
recordUserResult("group", UserRequestResult{At: 2001, Success: false})
|
||||
check(UserRequestResult{At: 2002, Success: true})
|
||||
assert.True(t, LatestUserResults(ctx, []string{"other"})["other"].Success)
|
||||
ttl, err := client.TTL(ctx, "status:user-result:group").Result()
|
||||
ttl, err := client.TTL(ctx, "status:stream-user-result:group").Result()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 15*time.Minute, ttl)
|
||||
server.FastForward(15 * time.Minute)
|
||||
assert.Zero(t, LatestUserResults(ctx, []string{"group"})["group"].At)
|
||||
}
|
||||
|
||||
func TestNonStreamRequestsCannotChangeHealth(t *testing.T) {
|
||||
oldRedis := common.RedisEnabled
|
||||
common.RedisEnabled = false
|
||||
t.Cleanup(func() {
|
||||
common.RedisEnabled = oldRedis
|
||||
liveResults.Delete("stream-only")
|
||||
hotBuckets.Clear()
|
||||
})
|
||||
ctx := context.Background()
|
||||
info := &relaycommon.RelayInfo{UsingGroup: "stream-only", OriginModelName: "test-model", TokenId: 1, IsStream: true, StartTime: time.Now()}
|
||||
RecordRelayResult(ctx, info, nil)
|
||||
want := LatestUserResults(ctx, []string{info.UsingGroup})[info.UsingGroup]
|
||||
require.True(t, want.Success)
|
||||
require.Positive(t, want.At)
|
||||
info.IsStream = false
|
||||
for _, apiErr := range []*types.NewAPIError{nil, types.InitOpenAIError("server_error", 500), types.InitOpenAIError("server_error", 502)} {
|
||||
RecordRelayResult(ctx, info, apiErr)
|
||||
assert.Equal(t, want, LatestUserResults(ctx, []string{info.UsingGroup})[info.UsingGroup])
|
||||
}
|
||||
info.IsStream = true
|
||||
RecordRelayResult(ctx, info, types.InitOpenAIError("server_error", 502))
|
||||
assert.False(t, LatestUserResults(ctx, []string{info.UsingGroup})[info.UsingGroup].Success)
|
||||
}
|
||||
Reference in new issue
Block a user