Skip to content

Commit

Permalink
feat: add test function about 1000 users join group send msg (openims…
Browse files Browse the repository at this point in the history
…dk#124) Signed-off-by: BanTanger <sharksharkchan@outlook.com>
  • Loading branch information
BanTanger committed Jul 20, 2023
1 parent 98b35bd commit 377a604
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 353 deletions.
19 changes: 17 additions & 2 deletions testv3/funcation/account.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package funcation

import (
Expand All @@ -11,6 +25,7 @@ import (

func RegisterOne(uid, nickname, faceurl string) (bool, error) {
InitContext(uid)
// config.UserID = uid
res, err := checkUserAccount(uid)
if err != nil {
return false, err
Expand Down Expand Up @@ -49,7 +64,7 @@ func checkUserAccount(uid string) (bool, error) {
var getAccountCheckResp userPB.AccountCheckResp
getAccountCheckReq.CheckUserIDs = []string{uid}
for {
err := util.ApiPost(ctx, "/user/account_check", &getAccountCheckReq, &getAccountCheckResp)
err := util.ApiPost(ctx, ACCOUNT_CHECK, &getAccountCheckReq, &getAccountCheckResp)
if err != nil {
return false, err
}
Expand All @@ -75,7 +90,7 @@ func registerUserAccount(uid, nickname, faceurl string) bool {
req.Users = []*sdkws.UserInfo{{UserID: uid, Nickname: nickname, FaceURL: faceurl}}
req.Secret = Secret
for {
err := util.ApiPost(ctx, "/user/user_register", &req, nil)
err := util.ApiPost(ctx, USER_REGISTER, &req, nil)
if err != nil {
log.Error("post failed ,continue ", err.Error(), REGISTERADDR)
time.Sleep(100 * time.Millisecond)
Expand Down
24 changes: 18 additions & 6 deletions testv3/funcation/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ var Config = sdk_struct.IMConfig{

// log and token
var (
rotateCount = uint(0)
LogLevel = uint32(6)
PlatformID = int32(1)
Secret = "tuoyun"
rotateCount = uint(0)
LogLevel = uint32(6)
PlatformID = int32(1)
Secret = "tuoyun"
// Secret = "openIM123"
IsLogStandardOutput = true
isLogJson = false
LogName = ""
Expand All @@ -56,7 +57,10 @@ var (
)

func init() {
AdminToken, _ = getToken("openIM123456")
AllLoginMgr = make(map[string]*CoreNode)

AdminUID := "openIM123456"
AdminToken, _ = GetToken(AdminUID)
// init log
if err := imLog.InitFromConfig(
"open-im-sdk-core", LogName, int(LogLevel), IsLogStandardOutput, isLogJson, LogFilePath, rotateCount); err != nil {
Expand All @@ -67,7 +71,8 @@ func init() {
// system
var (
// TESTIP = "59.36.173.89"
TESTIP = "203.56.175.233"
TESTIP = "203.56.175.233"
// TESTIP = "43.154.157.177"
APIADDR = "http://" + TESTIP + ":10002"
WSADDR = "ws://" + TESTIP + ":10001"
REGISTERADDR = APIADDR + "/auth/user_register"
Expand Down Expand Up @@ -95,3 +100,10 @@ var sendMsgClient = 0
var (
testConversation conversationCallBack
)

// route
var (
RPC_USER_TOKEN = "/auth/user_token"
ACCOUNT_CHECK = "/user/account_check"
USER_REGISTER = "/user/user_register"
)
17 changes: 0 additions & 17 deletions testv3/funcation/conversation.go

This file was deleted.

29 changes: 14 additions & 15 deletions testv3/funcation/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@ import (
"time"
)

func (t *testInitLister) OnUserTokenExpired() {
func (t *initLister) OnUserTokenExpired() {
log.Info("", utils.GetSelfFuncName())
}
func (t *testInitLister) OnConnecting() {
func (t *initLister) OnConnecting() {
log.Info("", utils.GetSelfFuncName())
}

func (t *testInitLister) OnConnectSuccess() {
func (t *initLister) OnConnectSuccess() {
log.Info("", utils.GetSelfFuncName())
}

func (t *testInitLister) OnConnectFailed(ErrCode int32, ErrMsg string) {
func (t *initLister) OnConnectFailed(ErrCode int32, ErrMsg string) {
log.Info("", utils.GetSelfFuncName(), ErrCode, ErrMsg)
}

func (t *testInitLister) OnKickedOffline() {
func (t *initLister) OnKickedOffline() {
log.Error("", utils.GetSelfFuncName(), "kick!!!!!!!!!!!!!!!!!!!!")
os.Exit(-1)
}

func (t *testInitLister) OnSelfInfoUpdated(info string) {
func (t *initLister) OnSelfInfoUpdated(info string) {
log.Info("", utils.GetSelfFuncName())
}

func (t *testInitLister) OnSuccess() {
func (t *initLister) OnSuccess() {
log.Info("", utils.GetSelfFuncName())
}

func (t *testInitLister) OnError(code int32, msg string) {
func (t *initLister) OnError(code int32, msg string) {
log.Info("", utils.GetSelfFuncName(), code, msg)
}

Expand All @@ -69,12 +69,12 @@ func (b *BaseSuccessFailed) OnSuccess(data string) {

func (c *conversationCallBack) OnError(errCode int32, errMsg string) {
// TODO implement me
panic("implement me")
// panic("implement me")
}

func (c *conversationCallBack) OnSuccess(data string) {
// TODO implement me
panic("implement me")
// panic("implement me")
}

func (c *conversationCallBack) OnNewConversation(conversationList string) {
Expand All @@ -87,7 +87,7 @@ func (c *conversationCallBack) OnConversationChanged(conversationList string) {

func (m *MsgListenerCallBak) OnRecvOfflineNewMessage(message string) {
// TODO implement me
panic("implement me")
// panic("implement me")
}

func (m *MsgListenerCallBak) OnRecvNewMessage(message string) {
Expand All @@ -113,7 +113,6 @@ func (testGroupListener) OnGroupMemberAdded(callbackInfo string) {
}
func (testGroupListener) OnGroupMemberDeleted(callbackInfo string) {
log.Info(utils.OperationIDGenerator(), utils.GetSelfFuncName(), callbackInfo)

}

func (testGroupListener) OnGroupApplicationAdded(callbackInfo string) {
Expand Down Expand Up @@ -194,7 +193,7 @@ func (m *MsgListenerCallBak) OnMsgDeleted(s string) {}

func (m *MsgListenerCallBak) OnRecvOfflineNewMessages(messageList string) {
// TODO implement me
panic("implement me")
// panic("implement me")
}

func (m *MsgListenerCallBak) OnRecvMessageExtensionsAdded(msgID string, reactionExtensionList string) {
Expand Down Expand Up @@ -223,11 +222,11 @@ func (userCallback) OnSelfInfoUpdated(callbackData string) {
}

func (c *conversationCallBack) OnRecvMessageExtensionsChanged(msgID string, reactionExtensionList string) {
panic("implement me")
// panic("implement me")
}

func (c *conversationCallBack) OnRecvMessageExtensionsDeleted(msgID string, reactionExtensionKeyList string) {
panic("implement me")
// panic("implement me")
}

func (c *conversationCallBack) OnSyncServerProgress(progress int) {
Expand Down
26 changes: 20 additions & 6 deletions testv3/funcation/login.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright © 2023 OpenIM SDK. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package funcation

import (
Expand All @@ -18,29 +32,29 @@ func LoginOne(uid string) bool {
// 返回值:成功登录和失败登录的 uidList
func LoginBatch(uidList []string) ([]string, []string) {
var successList, failList []string
for i, uid := range uidList {
for _, uid := range uidList {
if LoginOne(uid) == true {
successList[i] = uid
successList = append(successList, uid)
} else {
failList[i] = uid
failList = append(failList, uid)
}
}
return successList, failList
}

func collectToken(uid string) {
token, _ := getToken(uid)
token, _ := GetToken(uid)
coreMgrLock.Lock()
defer coreMgrLock.Unlock()
AllLoginMgr[uid] = &CoreNode{Token: token, UserID: uid}
}

func initAndLogin(uid, token string) bool {
var testinit testInitLister
var init initLister

lg := new(login.LoginMgr)

lg.InitSDK(Config, &testinit)
lg.InitSDK(Config, &init)
log.Info(uid, "new login ", lg)
AllLoginMgr[uid].Mgr = lg
log.Info(uid, "InitSDK ", Config, "index mgr", uid, lg)
Expand Down
Loading

0 comments on commit 377a604

Please sign in to comment.