Merge branch 'master' of https://github.com/httprunner/httprunner into refactor-python

This commit is contained in:
debugtalk
2022-03-31 23:01:36 +08:00
3 changed files with 14 additions and 14 deletions
+11 -11
View File
@@ -95,27 +95,27 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase, rendezvousList []*Rend
Name: config.Name, Name: config.Name,
Weight: config.Weight, Weight: config.Weight,
Fn: func() { Fn: func() {
sessionRunner := hrpRunner.NewSessionRunner(testcase) sessionTestCase := &TestCase{}
// copy testcase to avoid data racing
if err := copier.Copy(sessionTestCase, testcase); err != nil {
log.Error().Err(err).Msg("copy testcase data failed")
return
}
sessionRunner := hrpRunner.NewSessionRunner(sessionTestCase)
sessionRunner.parser.plugin = plugin sessionRunner.parser.plugin = plugin
testcaseSuccess := true // flag whole testcase result testcaseSuccess := true // flag whole testcase result
var transactionSuccess = true // flag current transaction result var transactionSuccess = true // flag current transaction result
cfg := testcase.Config cfg := sessionTestCase.Config
caseConfig := &TConfig{}
// copy config to avoid data racing
if err := copier.Copy(caseConfig, cfg); err != nil {
log.Error().Err(err).Msg("copy config data failed")
return
}
// iterate through all parameter iterators and update case variables // iterate through all parameter iterators and update case variables
for _, it := range caseConfig.ParametersSetting.Iterators { for _, it := range cfg.ParametersSetting.Iterators {
if it.HasNext() { if it.HasNext() {
caseConfig.Variables = mergeVariables(it.Next(), caseConfig.Variables) cfg.Variables = mergeVariables(it.Next(), cfg.Variables)
} }
} }
if err := sessionRunner.parseConfig(caseConfig); err != nil { if err := sessionRunner.parseConfig(cfg); err != nil {
log.Error().Err(err).Msg("parse config failed") log.Error().Err(err).Msg("parse config failed")
return return
} }
+1 -1
View File
@@ -177,7 +177,7 @@ type iteratorStrategyType string
const ( const (
strategyRandom iteratorStrategyType = "random" strategyRandom iteratorStrategyType = "random"
strategySequential iteratorStrategyType = "Sequential" strategySequential iteratorStrategyType = "sequential"
) )
type iteratorParamsType []map[string]interface{} type iteratorParamsType []map[string]interface{}
+2 -2
View File
@@ -652,7 +652,7 @@ func initParameterIterator(cfg *TConfig, mode string) (err error) {
// use strategy if configured // use strategy if configured
cfg.ParametersSetting.Iterators = append( cfg.ParametersSetting.Iterators = append(
cfg.ParametersSetting.Iterators, cfg.ParametersSetting.Iterators,
newIterator(v, rawValue.MapIndex(reflect.ValueOf(k)).Interface().(iteratorStrategyType), cfg.ParametersSetting.Iteration), newIterator(v, iteratorStrategyType(rawValue.MapIndex(reflect.ValueOf(k)).String()), cfg.ParametersSetting.Iteration),
) )
} else { } else {
// use sequential strategy by default // use sequential strategy by default
@@ -667,7 +667,7 @@ func initParameterIterator(cfg *TConfig, mode string) (err error) {
if len(rawValue.String()) == 0 { if len(rawValue.String()) == 0 {
cfg.ParametersSetting.Strategy = strategySequential cfg.ParametersSetting.Strategy = strategySequential
} else { } else {
cfg.ParametersSetting.Strategy = strings.ToLower(rawValue.String()) cfg.ParametersSetting.Strategy = iteratorStrategyType(strings.ToLower(rawValue.String()))
} }
cfg.ParametersSetting.Iterators = append( cfg.ParametersSetting.Iterators = append(
cfg.ParametersSetting.Iterators, cfg.ParametersSetting.Iterators,