feat: support think time for load testing #120

This commit is contained in:
xucong053
2022-03-22 00:40:55 +08:00
parent 2bb50d846f
commit 521fc4cc17
11 changed files with 380 additions and 3 deletions

33
step.go
View File

@@ -40,6 +40,12 @@ func (c *TConfig) WithParameters(parameters map[string]interface{}) *TConfig {
return c
}
// SetThinkTime sets think time config for current testcase.
func (c *TConfig) SetThinkTime(strategy string, cfg interface{}, limit float64) *TConfig {
c.ThinkTime = &ThinkTimeConfig{strategy, cfg, limit}
return c
}
// ExportVars specifies variable names to export for current testcase.
func (c *TConfig) ExportVars(vars ...string) *TConfig {
c.Export = vars
@@ -193,6 +199,16 @@ func (s *StepRequest) EndTransaction(name string) *StepTransaction {
}
}
// SetThinkTime sets think time.
func (s *StepRequest) SetThinkTime(time float64) *StepThinkTime {
s.step.ThinkTime = &ThinkTime{
Time: time,
}
return &StepThinkTime{
step: s.step,
}
}
// StepRequestWithOptionalArgs implements IStep interface.
type StepRequestWithOptionalArgs struct {
step *TStep
@@ -355,6 +371,23 @@ func (s *StepTestCaseWithOptionalArgs) ToStruct() *TStep {
return s.step
}
// StepThinkTime implements IStep interface.
type StepThinkTime struct {
step *TStep
}
func (s *StepThinkTime) Name() string {
return s.step.Name
}
func (s *StepThinkTime) Type() string {
return "thinktime"
}
func (s *StepThinkTime) ToStruct() *TStep {
return s.step
}
// StepTransaction implements IStep interface.
type StepTransaction struct {
step *TStep