diff --git a/convert.go b/convert.go index 94e2bc40..22ca17ec 100644 --- a/convert.go +++ b/convert.go @@ -120,6 +120,10 @@ func (tc *TCase) ToTestCase() (*TestCase, error) { testCase.TestSteps = append(testCase.TestSteps, &stepTransaction{ step: step, }) + } else if step.Rendezvous != nil { + testCase.TestSteps = append(testCase.TestSteps, &stepRendezvous{ + step: step, + }) } else { log.Warn().Interface("step", step).Msg("[convertTestCase] unexpected step") } diff --git a/models.go b/models.go index 85b284e9..94ccd45c 100644 --- a/models.go +++ b/models.go @@ -51,6 +51,7 @@ type TStep struct { Request *Request `json:"request,omitempty" yaml:"request,omitempty"` TestCase *TestCase `json:"testcase,omitempty" yaml:"testcase,omitempty"` Transaction *Transaction `json:"transaction,omitempty" yaml:"transaction,omitempty"` + Rendezvous *Rendezvous `json:"rendezvous,omitempty" yaml:"rendezvous,omitempty"` Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"` SetupHooks []string `json:"setup_hooks,omitempty" yaml:"setup_hooks,omitempty"` TeardownHooks []string `json:"teardown_hooks,omitempty" yaml:"teardown_hooks,omitempty"` @@ -63,6 +64,12 @@ type Transaction struct { Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` // start/end } +type Rendezvous struct { + Name string `json:"name" yaml:"name"` // required + Percent float32 `json:"percent,omitempty" yaml:"percent,omitempty"` // default to 1(100%) + Number int64 `json:"number,omitempty" yaml:"number,omitempty"` + Timeout int64 `json:"timeout,omitempty" yaml:"timeout,omitempty"` // milliseconds +} // TCase represents testcase data structure. // Each testcase includes one public config and several sequential teststeps. diff --git a/runner.go b/runner.go index 9f524bfb..5dc91051 100644 --- a/runner.go +++ b/runner.go @@ -118,14 +118,23 @@ func (r *hrpRunner) runCase(testcase *TestCase) error { } func (r *hrpRunner) runStep(step IStep, config *TConfig) (stepResult *stepData, err error) { - // step type priority order: transaction > testcase > request - if stepTransaction, ok := step.(*stepTransaction); ok { + // step type priority order: transaction > rendezvous > testcase > request + if stepTran, ok := step.(*stepTransaction); ok { // transaction log.Info(). - Str("name", stepTransaction.step.Transaction.Name). - Str("type", stepTransaction.step.Transaction.Type). + Str("name", stepTran.step.Transaction.Name). + Str("type", stepTran.step.Transaction.Type). Msg("transaction") return nil, nil + } else if stepRend, ok := step.(*stepRendezvous); ok { + // rendezvous + log.Info(). + Str("name", stepRend.step.Rendezvous.Name). + Float32("percent", stepRend.step.Rendezvous.Percent). + Int64("number", stepRend.step.Rendezvous.Number). + Int64("timeout", stepRend.step.Rendezvous.Timeout). + Msg("rendezvous") + return nil, nil } log.Info().Str("step", step.Name()).Msg("run step start") diff --git a/step.go b/step.go index 1f7a22c1..a2804053 100644 --- a/step.go +++ b/step.go @@ -297,3 +297,23 @@ func (s *stepTransaction) Type() string { func (s *stepTransaction) ToStruct() *TStep { return s.step } + +// implements IStep interface +type stepRendezvous struct { + step *TStep +} + +func (s *stepRendezvous) Name() string { + if s.step.Name != "" { + return s.step.Name + } + return s.step.Rendezvous.Name +} + +func (s *stepRendezvous) Type() string { + return "rendezvous" +} + +func (s *stepRendezvous) ToStruct() *TStep { + return s.step +}