From a813f966d7c2f00f48a721b566e4aa68e60d0ba3 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Tue, 19 Nov 2024 21:00:09 +0800 Subject: [PATCH] change: remove unused session data in step result --- hrp/internal/version/VERSION | 2 +- hrp/step.go | 24 ++++++++++++------------ hrp/step_mobile_ui.go | 9 ++++++--- hrp/step_request.go | 4 +++- hrp/step_websocket.go | 4 +++- hrp/summary.go | 6 ------ 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 77dd966b..edfe54d0 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411192052 +v5.0.0+2411192100 diff --git a/hrp/step.go b/hrp/step.go index dbb7c623..8ea46ac8 100644 --- a/hrp/step.go +++ b/hrp/step.go @@ -59,18 +59,18 @@ type ActionResult struct { // one testcase contains one or multiple steps type StepResult struct { - Name string `json:"name" yaml:"name"` // step name - Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` // step identifier - StartTime int64 `json:"start_time" yaml:"time"` // step start time - StepType StepType `json:"step_type" yaml:"step_type"` // step type, testcase/request/transaction/rendezvous - Success bool `json:"success" yaml:"success"` // step execution result - Elapsed int64 `json:"elapsed_ms" yaml:"elapsed_ms"` // step execution time in millisecond(ms) - HttpStat map[string]int64 `json:"httpstat,omitempty" yaml:"httpstat,omitempty"` // httpstat in millisecond(ms) - Data interface{} `json:"data,omitempty" yaml:"data,omitempty"` // step data - ContentSize int64 `json:"content_size" yaml:"content_size"` // response body length - ExportVars map[string]interface{} `json:"export_vars,omitempty" yaml:"export_vars,omitempty"` // extract variables - Actions []*ActionResult `json:"actions,omitempty" yaml:"actions,omitempty"` // store action execution info - Attachments interface{} `json:"attachments,omitempty" yaml:"attachments,omitempty"` // store extra step information, such as error message or screenshots + Name string `json:"name" yaml:"name"` // step name + Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` // step identifier + StartTime int64 `json:"start_time" yaml:"time"` // step start time + StepType StepType `json:"step_type" yaml:"step_type"` // step type, testcase/request/transaction/rendezvous + Success bool `json:"success" yaml:"success"` // step execution result + Elapsed int64 `json:"elapsed_ms" yaml:"elapsed_ms"` // step execution time in millisecond(ms) + HttpStat map[string]int64 `json:"httpstat,omitempty" yaml:"httpstat,omitempty"` // httpstat in millisecond(ms) + Data interface{} `json:"data,omitempty" yaml:"data,omitempty"` // step data + ContentSize int64 `json:"content_size,omitempty" yaml:"content_size,omitempty"` // response body length + ExportVars map[string]interface{} `json:"export_vars,omitempty" yaml:"export_vars,omitempty"` // extract variables + Actions []*ActionResult `json:"actions,omitempty" yaml:"actions,omitempty"` // store action execution info + Attachments interface{} `json:"attachments,omitempty" yaml:"attachments,omitempty"` // store extra step information, such as error message or screenshots } // IStep represents interface for all types for teststeps, includes: diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index ba81b1f3..07e27187 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -753,9 +753,12 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err } return } - sessionData := newSessionData() - sessionData.Validators = validateResults - stepResult.Data = sessionData + if len(validateResults) > 0 { + sessionData := &SessionData{ + Validators: validateResults, + } + stepResult.Data = sessionData + } stepResult.Success = true return stepResult, nil } diff --git a/hrp/step_request.go b/hrp/step_request.go index 15c731f4..4d0837ac 100644 --- a/hrp/step_request.go +++ b/hrp/step_request.go @@ -301,7 +301,9 @@ func runStepRequest(r *SessionRunner, step IStep) (stepResult *StepResult, err e return } - sessionData := newSessionData() + sessionData := &SessionData{ + ReqResps: &ReqResps{}, + } parser := r.caseRunner.parser config := r.caseRunner.Config.Get() diff --git a/hrp/step_websocket.go b/hrp/step_websocket.go index 7e0ee075..999a69b0 100644 --- a/hrp/step_websocket.go +++ b/hrp/step_websocket.go @@ -290,7 +290,9 @@ func runStepWebSocket(r *SessionRunner, step IStep) (stepResult *StepResult, err stepResult.Elapsed = time.Since(start).Milliseconds() }() - sessionData := newSessionData() + sessionData := &SessionData{ + ReqResps: &ReqResps{}, + } parser := r.caseRunner.parser config := r.caseRunner.Config.Get() diff --git a/hrp/summary.go b/hrp/summary.go index 22182c05..4ec92108 100644 --- a/hrp/summary.go +++ b/hrp/summary.go @@ -227,12 +227,6 @@ type TestCaseInOut struct { ExportVars map[string]interface{} `json:"export_vars" yaml:"export_vars"` } -func newSessionData() *SessionData { - return &SessionData{ - ReqResps: &ReqResps{}, - } -} - type SessionData struct { ReqResps *ReqResps `json:"req_resps" yaml:"req_resps"` Address *Address `json:"address,omitempty" yaml:"address,omitempty"` // TODO