mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
feat: run standalone boomer
This commit is contained in:
16
boomer.go
16
boomer.go
@@ -6,19 +6,9 @@ import (
|
|||||||
"github.com/debugtalk/boomer"
|
"github.com/debugtalk/boomer"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
func NewStandaloneBoomer(spawnCount int, spawnRate float64) *Boomer {
|
||||||
defaultMasterHost = "127.0.0.1"
|
|
||||||
defaultMasterPort = 5557
|
|
||||||
)
|
|
||||||
|
|
||||||
// run load test with default configs
|
|
||||||
func Boom(testcases ...ITestCase) {
|
|
||||||
NewBoomer(defaultMasterHost, defaultMasterPort).Run(testcases...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewBoomer(masterHost string, masterPort int) *Boomer {
|
|
||||||
return &Boomer{
|
return &Boomer{
|
||||||
Boomer: boomer.NewBoomer(masterHost, masterPort),
|
Boomer: boomer.NewStandaloneBoomer(spawnCount, spawnRate),
|
||||||
debug: false,
|
debug: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +33,7 @@ func (b *Boomer) Run(testcases ...ITestCase) {
|
|||||||
task := b.convertBoomerTask(testcase)
|
task := b.convertBoomerTask(testcase)
|
||||||
taskSlice = append(taskSlice, task)
|
taskSlice = append(taskSlice, task)
|
||||||
}
|
}
|
||||||
boomer.Run(taskSlice...)
|
b.Boomer.Run(taskSlice...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Boomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
func (b *Boomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ func TestHttpBoomer(t *testing.T) {
|
|||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Boom(testcase1, testcase2)
|
// NewStandaloneBoomer(1, 1).Run(testcase1, testcase2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ Copyright 2021 debugtalk
|
|||||||
* [hrp har2case](hrp_har2case.md) - Convert HAR to json/yaml testcase files
|
* [hrp har2case](hrp_har2case.md) - Convert HAR to json/yaml testcase files
|
||||||
* [hrp run](hrp_run.md) - run API test
|
* [hrp run](hrp_run.md) - run API test
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Nov-2021
|
###### Auto generated by spf13/cobra on 14-Nov-2021
|
||||||
|
|||||||
@@ -24,17 +24,17 @@ hrp boom [flags]
|
|||||||
--cpu-profile string Enable CPU profiling.
|
--cpu-profile string Enable CPU profiling.
|
||||||
--cpu-profile-duration duration CPU profile duration. (default 30s)
|
--cpu-profile-duration duration CPU profile duration. (default 30s)
|
||||||
-h, --help help for boom
|
-h, --help help for boom
|
||||||
--master-host string Host or IP address of locust master for distributed load testing. (default "127.0.0.1")
|
|
||||||
--master-port int The port to connect to that is used by the locust master for distributed load testing. (default 5557)
|
|
||||||
--max-rps int Max RPS that boomer can generate, disabled by default.
|
--max-rps int Max RPS that boomer can generate, disabled by default.
|
||||||
--mem-profile string Enable memory profiling.
|
--mem-profile string Enable memory profiling.
|
||||||
--mem-profile-duration duration Memory profile duration. (default 30s)
|
--mem-profile-duration duration Memory profile duration. (default 30s)
|
||||||
--request-increase-rate string Request increase rate, disabled by default. (default "-1")
|
--request-increase-rate string Request increase rate, disabled by default. (default "-1")
|
||||||
--run-tasks string Run tasks without connecting to the master, multiply tasks is separated by comma. Usually, it's for debug purpose.
|
--run-tasks string Run tasks without connecting to the master, multiply tasks is separated by comma. Usually, it's for debug purpose.
|
||||||
|
--spawn-count int The number of users to spawn for load testing (default 1)
|
||||||
|
--spawn-rate float The rate for spawning users (default 1)
|
||||||
```
|
```
|
||||||
|
|
||||||
### SEE ALSO
|
### SEE ALSO
|
||||||
|
|
||||||
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Nov-2021
|
###### Auto generated by spf13/cobra on 14-Nov-2021
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ hrp har2case harPath... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Nov-2021
|
###### Auto generated by spf13/cobra on 14-Nov-2021
|
||||||
|
|||||||
@@ -30,4 +30,4 @@ hrp run path... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
* [hrp](hrp.md) - One-stop solution for HTTP(S) testing.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 11-Nov-2021
|
###### Auto generated by spf13/cobra on 14-Nov-2021
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var boomCmd = &cobra.Command{
|
|||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
||||||
}
|
}
|
||||||
boomer := hrp.NewBoomer(masterHost, masterPort)
|
boomer := hrp.NewStandaloneBoomer(spawnCount, spawnRate)
|
||||||
boomer.EnableCPUProfile(cpuProfile, cpuProfileDuration)
|
boomer.EnableCPUProfile(cpuProfile, cpuProfileDuration)
|
||||||
boomer.EnableMemoryProfile(memoryProfile, memoryProfileDuration)
|
boomer.EnableMemoryProfile(memoryProfile, memoryProfileDuration)
|
||||||
boomer.Run(paths...)
|
boomer.Run(paths...)
|
||||||
@@ -30,8 +30,8 @@ var boomCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
masterHost string
|
spawnCount int
|
||||||
masterPort int
|
spawnRate float64
|
||||||
maxRPS int64 // TODO: init boomer with this flag
|
maxRPS int64 // TODO: init boomer with this flag
|
||||||
requestIncreaseRate string // TODO: init boomer with this flag
|
requestIncreaseRate string // TODO: init boomer with this flag
|
||||||
runTasks string // TODO: init boomer with this flag
|
runTasks string // TODO: init boomer with this flag
|
||||||
@@ -47,8 +47,8 @@ func init() {
|
|||||||
boomCmd.Flags().Int64Var(&maxRPS, "max-rps", 0, "Max RPS that boomer can generate, disabled by default.")
|
boomCmd.Flags().Int64Var(&maxRPS, "max-rps", 0, "Max RPS that boomer can generate, disabled by default.")
|
||||||
boomCmd.Flags().StringVar(&requestIncreaseRate, "request-increase-rate", "-1", "Request increase rate, disabled by default.")
|
boomCmd.Flags().StringVar(&requestIncreaseRate, "request-increase-rate", "-1", "Request increase rate, disabled by default.")
|
||||||
boomCmd.Flags().StringVar(&runTasks, "run-tasks", "", "Run tasks without connecting to the master, multiply tasks is separated by comma. Usually, it's for debug purpose.")
|
boomCmd.Flags().StringVar(&runTasks, "run-tasks", "", "Run tasks without connecting to the master, multiply tasks is separated by comma. Usually, it's for debug purpose.")
|
||||||
boomCmd.Flags().StringVar(&masterHost, "master-host", "127.0.0.1", "Host or IP address of locust master for distributed load testing.")
|
boomCmd.Flags().IntVar(&spawnCount, "spawn-count", 1, "The number of users to spawn for load testing")
|
||||||
boomCmd.Flags().IntVar(&masterPort, "master-port", 5557, "The port to connect to that is used by the locust master for distributed load testing.")
|
boomCmd.Flags().Float64Var(&spawnRate, "spawn-rate", 1, "The rate for spawning users")
|
||||||
boomCmd.Flags().StringVar(&memoryProfile, "mem-profile", "", "Enable memory profiling.")
|
boomCmd.Flags().StringVar(&memoryProfile, "mem-profile", "", "Enable memory profiling.")
|
||||||
boomCmd.Flags().DurationVar(&memoryProfileDuration, "mem-profile-duration", 30*time.Second, "Memory profile duration.")
|
boomCmd.Flags().DurationVar(&memoryProfileDuration, "mem-profile-duration", 30*time.Second, "Memory profile duration.")
|
||||||
boomCmd.Flags().StringVar(&cpuProfile, "cpu-profile", "", "Enable CPU profiling.")
|
boomCmd.Flags().StringVar(&cpuProfile, "cpu-profile", "", "Enable CPU profiling.")
|
||||||
|
|||||||
Reference in New Issue
Block a user