diff --git a/msgtest/module/group_manager.go b/msgtest/module/group_manager.go index e206204f0..aa011bc43 100644 --- a/msgtest/module/group_manager.go +++ b/msgtest/module/group_manager.go @@ -19,8 +19,15 @@ func (t *TestGroupManager) GenGroupID(prefix string) string { } func (t *TestGroupManager) CreateGroup(groupID string, groupName string, ownerUserID string, userIDs []string) error { + const batch = 2000 + var memberUserIDs []string + if len(userIDs) > batch { + memberUserIDs = userIDs[:batch] + } else { + memberUserIDs = userIDs + } req := &group.CreateGroupReq{ - MemberUserIDs: userIDs, + MemberUserIDs: memberUserIDs, OwnerUserID: ownerUserID, GroupInfo: &sdkws.GroupInfo{ GroupID: groupID, @@ -30,7 +37,32 @@ func (t *TestGroupManager) CreateGroup(groupID string, groupName string, ownerUs }, } resp := &group.CreateGroupResp{} - return t.postWithCtx(constant.CreateGroupRouter, &req, &resp) + if err := t.postWithCtx(constant.CreateGroupRouter, &req, &resp); err != nil { + return err + } + if len(userIDs) > batch { + num := len(userIDs) / batch + if len(userIDs)%batch != 0 { + num++ + } + for i := 1; i < num; i++ { + start := batch * i + end := batch*i + batch + if len(userIDs) < end { + end = len(userIDs) + } + req := map[string]any{ + "groupID": groupID, + "invitedUserIDs": userIDs[start:end], + "reason": "test", + } + resp := struct{}{} + if err := t.postWithCtx(constant.RouterGroup+"/invite_user_to_group", req, &resp); err != nil { + return err + } + } + } + return nil } func (t *TestGroupManager) InviteUserToGroup(ctx context.Context, groupID string, invitedUserIDs []string) error { diff --git a/msgtest/pressure_test.go b/msgtest/pressure_test.go index c74d72e6d..c4864d30c 100644 --- a/msgtest/pressure_test.go +++ b/msgtest/pressure_test.go @@ -48,7 +48,7 @@ func InitWithFlag() { flag.IntVar(&msgSenderNumEvreyUser, "m", 100, "msg sender num evrey user") flag.IntVar(&recvMsgUserNum, "r", 20, "recv msg user num") - flag.IntVar(&fastenedUserNum, "u", 320, "fastened user num") + flag.IntVar(&fastenedUserNum, "u", 300, "fastened user num") } func init() { @@ -128,7 +128,7 @@ func NewPressureTester() *PressureTester { func (p *PressureTester) genUserIDs() (userIDs, fastenedUserIDs, recvMsgUserIDs []string) { userIDs = p.userManager.GenUserIDs(totalOnlineUserNum - fastenedUserNum) // 在线用户 - fastenedUserIDs = p.userManager.GenUserIDsWithPrefix(fastenedUserNum, FastenedUserPrefix) // 指定320用户 + fastenedUserIDs = p.userManager.GenUserIDsWithPrefix(fastenedUserNum, FastenedUserPrefix) // 指定300用户 recvMsgUserIDs = p.userManager.GenUserIDsWithPrefix(recvMsgUserNum, RecvMsgPrefix) // 抽样用户完整SDK return } @@ -200,7 +200,7 @@ func (p *PressureTester) createTestGroups(userIDs, fastenedUserIDs, recvMsgUserI } p.tenThousandGroupIDs = append(p.tenThousandGroupIDs, groupID) } - // create thousand group + // create two thousand group exclude := TenThousandGroupNum * TenThousandGroupUserNum for i := 1; i <= ThousandGroupNum; i++ { groupID := p.groupManager.GenGroupID(fmt.Sprintf("thousandGroup_%d", i)) @@ -210,7 +210,7 @@ func (p *PressureTester) createTestGroups(userIDs, fastenedUserIDs, recvMsgUserI } p.thousandGroupIDs = append(p.thousandGroupIDs, groupID) } - // create hundred group + // create five hundred group exclude += exclude + ThousandGroupNum*ThousandGroupUserNum for i := 1; i <= HundredGroupNum; i++ { groupID := p.groupManager.GenGroupID(fmt.Sprintf("hundredGroup_%d", i)) diff --git a/wasm/indexdb/stranger_model.go b/wasm/indexdb/stranger_model.go index a0eece913..feaf7a6fd 100644 --- a/wasm/indexdb/stranger_model.go +++ b/wasm/indexdb/stranger_model.go @@ -33,7 +33,6 @@ type LocalStrangers struct { func NewLocalStrangers() *LocalStrangers { return &LocalStrangers{} } - func (l *LocalStrangers) GetStrangerInfo(ctx context.Context, userIDs []string) (result []*model_struct.LocalStranger, err error) { gList, err := exec.Exec(utils.StructToJsonString(userIDs)) if err != nil { diff --git a/wasm/indexdb/user_model.go b/wasm/indexdb/user_model.go index b2b90e645..b052b0333 100644 --- a/wasm/indexdb/user_model.go +++ b/wasm/indexdb/user_model.go @@ -94,29 +94,3 @@ func (l *LocalUsers) InsertLoginUser(ctx context.Context, user *model_struct.Loc _, err := exec.Exec(utils.StructToJsonString(temp)) return err } - -func (l *LocalUsers) GetStrangerInfo(ctx context.Context, userIDs []string) (result []*model_struct.LocalStranger, err error) { - gList, err := exec.Exec(utils.StructToJsonString(userIDs)) - if err != nil { - return nil, err - } else { - if v, ok := gList.(string); ok { - var temp []model_struct.LocalStranger - err := utils.JsonStringToStruct(v, &temp) - if err != nil { - return nil, err - } - for _, v := range temp { - v1 := v - result = append(result, &v1) - } - return result, err - } else { - return nil, exec.ErrType - } - } -} - -func (l *LocalUsers) SetStrangerInfo(ctx context.Context, strangerList []*model_struct.LocalStranger) error { - return nil -}