From 6a40da46e0168ca5d5be0dfebb5888c145c2d1a4 Mon Sep 17 00:00:00 2001 From: xucong053 Date: Fri, 1 Jul 2022 11:53:27 +0800 Subject: [PATCH] fix: record all requests of testcase reference in boom mode --- examples/demo-with-py-plugin/.debugtalk_gen.py | 2 +- hrp/boomer.go | 15 ++++++++++++++- hrp/internal/boomer/stats.go | 8 ++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/examples/demo-with-py-plugin/.debugtalk_gen.py b/examples/demo-with-py-plugin/.debugtalk_gen.py index a57fef72..70910180 100644 --- a/examples/demo-with-py-plugin/.debugtalk_gen.py +++ b/examples/demo-with-py-plugin/.debugtalk_gen.py @@ -1,4 +1,4 @@ -# NOTE: Generated By hrp v4.1.4, DO NOT EDIT! +# NOTE: Generated By hrp v4.1.5, DO NOT EDIT! import sys import os diff --git a/hrp/boomer.go b/hrp/boomer.go index fddc47df..4c2bcebe 100644 --- a/hrp/boomer.go +++ b/hrp/boomer.go @@ -136,7 +136,20 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase, rendezvousList []*Rend b.Boomer.ResetStartTime() }) stepResult, err := step.Run(sessionRunner) + // update step result name with parsed step name stepResult.Name = stepName + // record requests result of the step if step type is testcase + if stepResult.StepType == stepTypeTestCase && stepResult.Data != nil { + // record requests of testcase step + for _, result := range stepResult.Data.([]*StepResult) { + if result.Success { + b.RecordSuccess(string(result.StepType), result.Name, result.Elapsed, result.ContentSize) + } else { + b.RecordFailure(string(result.StepType), result.Name, result.Elapsed, result.Attachment) + } + } + } + // record step failure if err != nil { // step failed var elapsed int64 @@ -157,7 +170,7 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase, rendezvousList []*Rend continue } - // step success + // record step success if stepResult.StepType == stepTypeTransaction { // transaction // FIXME: support nested transactions diff --git a/hrp/internal/boomer/stats.go b/hrp/internal/boomer/stats.go index c1bbcfe8..043246cb 100644 --- a/hrp/internal/boomer/stats.go +++ b/hrp/internal/boomer/stats.go @@ -74,12 +74,16 @@ func (s *requestStats) logTransaction(name string, success bool, responseTime in } func (s *requestStats) logRequest(method, name string, responseTime int64, contentLength int64) { - s.total.log(responseTime, contentLength) + if method != "testcase" { + s.total.log(responseTime, contentLength) + } s.get(name, method).log(responseTime, contentLength) } func (s *requestStats) logError(method, name, err string) { - s.total.logFailures() + if method != "testcase" { + s.total.logFailures() + } s.get(name, method).logFailures() // store error in errors map