mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 06:23:52 +08:00
feat: set ulimit to 10240 before load testing
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## v0.4.0 (2021-12-30)
|
## v0.4.0 (2021-12-30)
|
||||||
|
|
||||||
|
- feat: 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)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/hrp"
|
"github.com/httprunner/hrp"
|
||||||
@@ -19,6 +21,7 @@ var boomCmd = &cobra.Command{
|
|||||||
$ hrp boom examples/ # run testcases in specified folder`,
|
$ hrp boom examples/ # run testcases in specified folder`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
setUlimit()
|
||||||
setLogLevel("WARN") // disable info logs for load testing
|
setLogLevel("WARN") // disable info logs for load testing
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
@@ -67,3 +70,26 @@ func init() {
|
|||||||
boomCmd.Flags().StringVar(&prometheusPushgatewayURL, "prometheus-gateway", "", "Prometheus Pushgateway url.")
|
boomCmd.Flags().StringVar(&prometheusPushgatewayURL, "prometheus-gateway", "", "Prometheus Pushgateway url.")
|
||||||
boomCmd.Flags().BoolVar(&disableConsoleOutput, "disable-console-output", false, "Disable console output.")
|
boomCmd.Flags().BoolVar(&disableConsoleOutput, "disable-console-output", false, "Disable console output.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set resource limit
|
||||||
|
// ulimit -n 10240
|
||||||
|
func setUlimit() {
|
||||||
|
var rLimit syscall.Rlimit
|
||||||
|
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("get ulimit failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info().Uint64("limit", rLimit.Cur).Msg("get current ulimit")
|
||||||
|
if rLimit.Cur >= 10240 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rLimit.Cur = 10240
|
||||||
|
log.Info().Uint64("limit", rLimit.Cur).Msg("set current ulimit")
|
||||||
|
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("set ulimit failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user