feat: Integrate Comprehensive E2E Testing for GoChat (#1906)

* feat: create e2e test readme

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* feat: fix markdown file

* feat: add openim make lint

* feat: add git chglog pull request

* feat: add git chglog pull request

* fix: fix openim api err code

* fix: fix openim api err code

* fix: fix openim api err code

* feat: Improve CICD

* feat: Combining GitHub and Google Workspace for Effective Project Management'

* feat: fix openim tools error code

* feat: fix openim tools error code

* feat: add openim error handle

* feat: add openim error handle

* feat: optimize tim white prom code return err

* feat: fix openim tools error code

* style: format openim server code style

* feat: add openim optimize commit code

* feat: add openim optimize commit code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: format openim code

* feat: Some of the notes were translated

* feat: Some of the notes were translated

* feat: update openim server code

* feat: optimize openim reset code

* feat: optimize openim reset code

---------

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong
2024-03-04 12:12:14 +08:00
committed by GitHub
parent 1ef26b29a7
commit 853ac47e42
131 changed files with 1133 additions and 881 deletions
@@ -38,11 +38,20 @@ import (
func main() {
var (
topic = "ws2ms_chat" // v2版本配置文件kafka.topic.ws2ms_chat
kafkaAddr = "127.0.0.1:9092" // v2版本配置文件kafka.topic.addr
rpcAddr = "127.0.0.1:10130" // v3版本配置文件rpcPort.openImMessagePort
adminUserID = "openIM123456" // v3版本管理员userID
concurrency = 1 // 并发数量
// The Kafka topic for ws2ms_chat in version 2 configuration
topic = "ws2ms_chat"
// The Kafka address in version 2 configuration
kafkaAddr = "127.0.0.1:9092"
// The RPC address in version 3 configuration
rpcAddr = "127.0.0.1:10130"
// The administrator userID in version 3
adminUserID = "openIM123456"
// The number of concurrent processes
concurrency = 1
)
getRpcConn := func() (*grpc.ClientConn, error) {
@@ -99,7 +108,7 @@ func main() {
ch := pc.Messages()
for {
select {
case <-time.After(time.Second * 10): // 10s读取不到就关闭
case <-time.After(time.Second * 10): // 10s Shuts down when the data cannot be read
return
case message, ok := <-ch:
if !ok {
@@ -27,21 +27,37 @@ import (
)
func main() {
var (
usernameV2 = "root" // v2版本mysql用户名
passwordV2 = "openIM" // v2版本mysql密码
addrV2 = "127.0.0.1:13306" // v2版本mysql地址
databaseV2 = "openIM_v2" // v2版本mysql数据库名字
// MySQL username for version 2
usernameV2 = "root"
// MySQL password for version 2
passwordV2 = "openIM"
// MySQL address for version 2
addrV2 = "127.0.0.1:13306"
// MySQL database name for version 2
databaseV2 = "openIM_v2"
)
var (
usernameV3 = "root" // v3版本mysql用户名
passwordV3 = "openIM123" // v3版本mysql密码
addrV3 = "127.0.0.1:13306" // v3版本mysql地址
databaseV3 = "openim_v3" // v3版本mysql数据库名字
// MySQL username for version 3
usernameV3 = "root"
// MySQL password for version 3
passwordV3 = "openIM123"
// MySQL address for version 3
addrV3 = "127.0.0.1:13306"
// MySQL database name for version 3
databaseV3 = "openim_v3"
)
var concurrency = 1 // 并发数量
// The number of concurrent processes
var concurrency = 1
log.SetFlags(log.LstdFlags | log.Llongfile)
dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2)
+25 -36
View File
@@ -38,41 +38,30 @@ func (FriendModel) TableName() string {
}
type FriendModelInterface interface {
// 插入多条记录
Create(ctx context.Context, friends []*FriendModel) (err error)
// 删除ownerUserID指定的好友
Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error)
// 更新ownerUserID单个好友信息 更新零值
UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}) (err error)
// 更新好友信息的非零值
Update(ctx context.Context, friends []*FriendModel) (err error)
// 更新好友备注(也支持零值
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
// 获取单个好友信息,如没找到 返回错误
Take(ctx context.Context, ownerUserID, friendUserID string) (friend *FriendModel, err error)
// 查找好友关系,如果是双向关系,则都返回
FindUserState(ctx context.Context, userID1, userID2 string) (friends []*FriendModel, err error)
// 获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*FriendModel, err error)
// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误
FindReversalFriends(
ctx context.Context,
friendUserID string,
ownerUserIDs []string,
) (friends []*FriendModel, err error)
// 获取ownerUserID好友列表 支持翻页
FindOwnerFriends(
ctx context.Context,
ownerUserID string,
pageNumber, showNumber int32,
) (friends []*FriendModel, total int64, err error)
// 获取哪些人添加了friendUserID 支持翻页
FindInWhoseFriends(
ctx context.Context,
friendUserID string,
pageNumber, showNumber int32,
) (friends []*FriendModel, total int64, err error)
// 获取好友UserID列表
FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
// Create inserts multiple friend records.
Create(ctx context.Context, friends []*FriendModel) error
// Delete removes specified friends for an owner user.
Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) error
// UpdateByMap updates a single friend's information for an owner user based on a map of arguments. Zero values are updated.
UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}) error
// Update modifies the information of friends, excluding zero values.
Update(ctx context.Context, friends []*FriendModel) error
// UpdateRemark updates the remark for a friend, supporting zero values.
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) error
// Take retrieves a single friend's information. Returns an error if not found.
Take(ctx context.Context, ownerUserID, friendUserID string) (*FriendModel, error)
// FindUserState finds the friendship status between two users, returning both if a mutual friendship exists.
FindUserState(ctx context.Context, userID1, userID2 string) ([]*FriendModel, error)
// FindFriends retrieves a list of friends for an owner, not returning an error for non-existent friendUserIDs.
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) ([]*FriendModel, error)
// FindReversalFriends finds who has added the specified user as a friend, not returning an error for non-existent ownerUserIDs.
FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string) ([]*FriendModel, error)
// FindOwnerFriends paginates through the friends list of an owner user.
FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) ([]*FriendModel, int64, error)
// FindInWhoseFriends paginates through users who have added the specified user as a friend.
FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) ([]*FriendModel, int64, error)
// FindFriendUserIDs retrieves a list of friend user IDs for an owner user.
FindFriendUserIDs(ctx context.Context, ownerUserID string) ([]string, error)
// NewTx creates a new transactional instance of the FriendModelInterface.
NewTx(tx any) FriendModelInterface
}
@@ -38,29 +38,33 @@ func (FriendRequestModel) TableName() string {
}
type FriendRequestModelInterface interface {
// 插入多条记录
// Insert multiple records
Create(ctx context.Context, friendRequests []*FriendRequestModel) (err error)
// 删除记录
// Delete a record
Delete(ctx context.Context, fromUserID, toUserID string) (err error)
// 更新零值
UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}) (err error)
// 更新多条记录 (非零值)
// Update records with zero values based on a map of changes
UpdateByMap(ctx context.Context, formUserID, toUserID string, args map[string]interface{}) (err error)
// Update multiple records (non-zero values)
Update(ctx context.Context, friendRequest *FriendRequestModel) (err error)
// 获取来指定用户的好友申请 未找到 不返回错误
// Find a friend request sent to a specific user; does not return an error if not found
Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)
// Alias for Find (retrieves a friend request between two users)
Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)
// 获取toUserID收到的好友申请列表
FindToUserID(
ctx context.Context,
toUserID string,
pageNumber, showNumber int32,
) (friendRequests []*FriendRequestModel, total int64, err error)
// 获取fromUserID发出去的好友申请列表
FindFromUserID(
ctx context.Context,
fromUserID string,
pageNumber, showNumber int32,
) (friendRequests []*FriendRequestModel, total int64, err error)
// Get a list of friend requests received by `toUserID`
FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error)
// Get a list of friend requests sent by `fromUserID`
FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error)
// Find all friend requests between two users (both directions)
FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*FriendRequestModel, err error)
// Create a new transaction
NewTx(tx any) FriendRequestModelInterface
}
@@ -58,9 +58,10 @@ type GroupModelInterface interface {
keyword string,
pageNumber, showNumber int32,
) (total uint32, groups []*GroupModel, err error)
// GetGroupIDsByCreatorUserID retrieves a list of group IDs created by the specified user.
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
// 获取群总数
// CountTotal retrieves the total number of groups.
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
// 获取范围内群增量
// CountRangeEverydayTotal retrieves the total number of groups created every day within the specified time range.
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
}
+20 -5
View File
@@ -53,20 +53,35 @@ func (UserModel) TableName() string {
return UserModelTableName
}
// UserModelInterface defines the operations available for managing user models.
type UserModelInterface interface {
// Create inserts a new user or multiple users into the database.
Create(ctx context.Context, users []*UserModel) (err error)
// UpdateByMap updates a user's information based on a map of changes.
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
// Update modifies a user's information in the database.
Update(ctx context.Context, user *UserModel) (err error)
// 获取指定用户信息 不存在,也不返回错误
// Find retrieves information for a list of users by their IDs. If a user does not exist, it is simply skipped without returning an error.
Find(ctx context.Context, userIDs []string) (users []*UserModel, err error)
// 获取某个用户信息 不存在,则返回错误
// Take retrieves a specific user's information by their ID. Returns an error if the user does not exist.
Take(ctx context.Context, userID string) (user *UserModel, err error)
// 获取用户信息 不存在,不返回错误
// Page retrieves a paginated list of users and the total count of users. If no users exist, returns an empty list without an error.
Page(ctx context.Context, pageNumber, showNumber int32) (users []*UserModel, count int64, err error)
// GetAllUserID retrieves all user IDs in a paginated manner.
GetAllUserID(ctx context.Context, pageNumber, showNumber int32) (userIDs []string, err error)
// GetUserGlobalRecvMsgOpt retrieves a user's global message receiving option.
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
// 获取用户总数
// CountTotal returns the total number of users before a specified time.
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
// 获取范围内用户增量
// CountRangeEverydayTotal calculates the daily increment of users within a specified time range.
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
}