mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-03 16:26:36 +08:00
test cron
This commit is contained in:
parent
e588091bf6
commit
0e62deed0a
@ -4,6 +4,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -24,7 +25,7 @@ var (
|
|||||||
|
|
||||||
func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.UserChat {
|
func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.UserChat {
|
||||||
chat := &db.UserChat{UID: userID + strconv.Itoa(int(index))}
|
chat := &db.UserChat{UID: userID + strconv.Itoa(int(index))}
|
||||||
for i := startSeq; i <= stopSeq; i++ {
|
for i := startSeq; i < stopSeq; i++ {
|
||||||
msg := server_api_params.MsgData{
|
msg := server_api_params.MsgData{
|
||||||
SendID: "sendID1",
|
SendID: "sendID1",
|
||||||
RecvID: "recvID1",
|
RecvID: "recvID1",
|
||||||
@ -44,7 +45,12 @@ func GenUserChat(startSeq, stopSeq, delSeq, index uint32, userID string) *db.Use
|
|||||||
Status: 1,
|
Status: 1,
|
||||||
}
|
}
|
||||||
bytes, _ := proto.Marshal(&msg)
|
bytes, _ := proto.Marshal(&msg)
|
||||||
sendTime := 0
|
var sendTime int64
|
||||||
|
if i <= delSeq {
|
||||||
|
sendTime = 10000
|
||||||
|
} else {
|
||||||
|
sendTime = utils.GetCurrentTimestampByMill()
|
||||||
|
}
|
||||||
chat.Msg = append(chat.Msg, db.MsgInfo{SendTime: int64(sendTime), Msg: bytes})
|
chat.Msg = append(chat.Msg, db.MsgInfo{SendTime: int64(sendTime), Msg: bytes})
|
||||||
}
|
}
|
||||||
return chat
|
return chat
|
||||||
@ -54,6 +60,12 @@ func SetUserMaxSeq(userID string, seq int) error {
|
|||||||
return redisClient.Set(context.Background(), "REDIS_USER_INCR_SEQ"+userID, seq, 0).Err()
|
return redisClient.Set(context.Background(), "REDIS_USER_INCR_SEQ"+userID, seq, 0).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserMinSeq(userID string) (uint64, error) {
|
||||||
|
key := "REDIS_USER_MIN_SEQ:" + userID
|
||||||
|
seq, err := redisClient.Get(context.Background(), key).Result()
|
||||||
|
return uint64(utils.StringToInt(seq)), err
|
||||||
|
}
|
||||||
|
|
||||||
func CreateChat(userChat *db.UserChat) error {
|
func CreateChat(userChat *db.UserChat) error {
|
||||||
_, err := mongoClient.InsertOne(context.Background(), userChat)
|
_, err := mongoClient.InsertOne(context.Background(), userChat)
|
||||||
return err
|
return err
|
||||||
@ -80,25 +92,17 @@ func TestDeleteMongoMsgAndResetRedisSeq(t *testing.T) {
|
|||||||
err = SetUserMaxSeq(testUID1, 600)
|
err = SetUserMaxSeq(testUID1, 600)
|
||||||
userChat := GenUserChat(1, 500, 200, 0, testUID1)
|
userChat := GenUserChat(1, 500, 200, 0, testUID1)
|
||||||
err = CreateChat(userChat)
|
err = CreateChat(userChat)
|
||||||
|
|
||||||
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID1); err != nil {
|
if err := DeleteMongoMsgAndResetRedisSeq(operationID, testUID1); err != nil {
|
||||||
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
||||||
}
|
}
|
||||||
if err := checkMaxSeqWithMongo(operationID, testUID1, constant.WriteDiffusion); err != nil {
|
if err := checkMaxSeqWithMongo(operationID, testUID1, constant.WriteDiffusion); err != nil {
|
||||||
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
t.Error("checkMaxSeqWithMongo failed", testUID1)
|
||||||
}
|
}
|
||||||
|
minSeq, err := GetUserMinSeq(testUID1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("err is not nil", testUID1, err.Error())
|
t.Error("err is not nil", testUID1, err.Error())
|
||||||
}
|
}
|
||||||
// testWorkingGroupIDList := []string{"test_del_id1", "test_del_id2", "test_del_id3", "test_del_id4", "test_del_id5"}
|
if minSeq != 201 {
|
||||||
// for _, groupID := range testWorkingGroupIDList {
|
t.Error("is not the same")
|
||||||
// operationID = groupID + "-" + operationID
|
}
|
||||||
// log.NewDebug(operationID, utils.GetSelfFuncName(), "groupID:", groupID, "userIDList:", testUserIDList)
|
|
||||||
// if err := ResetUserGroupMinSeq(operationID, groupID, testUserIDList); err != nil {
|
|
||||||
// t.Error("checkMaxSeqWithMongo failed", groupID)
|
|
||||||
// }
|
|
||||||
// if err := checkMaxSeqWithMongo(operationID, groupID, constant.ReadDiffusion); err != nil {
|
|
||||||
// t.Error("checkMaxSeqWithMongo failed", groupID)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
//
|
|
||||||
//func main() {
|
|
||||||
// db.DB.BatchInsertChat()
|
|
||||||
//}
|
|
@ -264,8 +264,8 @@ func (g *Getui) request(url string, content interface{}, token string, returnStr
|
|||||||
|
|
||||||
func (pushReq *PushReq) setPushChannel(title string, body string) {
|
func (pushReq *PushReq) setPushChannel(title string, body string) {
|
||||||
pushReq.PushChannel = &PushChannel{}
|
pushReq.PushChannel = &PushChannel{}
|
||||||
// autoBadge := "+1"
|
autoBadge := "+1"
|
||||||
pushReq.PushChannel.Ios = &Ios{}
|
pushReq.PushChannel.Ios = &Ios{AutoBadge: &autoBadge}
|
||||||
notify := "notify"
|
notify := "notify"
|
||||||
pushReq.PushChannel.Ios.NotiType = ¬ify
|
pushReq.PushChannel.Ios.NotiType = ¬ify
|
||||||
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user