|
@@ -225,7 +225,8 @@ func (mt *MQLTest) RunMQLTryDo(t *testing.T, ctx context.Context,
|
|
|
tn = fmt.Sprint(tn, "(retry ", retry_count, ")")
|
|
tn = fmt.Sprint(tn, "(retry ", retry_count, ")")
|
|
|
}
|
|
}
|
|
|
var seriouserror bool
|
|
var seriouserror bool
|
|
|
- seriouserror, err = mt.RunMQLTryOnce(t, ctx,
|
|
|
|
|
|
|
+ report := retry_count >= retry_limit
|
|
|
|
|
+ seriouserror, err = mt.RunMQLTryOnce(t, report, ctx,
|
|
|
global,
|
|
global,
|
|
|
topvars,
|
|
topvars,
|
|
|
dirvars,
|
|
dirvars,
|
|
@@ -243,7 +244,7 @@ func (mt *MQLTest) RunMQLTryDo(t *testing.T, ctx context.Context,
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (mt *MQLTest) RunMQLTryOnce(t *testing.T, ctx context.Context,
|
|
|
|
|
|
|
+func (mt *MQLTest) RunMQLTryOnce(t *testing.T, report bool, ctx context.Context,
|
|
|
global *GlobalVars,
|
|
global *GlobalVars,
|
|
|
topvars *CurrentVars,
|
|
topvars *CurrentVars,
|
|
|
dirvars *CurrentVars,
|
|
dirvars *CurrentVars,
|
|
@@ -272,7 +273,7 @@ func (mt *MQLTest) RunMQLTryOnce(t *testing.T, ctx context.Context,
|
|
|
mqlstr = strings.TrimSpace(mqlstr)
|
|
mqlstr = strings.TrimSpace(mqlstr)
|
|
|
if mqlstr == "" {
|
|
if mqlstr == "" {
|
|
|
rtn := &odb.Result{}
|
|
rtn := &odb.Result{}
|
|
|
- seriouserror, err = mt.doFollowThroughActions(t, testname, toption, rtn, actionexprs.FollowThroughActions(), mqri.PreparedQueryString)
|
|
|
|
|
|
|
+ seriouserror, err = mt.doFollowThroughActions(t, report, testname, toption, rtn, actionexprs.FollowThroughActions(), mqri.PreparedQueryString)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logger.Info(fmt.Sprint("mql ", testname, " done, empty mql ignore usetime"))
|
|
logger.Info(fmt.Sprint("mql ", testname, " done, empty mql ignore usetime"))
|
|
|
return
|
|
return
|
|
@@ -286,8 +287,9 @@ func (mt *MQLTest) RunMQLTryOnce(t *testing.T, ctx context.Context,
|
|
|
if toption.regex[OnErrorPass] != nil {
|
|
if toption.regex[OnErrorPass] != nil {
|
|
|
if e == nil {
|
|
if e == nil {
|
|
|
e = merrs.NewError(fmt.Sprint("expect error ", toption.regex[OnErrorPass].String(), ", but no error occurs"))
|
|
e = merrs.NewError(fmt.Sprint("expect error ", toption.regex[OnErrorPass].String(), ", but no error occurs"))
|
|
|
- assert.Nil(t, "error", e)
|
|
|
|
|
- // 不直接输出错误信息,返回错误信息,中断循环, 在 testing.T 中报告错误,中断测试
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Nil(t, "error", e)
|
|
|
|
|
+ }
|
|
|
return false, e
|
|
return false, e
|
|
|
}
|
|
}
|
|
|
if toption.regex[OnErrorPass].MatchString(e.Error()) {
|
|
if toption.regex[OnErrorPass].MatchString(e.Error()) {
|
|
@@ -312,11 +314,10 @@ func (mt *MQLTest) RunMQLTryOnce(t *testing.T, ctx context.Context,
|
|
|
}
|
|
}
|
|
|
return false, nil
|
|
return false, nil
|
|
|
}
|
|
}
|
|
|
- if !assert.Nil(t, "error", e) {
|
|
|
|
|
- // 不直接输出错误信息,返回错误信息,中断循环, 在 testing.T 中报告错误,中断测试
|
|
|
|
|
- return false, e
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Nil(t, "error", e)
|
|
|
}
|
|
}
|
|
|
- return false, nil
|
|
|
|
|
|
|
+ return false, e
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
mt.scopevars.Lock()
|
|
mt.scopevars.Lock()
|
|
@@ -357,7 +358,7 @@ func (mt *MQLTest) RunMQLTryOnce(t *testing.T, ctx context.Context,
|
|
|
}
|
|
}
|
|
|
mt.scopevars.Unlock()
|
|
mt.scopevars.Unlock()
|
|
|
|
|
|
|
|
- seriouserror, err = mt.doFollowThroughActions(t, testname, toption, rtn, actionexprs.FollowThroughActions(), mqlstr)
|
|
|
|
|
|
|
+ seriouserror, err = mt.doFollowThroughActions(t, report, testname, toption, rtn, actionexprs.FollowThroughActions(), mqlstr)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
logger.Info(fmt.Sprint("mql ", testname, " done, usetime=", ut))
|
|
logger.Info(fmt.Sprint("mql ", testname, " done, usetime=", ut))
|
|
|
return
|
|
return
|
|
@@ -366,7 +367,7 @@ func (mt *MQLTest) RunMQLTryOnce(t *testing.T, ctx context.Context,
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption *OnErrorOption, rtn *odb.Result, actions []*Action, mql string) (seriouserror bool, err error) {
|
|
|
|
|
|
|
+func (mt *MQLTest) doFollowThroughActions(t *testing.T, report bool, testname string, toption *OnErrorOption, rtn *odb.Result, actions []*Action, mql string) (seriouserror bool, err error) {
|
|
|
if len(actions) > 0 {
|
|
if len(actions) > 0 {
|
|
|
if rtn == nil {
|
|
if rtn == nil {
|
|
|
s := "返回值为空"
|
|
s := "返回值为空"
|
|
@@ -385,9 +386,10 @@ func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption
|
|
|
err = nil
|
|
err = nil
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if !assert.NotNil(t, rtn, err) {
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.NotNil(t, rtn, err)
|
|
|
}
|
|
}
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
for _, act := range actions {
|
|
for _, act := range actions {
|
|
|
breakup := false
|
|
breakup := false
|
|
@@ -421,9 +423,10 @@ func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption
|
|
|
err = nil
|
|
err = nil
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if !assert.Nil(t, s, err) {
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Nil(t, s, err)
|
|
|
}
|
|
}
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
case "metainfo":
|
|
case "metainfo":
|
|
|
bs, e := json.MarshalIndent(rtn.Meta, "", " ")
|
|
bs, e := json.MarshalIndent(rtn.Meta, "", " ")
|
|
@@ -443,10 +446,10 @@ func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption
|
|
|
err = nil
|
|
err = nil
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if !assert.Nil(t, "error", err) {
|
|
|
|
|
- // 不直接输出错误信息,返回错误信息,中断循环, 在 testing.T 中报告错误,中断测试
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Nil(t, "error", err)
|
|
|
}
|
|
}
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
logger.Info(fmt.Sprint("mql ", testname, " meta info:\n", string(bs)))
|
|
logger.Info(fmt.Sprint("mql ", testname, " meta info:\n", string(bs)))
|
|
|
case "output":
|
|
case "output":
|
|
@@ -467,10 +470,10 @@ func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption
|
|
|
err = nil
|
|
err = nil
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if !assert.Nil(t, "error", err) {
|
|
|
|
|
- // 不直接输出错误信息,返回错误信息,中断循环, 在 testing.T 中报告错误,中断测试
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Nil(t, "error", err)
|
|
|
}
|
|
}
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
total := ""
|
|
total := ""
|
|
|
if len(rtn.Data) > 0 {
|
|
if len(rtn.Data) > 0 {
|
|
@@ -506,13 +509,13 @@ func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption
|
|
|
err = nil
|
|
err = nil
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if !assert.Equal(t, n, len(rtn.Data), err) {
|
|
|
|
|
- // 不直接输出错误信息,返回错误信息,中断循环, 在 testing.T 中报告错误,中断测试
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Equal(t, n, len(rtn.Data), err)
|
|
|
}
|
|
}
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
case "match":
|
|
case "match":
|
|
|
- breakup, seriouserror, err = DoActionMatch(t, args, mql, rtn, toption)
|
|
|
|
|
|
|
+ breakup, seriouserror, err = DoActionMatch(t, report, args, mql, rtn, toption)
|
|
|
if breakup {
|
|
if breakup {
|
|
|
return seriouserror, err
|
|
return seriouserror, err
|
|
|
}
|
|
}
|
|
@@ -595,14 +598,15 @@ func (mt *MQLTest) doFollowThroughActions(t *testing.T, testname string, toption
|
|
|
err = nil
|
|
err = nil
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if !assert.Equal(t, n, x, err) {
|
|
|
|
|
- // 不直接输出错误信息,返回错误信息,中断循环, 在 testing.T 中报告错误,中断测试
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if report {
|
|
|
|
|
+ assert.Equal(t, n, x, err)
|
|
|
}
|
|
}
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
case "equal":
|
|
case "equal":
|
|
|
breakup, seriouserror, err := DoActionEqual(
|
|
breakup, seriouserror, err := DoActionEqual(
|
|
|
t,
|
|
t,
|
|
|
|
|
+ report,
|
|
|
toption,
|
|
toption,
|
|
|
rtn,
|
|
rtn,
|
|
|
cast.ToStringSlice(args)...)
|
|
cast.ToStringSlice(args)...)
|