change: update models

This commit is contained in:
debugtalk
2021-12-30 18:02:15 +08:00
parent 271c533b4b
commit 51df014c4a
3 changed files with 16 additions and 16 deletions

View File

@@ -9,27 +9,27 @@ import (
"github.com/httprunner/hrp/internal/ga"
)
func NewBoomer(spawnCount int, spawnRate float64) *hrpBoomer {
b := &hrpBoomer{
func NewBoomer(spawnCount int, spawnRate float64) *HRPBoomer {
b := &HRPBoomer{
Boomer: boomer.NewStandaloneBoomer(spawnCount, spawnRate),
debug: false,
}
return b
}
type hrpBoomer struct {
type HRPBoomer struct {
*boomer.Boomer
debug bool
}
// SetDebug configures whether to log HTTP request and response content.
func (b *hrpBoomer) SetDebug(debug bool) *hrpBoomer {
func (b *HRPBoomer) SetDebug(debug bool) *HRPBoomer {
b.debug = debug
return b
}
// Run starts to run load test for one or multiple testcases.
func (b *hrpBoomer) Run(testcases ...ITestCase) {
func (b *HRPBoomer) Run(testcases ...ITestCase) {
event := ga.EventTracking{
Category: "RunLoadTests",
Action: "hrp boom",
@@ -51,7 +51,7 @@ func (b *hrpBoomer) Run(testcases ...ITestCase) {
b.Boomer.Run(taskSlice...)
}
func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
func (b *HRPBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
hrpRunner := NewRunner(nil).SetDebug(b.debug)
config := testcase.Config.ToStruct()
return &boomer.Task{

View File

@@ -2,7 +2,7 @@
## v0.3.1 (2021-12-30)
- feat: set ulimit to 10240 before load testing
- fix: set ulimit to 10240 before load testing
- fix: concurrent map writes in load testing
## v0.3.0 (2021-12-24)

View File

@@ -28,11 +28,11 @@ func Run(testcases ...ITestCase) error {
}
// NewRunner constructs a new runner instance.
func NewRunner(t *testing.T) *hrpRunner {
func NewRunner(t *testing.T) *HRPRunner {
if t == nil {
t = &testing.T{}
}
return &hrpRunner{
return &HRPRunner{
t: t,
failfast: true, // default to failfast
debug: false, // default to turn off debug
@@ -45,7 +45,7 @@ func NewRunner(t *testing.T) *hrpRunner {
}
}
type hrpRunner struct {
type HRPRunner struct {
t *testing.T
failfast bool
debug bool
@@ -53,21 +53,21 @@ type hrpRunner struct {
}
// SetFailfast configures whether to stop running when one step fails.
func (r *hrpRunner) SetFailfast(failfast bool) *hrpRunner {
func (r *HRPRunner) SetFailfast(failfast bool) *HRPRunner {
log.Info().Bool("failfast", failfast).Msg("[init] SetFailfast")
r.failfast = failfast
return r
}
// SetDebug configures whether to log HTTP request and response content.
func (r *hrpRunner) SetDebug(debug bool) *hrpRunner {
func (r *HRPRunner) SetDebug(debug bool) *HRPRunner {
log.Info().Bool("debug", debug).Msg("[init] SetDebug")
r.debug = debug
return r
}
// SetProxyUrl configures the proxy URL, which is usually used to capture HTTP packets for debugging.
func (r *hrpRunner) SetProxyUrl(proxyUrl string) *hrpRunner {
func (r *HRPRunner) SetProxyUrl(proxyUrl string) *HRPRunner {
log.Info().Str("proxyUrl", proxyUrl).Msg("[init] SetProxyUrl")
p, err := url.Parse(proxyUrl)
if err != nil {
@@ -82,7 +82,7 @@ func (r *hrpRunner) SetProxyUrl(proxyUrl string) *hrpRunner {
}
// Run starts to execute one or multiple testcases.
func (r *hrpRunner) Run(testcases ...ITestCase) error {
func (r *HRPRunner) Run(testcases ...ITestCase) error {
event := ga.EventTracking{
Category: "RunAPITests",
Action: "hrp run",
@@ -106,7 +106,7 @@ func (r *hrpRunner) Run(testcases ...ITestCase) error {
return nil
}
func (r *hrpRunner) newCaseRunner(testcase *TestCase) *caseRunner {
func (r *HRPRunner) newCaseRunner(testcase *TestCase) *caseRunner {
caseRunner := &caseRunner{
TestCase: testcase,
hrpRunner: r,
@@ -119,7 +119,7 @@ func (r *hrpRunner) newCaseRunner(testcase *TestCase) *caseRunner {
// each testcase has its own caseRunner instance and share session variables.
type caseRunner struct {
*TestCase
hrpRunner *hrpRunner
hrpRunner *HRPRunner
sessionVariables map[string]interface{}
// transactions stores transaction timing info.
// key is transaction name, value is map of transaction type and time, e.g. start time and end time.