mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-05-05 05:30:44 +08:00
fix: improve sticky session scheduling
This commit is contained in:
@@ -31,3 +31,43 @@ func TestBuildSchedulerMetadataAccount_KeepsOpenAIWSFlags(t *testing.T) {
|
||||
require.Equal(t, true, got.Extra["mixed_scheduling"])
|
||||
require.Nil(t, got.Extra["unused_large_field"])
|
||||
}
|
||||
|
||||
func TestBuildSchedulerMetadataAccount_KeepsSlimGroupMembership(t *testing.T) {
|
||||
account := service.Account{
|
||||
ID: 42,
|
||||
Platform: service.PlatformAnthropic,
|
||||
GroupIDs: []int64{7, 9, 7, 0},
|
||||
AccountGroups: []service.AccountGroup{
|
||||
{
|
||||
AccountID: 42,
|
||||
GroupID: 7,
|
||||
Priority: 2,
|
||||
Account: &service.Account{ID: 42, Name: "drop-from-metadata"},
|
||||
Group: &service.Group{ID: 7, Name: "drop-from-metadata"},
|
||||
},
|
||||
{
|
||||
AccountID: 42,
|
||||
GroupID: 11,
|
||||
Priority: 3,
|
||||
Group: &service.Group{ID: 11, Name: "drop-from-metadata"},
|
||||
},
|
||||
{
|
||||
AccountID: 42,
|
||||
GroupID: 0,
|
||||
Priority: 4,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
got := buildSchedulerMetadataAccount(account)
|
||||
|
||||
require.Equal(t, []int64{7, 9, 11}, got.GroupIDs)
|
||||
require.Len(t, got.AccountGroups, 2)
|
||||
require.Equal(t, int64(42), got.AccountGroups[0].AccountID)
|
||||
require.Equal(t, int64(7), got.AccountGroups[0].GroupID)
|
||||
require.Equal(t, 2, got.AccountGroups[0].Priority)
|
||||
require.Nil(t, got.AccountGroups[0].Account)
|
||||
require.Nil(t, got.AccountGroups[0].Group)
|
||||
require.Equal(t, int64(11), got.AccountGroups[1].GroupID)
|
||||
require.Nil(t, got.Groups)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user