gui任务测试报告输出
This commit is contained in:
parent
a36b7e5767
commit
aef6e046f0
@ -1,13 +1,18 @@
|
|||||||
package formview
|
package formview
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/cmd/v2/lib/common"
|
"go_dreamfactory/cmd/v2/lib/common"
|
||||||
pb2 "go_dreamfactory/cmd/v2/lib/pb"
|
pb2 "go_dreamfactory/cmd/v2/lib/pb"
|
||||||
"go_dreamfactory/cmd/v2/model"
|
"go_dreamfactory/cmd/v2/model"
|
||||||
"go_dreamfactory/cmd/v2/service"
|
"go_dreamfactory/cmd/v2/service"
|
||||||
|
"go_dreamfactory/cmd/v2/service/observer"
|
||||||
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -25,6 +30,7 @@ type RtaskTestView struct {
|
|||||||
BaseformView
|
BaseformView
|
||||||
itemList *common.ItemList
|
itemList *common.ItemList
|
||||||
result chan int
|
result chan int
|
||||||
|
flag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||||
@ -34,10 +40,6 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
|
|
||||||
this.result = make(chan int)
|
this.result = make(chan int)
|
||||||
|
|
||||||
go func() {
|
|
||||||
|
|
||||||
}()
|
|
||||||
|
|
||||||
rtaskTypeInput := widget.NewEntry()
|
rtaskTypeInput := widget.NewEntry()
|
||||||
|
|
||||||
paramsInput := widget.NewEntry()
|
paramsInput := widget.NewEntry()
|
||||||
@ -84,7 +86,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
|
|
||||||
autoTestForm := widget.NewForm(
|
autoTestForm := widget.NewForm(
|
||||||
widget.NewFormItem("Json配置", jsonPathEntry),
|
widget.NewFormItem("Json配置", jsonPathEntry),
|
||||||
widget.NewFormItem("报告目录", reportEntry),
|
widget.NewFormItem("报告保存", reportEntry),
|
||||||
)
|
)
|
||||||
|
|
||||||
autoTestForm.OnSubmit = func() {
|
autoTestForm.OnSubmit = func() {
|
||||||
@ -92,6 +94,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
Path: jsonPathEntry.Text,
|
Path: jsonPathEntry.Text,
|
||||||
}
|
}
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
var msgs []string
|
||||||
if tb, err := cfg.NewTables(commCfg.Loader); err == nil {
|
if tb, err := cfg.NewTables(commCfg.Loader); err == nil {
|
||||||
for _, v := range tb.RdtaskCondi.GetDataList() {
|
for _, v := range tb.RdtaskCondi.GetDataList() {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -116,11 +119,28 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.Debugf("执行任务 id:%v rtype:%v params:%v", condId, rtype, p)
|
logrus.Debugf("执行任务 id:%v rtype:%v params:%v", condId, rtype, p)
|
||||||
|
msgs = append(msgs, fmt.Sprintf("condId:%v rtype:%v params:%v", condId, rtype, p))
|
||||||
}(v.Id, v.Type, p)
|
}(v.Id, v.Type, p)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
// time.Sleep(time.Millisecond * 100)
|
// time.Sleep(time.Millisecond * 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record := strings.Join(msgs, "\n")
|
||||||
|
var buf bytes.Buffer
|
||||||
|
buf.WriteString(fmt.Sprintf("---任务参数测试报告---\n"))
|
||||||
|
buf.WriteString(record)
|
||||||
|
buf.WriteString("\n-------")
|
||||||
|
|
||||||
|
file, err := os.OpenFile(filepath.Join(reportEntry.Text, "report.log"), os.O_TRUNC|os.O_CREATE, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
if _, err := file.WriteString(buf.String()); err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
autoTestBtn := widget.NewButton("自动触发配置", func() {
|
autoTestBtn := widget.NewButton("自动触发配置", func() {
|
||||||
@ -145,6 +165,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.rtestListener()
|
||||||
c := container.NewBorder(
|
c := container.NewBorder(
|
||||||
container.NewHBox(testBtn, autoTestBtn, autoBtn), nil, nil, nil, this.itemList.ItemList)
|
container.NewHBox(testBtn, autoTestBtn, autoBtn), nil, nil, nil, this.itemList.ItemList)
|
||||||
|
|
||||||
@ -163,3 +184,29 @@ func (this *RtaskTestView) loadProtocol() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *RtaskTestView) rtestListener() {
|
||||||
|
if this.flag {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
|
||||||
|
OnNotify: func(d interface{}, args ...interface{}) {
|
||||||
|
data := d.(*pb.UserMessage)
|
||||||
|
if data.MainType == string(comm.ModuleRtask) &&
|
||||||
|
data.SubType == "rtest" {
|
||||||
|
rsp := &pb.RtaskTestResp{}
|
||||||
|
|
||||||
|
if !comm.ProtoUnmarshal(data, rsp) {
|
||||||
|
logrus.Error("unmarshal err")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !rsp.Flag {
|
||||||
|
logrus.Debug(fmt.Sprintf("%v", rsp.Flag))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
this.flag = true
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user