优化测试请求2
This commit is contained in:
parent
875285034f
commit
4c18c50d3d
@ -91,7 +91,7 @@ var (
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
}
|
}
|
||||||
tcs = append(tcs, tc)
|
tcs = append(tcs, tc)
|
||||||
robot.addTestCaseAndReq(tcs)
|
robot.addBuilders(tcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -45,7 +45,7 @@ var (
|
|||||||
}
|
}
|
||||||
tcs = append(tcs, tc)
|
tcs = append(tcs, tc)
|
||||||
}
|
}
|
||||||
robot.addTestCaseAndReq(tcs)
|
robot.addBuilders(tcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -61,10 +61,10 @@ func (r *Robot) AccountLogin() {
|
|||||||
NickName: nick,
|
NickName: nick,
|
||||||
},
|
},
|
||||||
rsp: &pb.UserCreateResp{},
|
rsp: &pb.UserCreateResp{},
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
}
|
}
|
||||||
tcs = append(tcs, tc)
|
tcs = append(tcs, tc)
|
||||||
r.addTestCaseAndReq(tcs)
|
r.addBuilders(tcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -25,7 +25,7 @@ type Robot struct {
|
|||||||
builderMap map[string]*TestCase
|
builderMap map[string]*TestCase
|
||||||
// linkCase *LinkCase
|
// linkCase *LinkCase
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
reqCh chan string //请求通道uuid
|
// reqCh chan string //请求通道uuid
|
||||||
// rspCh chan string //响应通道uuid
|
// rspCh chan string //响应通道uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ func NewRobot(opts *Options) *Robot {
|
|||||||
ws: ws,
|
ws: ws,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
builderMap: make(map[string]*TestCase),
|
builderMap: make(map[string]*TestCase),
|
||||||
reqCh: make(chan string, 1),
|
// reqCh: make(chan string, 1),
|
||||||
// rspCh: make(chan string, 10),
|
// rspCh: make(chan string, 10),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ func (r *Robot) handleReq() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
b.requested = true
|
b.requested = true
|
||||||
r.reqCh <- b.id
|
// r.reqCh <- b.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,18 +133,39 @@ func (r *Robot) addTestCaseAndReq(tcs []*TestCase) {
|
|||||||
r.handleReq()
|
r.handleReq()
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理响应
|
//错误通知处理
|
||||||
func (r *Robot) handleRsp(msg *pb.UserMessage) {
|
func (r *Robot) handleNotify(msg *pb.UserMessage) {
|
||||||
uuid := <-r.reqCh
|
if msg.MainType == "notify" && msg.SubType == "errornotify" {
|
||||||
if uuid == "" {
|
rsp := &pb.NotifyErrorNotifyPush{}
|
||||||
log.Printf("[%v.%v] uuid is empty", msg.MainType, msg.SubType)
|
if !comm.ProtoUnmarshal(msg, rsp) {
|
||||||
return
|
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 &&
|
if v.enabled &&
|
||||||
(msg.MainType == v.mainType &&
|
(msg.MainType == v.mainType &&
|
||||||
msg.SubType == v.subType) &&
|
msg.SubType == v.subType) &&
|
||||||
v.requested {
|
v.requested {
|
||||||
|
|
||||||
if !comm.ProtoUnmarshal(msg, v.rsp) {
|
if !comm.ProtoUnmarshal(msg, v.rsp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -183,6 +204,7 @@ func (r *Robot) loginCallback(rsp proto.Message) {
|
|||||||
if lr.Data != nil {
|
if lr.Data != nil {
|
||||||
r.user = lr.Data
|
r.user = lr.Data
|
||||||
r.onUserLoaded()
|
r.onUserLoaded()
|
||||||
|
r.handleReq()
|
||||||
} else {
|
} else {
|
||||||
//请求Http接口,模拟创建新账号
|
//请求Http接口,模拟创建新账号
|
||||||
r.AccountRegister(r.opts.Account, int32(r.opts.ServerId))
|
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() {
|
func (r *Robot) onUserLoaded() {
|
||||||
//notify
|
|
||||||
r.RunNotify()
|
|
||||||
//user
|
//user
|
||||||
r.RunUser()
|
r.RunUser()
|
||||||
//hero
|
//hero
|
||||||
|
@ -33,7 +33,7 @@ var (
|
|||||||
StoryId: 1,
|
StoryId: 1,
|
||||||
},
|
},
|
||||||
rsp: &pb.StoryChallengeResp{},
|
rsp: &pb.StoryChallengeResp{},
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user