修改测试报告
This commit is contained in:
parent
3ae84647d1
commit
776dfc2811
@ -21,9 +21,12 @@ func (c *CreateUserScene) Info() lib.SceneInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *CreateUserScene) Run(robot lib.IRobot) error {
|
func (c *CreateUserScene) Run(robot lib.IRobot) error {
|
||||||
account := robot.Get("account").(string)
|
user, ok := robot.Get("user.login").(*pb.UserLoginResp)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
req := &pb.UserCreateReq{
|
req := &pb.UserCreateReq{
|
||||||
NickName: account,
|
NickName: user.Data.Uid,
|
||||||
}
|
}
|
||||||
rsp := &pb.UserCreateResp{}
|
rsp := &pb.UserCreateResp{}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ func (f *HeroScene) Run(robot lib.IRobot) error {
|
|||||||
f.AddHero(robot, "25001") // 加阿宝
|
f.AddHero(robot, "25001") // 加阿宝
|
||||||
f.AddHero(robot, "44911") // 升级精灵
|
f.AddHero(robot, "44911") // 升级精灵
|
||||||
f.AddHero(robot, "45921") // 技能精灵
|
f.AddHero(robot, "45921") // 技能精灵
|
||||||
|
f.AddHero(robot, "45921") // 技能精灵
|
||||||
// f.AddAttrGold(robot) // 加金币
|
// f.AddAttrGold(robot) // 加金币
|
||||||
// f.AddAttrDiamond(robot) // 加钻石
|
// f.AddAttrDiamond(robot) // 加钻石
|
||||||
time.Sleep(10 * time.Millisecond) // 等待10ms
|
time.Sleep(10 * time.Millisecond) // 等待10ms
|
||||||
|
1
go.mod
1
go.mod
@ -8,7 +8,6 @@ require (
|
|||||||
github.com/Pallinder/go-randomdata v1.2.0
|
github.com/Pallinder/go-randomdata v1.2.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/json-iterator/go v1.1.11
|
github.com/json-iterator/go v1.1.11
|
||||||
github.com/nacos-group/nacos-sdk-go v1.1.3
|
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/spf13/cast v1.3.1
|
github.com/spf13/cast v1.3.1
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.28.1
|
||||||
|
17
lib/robot.go
17
lib/robot.go
@ -185,8 +185,8 @@ func (m *Robot) syncCall() {
|
|||||||
for {
|
for {
|
||||||
scene, err := m.sceneQueue.Pop()
|
scene, err := m.sceneQueue.Pop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithField("err", err).Error("所有场景执行结束")
|
logrus.WithField("err", err).Warn("所有场景执行结束")
|
||||||
// m.prepareToStop()
|
m.prepareToStop()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,24 +215,27 @@ func (m *Robot) prepareToStop() {
|
|||||||
|
|
||||||
func (m *Robot) SendResult(result *CallResult) bool {
|
func (m *Robot) SendResult(result *CallResult) bool {
|
||||||
if atomic.LoadUint32(&m.status) != STATUS_STARTED {
|
if atomic.LoadUint32(&m.status) != STATUS_STARTED {
|
||||||
m.printIgnoredResult(result, "stopped load generator")
|
m.printIgnoredResult(result, "停止发送")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case m.resultCh <- result:
|
case m.resultCh <- result:
|
||||||
fmt.Printf("准备发送结果: %v\n", result)
|
logrus.WithField("res", result).Debug("发送结果")
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
m.printIgnoredResult(result, "full result channel")
|
m.printIgnoredResult(result, "通道满了")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Robot) ShowResult() {
|
func (m *Robot) ShowResult() {
|
||||||
go func() {
|
go func() {
|
||||||
|
logrus.Debug("开始生成测试报告")
|
||||||
|
defer logrus.Debug("测试报告生成完成")
|
||||||
routes := make(map[string]*Statistics)
|
routes := make(map[string]*Statistics)
|
||||||
for r := range m.resultCh {
|
for r := range m.resultCh {
|
||||||
head := fmt.Sprintf("%s.%s", r.MainType, r.SubType)
|
head := fmt.Sprintf("%s.%s", r.MainType, r.SubType)
|
||||||
|
logrus.WithField("head", head).Debug("读结果")
|
||||||
if len(routes) == 0 {
|
if len(routes) == 0 {
|
||||||
statis := &Statistics{
|
statis := &Statistics{
|
||||||
Route: head,
|
Route: head,
|
||||||
@ -290,11 +293,11 @@ func (m *Robot) ShowResult() {
|
|||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.WriteString("测试报告\n")
|
buf.WriteString("测试报告\n")
|
||||||
buf.WriteString(record)
|
buf.WriteString(record)
|
||||||
if err := ioutil.WriteFile(filepath.Join("./", "report.txt"), buf.Bytes(), fs.ModePerm); err != nil {
|
logrus.WithField("res", buf.String()).Debug("报告内容")
|
||||||
|
if err := ioutil.WriteFile(filepath.Join("./", "report.log"), buf.Bytes(), fs.ModePerm); err != nil {
|
||||||
logrus.WithField("err", err).Error("测试报告")
|
logrus.WithField("err", err).Error("测试报告")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Robot) printIgnoredResult(result *CallResult, cause string) {
|
func (m *Robot) printIgnoredResult(result *CallResult, cause string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user