修改测试报告
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 {
|
||||
account := robot.Get("account").(string)
|
||||
user, ok := robot.Get("user.login").(*pb.UserLoginResp)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
req := &pb.UserCreateReq{
|
||||
NickName: account,
|
||||
NickName: user.Data.Uid,
|
||||
}
|
||||
rsp := &pb.UserCreateResp{}
|
||||
|
||||
|
@ -27,6 +27,7 @@ func (f *HeroScene) Run(robot lib.IRobot) error {
|
||||
f.AddHero(robot, "25001") // 加阿宝
|
||||
f.AddHero(robot, "44911") // 升级精灵
|
||||
f.AddHero(robot, "45921") // 技能精灵
|
||||
f.AddHero(robot, "45921") // 技能精灵
|
||||
// f.AddAttrGold(robot) // 加金币
|
||||
// f.AddAttrDiamond(robot) // 加钻石
|
||||
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/gorilla/websocket v1.5.0
|
||||
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/spf13/cast v1.3.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 {
|
||||
scene, err := m.sceneQueue.Pop()
|
||||
if err != nil {
|
||||
logrus.WithField("err", err).Error("所有场景执行结束")
|
||||
// m.prepareToStop()
|
||||
logrus.WithField("err", err).Warn("所有场景执行结束")
|
||||
m.prepareToStop()
|
||||
return
|
||||
}
|
||||
|
||||
@ -215,24 +215,27 @@ func (m *Robot) prepareToStop() {
|
||||
|
||||
func (m *Robot) SendResult(result *CallResult) bool {
|
||||
if atomic.LoadUint32(&m.status) != STATUS_STARTED {
|
||||
m.printIgnoredResult(result, "stopped load generator")
|
||||
m.printIgnoredResult(result, "停止发送")
|
||||
return false
|
||||
}
|
||||
select {
|
||||
case m.resultCh <- result:
|
||||
fmt.Printf("准备发送结果: %v\n", result)
|
||||
logrus.WithField("res", result).Debug("发送结果")
|
||||
return true
|
||||
default:
|
||||
m.printIgnoredResult(result, "full result channel")
|
||||
m.printIgnoredResult(result, "通道满了")
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Robot) ShowResult() {
|
||||
go func() {
|
||||
logrus.Debug("开始生成测试报告")
|
||||
defer logrus.Debug("测试报告生成完成")
|
||||
routes := make(map[string]*Statistics)
|
||||
for r := range m.resultCh {
|
||||
head := fmt.Sprintf("%s.%s", r.MainType, r.SubType)
|
||||
logrus.WithField("head", head).Debug("读结果")
|
||||
if len(routes) == 0 {
|
||||
statis := &Statistics{
|
||||
Route: head,
|
||||
@ -290,11 +293,11 @@ func (m *Robot) ShowResult() {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("测试报告\n")
|
||||
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("测试报告")
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
func (m *Robot) printIgnoredResult(result *CallResult, cause string) {
|
||||
|
Loading…
Reference in New Issue
Block a user