优化测试请求2
This commit is contained in:
parent
875285034f
commit
4c18c50d3d
@ -91,7 +91,7 @@ var (
|
||||
enabled: true,
|
||||
}
|
||||
tcs = append(tcs, tc)
|
||||
robot.addTestCaseAndReq(tcs)
|
||||
robot.addBuilders(tcs)
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -45,7 +45,7 @@ var (
|
||||
}
|
||||
tcs = append(tcs, tc)
|
||||
}
|
||||
robot.addTestCaseAndReq(tcs)
|
||||
robot.addBuilders(tcs)
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -61,10 +61,10 @@ func (r *Robot) AccountLogin() {
|
||||
NickName: nick,
|
||||
},
|
||||
rsp: &pb.UserCreateResp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
}
|
||||
tcs = append(tcs, tc)
|
||||
r.addTestCaseAndReq(tcs)
|
||||
r.addBuilders(tcs)
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ type Robot struct {
|
||||
builderMap map[string]*TestCase
|
||||
// linkCase *LinkCase
|
||||
wg sync.WaitGroup
|
||||
reqCh chan string //请求通道uuid
|
||||
// reqCh chan string //请求通道uuid
|
||||
// rspCh chan string //响应通道uuid
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ func NewRobot(opts *Options) *Robot {
|
||||
ws: ws,
|
||||
opts: opts,
|
||||
builderMap: make(map[string]*TestCase),
|
||||
reqCh: make(chan string, 1),
|
||||
// reqCh: make(chan string, 1),
|
||||
// rspCh: make(chan string, 10),
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ func (r *Robot) handleReq() {
|
||||
continue
|
||||
}
|
||||
b.requested = true
|
||||
r.reqCh <- b.id
|
||||
// r.reqCh <- b.id
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,18 +133,39 @@ func (r *Robot) addTestCaseAndReq(tcs []*TestCase) {
|
||||
r.handleReq()
|
||||
}
|
||||
|
||||
//处理响应
|
||||
func (r *Robot) handleRsp(msg *pb.UserMessage) {
|
||||
uuid := <-r.reqCh
|
||||
if uuid == "" {
|
||||
log.Printf("[%v.%v] uuid is empty", msg.MainType, msg.SubType)
|
||||
//错误通知处理
|
||||
func (r *Robot) handleNotify(msg *pb.UserMessage) {
|
||||
if msg.MainType == "notify" && msg.SubType == "errornotify" {
|
||||
rsp := &pb.NotifyErrorNotifyPush{}
|
||||
if !comm.ProtoUnmarshal(msg, rsp) {
|
||||
return
|
||||
}
|
||||
if v, ok := r.builderMap[uuid]; ok {
|
||||
printReply(msg, &TestCase{
|
||||
desc: "错误通知",
|
||||
mainType: comm.MainTypeNotify,
|
||||
subType: comm.SubTypeErrorNotify,
|
||||
rsp: rsp,
|
||||
enabled: true,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//处理响应
|
||||
func (r *Robot) handleRsp(msg *pb.UserMessage) {
|
||||
r.handleNotify(msg)
|
||||
// uuid := <-r.reqCh
|
||||
// if uuid == "" {
|
||||
// log.Printf("[%v.%v] uuid is empty", msg.MainType, msg.SubType)
|
||||
// return
|
||||
// }
|
||||
// if v, ok := r.builderMap[uuid]; ok {
|
||||
for _, v := range r.builderMap {
|
||||
if v.enabled &&
|
||||
(msg.MainType == v.mainType &&
|
||||
msg.SubType == v.subType) &&
|
||||
v.requested {
|
||||
|
||||
if !comm.ProtoUnmarshal(msg, v.rsp) {
|
||||
return
|
||||
}
|
||||
@ -183,6 +204,7 @@ func (r *Robot) loginCallback(rsp proto.Message) {
|
||||
if lr.Data != nil {
|
||||
r.user = lr.Data
|
||||
r.onUserLoaded()
|
||||
r.handleReq()
|
||||
} else {
|
||||
//请求Http接口,模拟创建新账号
|
||||
r.AccountRegister(r.opts.Account, int32(r.opts.ServerId))
|
||||
@ -268,8 +290,6 @@ func traceFunc(module string, funcName string, uid string, funcArgs interface{})
|
||||
//在这里添加玩家成功登录以后的测试方法
|
||||
//次方法在用户登录成功后调用
|
||||
func (r *Robot) onUserLoaded() {
|
||||
//notify
|
||||
r.RunNotify()
|
||||
//user
|
||||
r.RunUser()
|
||||
//hero
|
||||
|
@ -33,7 +33,7 @@ var (
|
||||
StoryId: 1,
|
||||
},
|
||||
rsp: &pb.StoryChallengeResp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user