mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-26 02:40:05 +08:00
change: update models
This commit is contained in:
12
boomer.go
12
boomer.go
@@ -9,27 +9,27 @@ import (
|
|||||||
"github.com/httprunner/hrp/internal/ga"
|
"github.com/httprunner/hrp/internal/ga"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBoomer(spawnCount int, spawnRate float64) *hrpBoomer {
|
func NewBoomer(spawnCount int, spawnRate float64) *HRPBoomer {
|
||||||
b := &hrpBoomer{
|
b := &HRPBoomer{
|
||||||
Boomer: boomer.NewStandaloneBoomer(spawnCount, spawnRate),
|
Boomer: boomer.NewStandaloneBoomer(spawnCount, spawnRate),
|
||||||
debug: false,
|
debug: false,
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
type hrpBoomer struct {
|
type HRPBoomer struct {
|
||||||
*boomer.Boomer
|
*boomer.Boomer
|
||||||
debug bool
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDebug configures whether to log HTTP request and response content.
|
// 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
|
b.debug = debug
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts to run load test for one or multiple testcases.
|
// 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{
|
event := ga.EventTracking{
|
||||||
Category: "RunLoadTests",
|
Category: "RunLoadTests",
|
||||||
Action: "hrp boom",
|
Action: "hrp boom",
|
||||||
@@ -51,7 +51,7 @@ func (b *hrpBoomer) Run(testcases ...ITestCase) {
|
|||||||
b.Boomer.Run(taskSlice...)
|
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)
|
hrpRunner := NewRunner(nil).SetDebug(b.debug)
|
||||||
config := testcase.Config.ToStruct()
|
config := testcase.Config.ToStruct()
|
||||||
return &boomer.Task{
|
return &boomer.Task{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## v0.3.1 (2021-12-30)
|
## 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
|
- fix: concurrent map writes in load testing
|
||||||
|
|
||||||
## v0.3.0 (2021-12-24)
|
## v0.3.0 (2021-12-24)
|
||||||
|
|||||||
18
runner.go
18
runner.go
@@ -28,11 +28,11 @@ func Run(testcases ...ITestCase) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRunner constructs a new runner instance.
|
// NewRunner constructs a new runner instance.
|
||||||
func NewRunner(t *testing.T) *hrpRunner {
|
func NewRunner(t *testing.T) *HRPRunner {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
t = &testing.T{}
|
t = &testing.T{}
|
||||||
}
|
}
|
||||||
return &hrpRunner{
|
return &HRPRunner{
|
||||||
t: t,
|
t: t,
|
||||||
failfast: true, // default to failfast
|
failfast: true, // default to failfast
|
||||||
debug: false, // default to turn off debug
|
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
|
t *testing.T
|
||||||
failfast bool
|
failfast bool
|
||||||
debug bool
|
debug bool
|
||||||
@@ -53,21 +53,21 @@ type hrpRunner struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetFailfast configures whether to stop running when one step fails.
|
// 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")
|
log.Info().Bool("failfast", failfast).Msg("[init] SetFailfast")
|
||||||
r.failfast = failfast
|
r.failfast = failfast
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDebug configures whether to log HTTP request and response content.
|
// 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")
|
log.Info().Bool("debug", debug).Msg("[init] SetDebug")
|
||||||
r.debug = debug
|
r.debug = debug
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetProxyUrl configures the proxy URL, which is usually used to capture HTTP packets for debugging.
|
// 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")
|
log.Info().Str("proxyUrl", proxyUrl).Msg("[init] SetProxyUrl")
|
||||||
p, err := url.Parse(proxyUrl)
|
p, err := url.Parse(proxyUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -82,7 +82,7 @@ func (r *hrpRunner) SetProxyUrl(proxyUrl string) *hrpRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run starts to execute one or multiple testcases.
|
// 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{
|
event := ga.EventTracking{
|
||||||
Category: "RunAPITests",
|
Category: "RunAPITests",
|
||||||
Action: "hrp run",
|
Action: "hrp run",
|
||||||
@@ -106,7 +106,7 @@ func (r *hrpRunner) Run(testcases ...ITestCase) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *hrpRunner) newCaseRunner(testcase *TestCase) *caseRunner {
|
func (r *HRPRunner) newCaseRunner(testcase *TestCase) *caseRunner {
|
||||||
caseRunner := &caseRunner{
|
caseRunner := &caseRunner{
|
||||||
TestCase: testcase,
|
TestCase: testcase,
|
||||||
hrpRunner: r,
|
hrpRunner: r,
|
||||||
@@ -119,7 +119,7 @@ func (r *hrpRunner) newCaseRunner(testcase *TestCase) *caseRunner {
|
|||||||
// each testcase has its own caseRunner instance and share session variables.
|
// each testcase has its own caseRunner instance and share session variables.
|
||||||
type caseRunner struct {
|
type caseRunner struct {
|
||||||
*TestCase
|
*TestCase
|
||||||
hrpRunner *hrpRunner
|
hrpRunner *HRPRunner
|
||||||
sessionVariables map[string]interface{}
|
sessionVariables map[string]interface{}
|
||||||
// transactions stores transaction timing info.
|
// transactions stores transaction timing info.
|
||||||
// key is transaction name, value is map of transaction type and time, e.g. start time and end time.
|
// key is transaction name, value is map of transaction type and time, e.g. start time and end time.
|
||||||
|
|||||||
Reference in New Issue
Block a user