mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 11:36:56 +08:00
fix: avoid data racing.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package hrp
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/copier"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -69,12 +70,17 @@ func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
||||
var transactionSuccess = true // flag current transaction result
|
||||
|
||||
cfg := testcase.Config.ToStruct()
|
||||
testCaseVariables := &TConfig{}
|
||||
// copy config to avoid data racing
|
||||
if err := copier.Copy(testCaseVariables, cfg); err != nil {
|
||||
log.Error().Err(err).Msg("copy config data failed")
|
||||
}
|
||||
if it := cfg.ParametersSetting.Iterator; it.HasNext() {
|
||||
cfg.Variables = mergeVariables(it.Next(), cfg.Variables)
|
||||
testCaseVariables.Variables = mergeVariables(it.Next(), cfg.Variables)
|
||||
}
|
||||
startTime := time.Now()
|
||||
for index, step := range testcase.TestSteps {
|
||||
stepData, err := runner.runStep(index)
|
||||
stepData, err := runner.runStep(index, testCaseVariables)
|
||||
if err != nil {
|
||||
// step failed
|
||||
var elapsed int64
|
||||
|
||||
Reference in New Issue
Block a user