mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +08:00
change: update logs
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
- feat: support `--continue-on-failure` flag to continue running next step when failure occurs, default to failfast
|
||||
- refactor: fork [boomer] as sub module
|
||||
- feat: report GA events with version
|
||||
- feat: run load test with the given limit and burst as rate limiter
|
||||
- change: update API models
|
||||
|
||||
## v0.2.2 (2021-12-07)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func Execute() {
|
||||
|
||||
func setLogLevel(level string) {
|
||||
level = strings.ToUpper(level)
|
||||
log.Info().Msgf("Set log level to %s", level)
|
||||
log.Info().Str("level", level).Msg("Set log level")
|
||||
switch level {
|
||||
case "DEBUG":
|
||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package boomer
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// A Boomer is used to run tasks.
|
||||
@@ -36,20 +37,19 @@ func (b *Boomer) SetRateLimiter(maxRPS int64, requestIncreaseRate string) {
|
||||
var rateLimiter RateLimiter
|
||||
var err error
|
||||
if requestIncreaseRate != "-1" {
|
||||
if maxRPS > 0 {
|
||||
log.Println("The max RPS that boomer may generate is limited to", maxRPS, "with a increase rate", requestIncreaseRate)
|
||||
rateLimiter, err = NewRampUpRateLimiter(maxRPS, requestIncreaseRate, time.Second)
|
||||
} else {
|
||||
log.Println("The max RPS that boomer may generate is limited by a increase rate", requestIncreaseRate)
|
||||
rateLimiter, err = NewRampUpRateLimiter(math.MaxInt64, requestIncreaseRate, time.Second)
|
||||
if maxRPS <= 0 {
|
||||
maxRPS = math.MaxInt64
|
||||
}
|
||||
log.Warn().Int64("maxRPS", maxRPS).Str("increaseRate", requestIncreaseRate).Msg("set ramp up rate limiter")
|
||||
rateLimiter, err = NewRampUpRateLimiter(math.MaxInt64, requestIncreaseRate, time.Second)
|
||||
} else {
|
||||
if maxRPS > 0 {
|
||||
log.Println("The max RPS that boomer may generate is limited to", maxRPS)
|
||||
log.Warn().Int64("maxRPS", maxRPS).Msg("set stable rate limiter")
|
||||
rateLimiter = NewStableRateLimiter(maxRPS, time.Second)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to create rate limiter")
|
||||
return
|
||||
}
|
||||
b.rateLimiter = rateLimiter
|
||||
@@ -77,13 +77,13 @@ func (b *Boomer) Run(tasks ...*Task) {
|
||||
if b.cpuProfile != "" {
|
||||
err := startCPUProfile(b.cpuProfile, b.cpuProfileDuration)
|
||||
if err != nil {
|
||||
log.Printf("Error starting cpu profiling, %v", err)
|
||||
log.Error().Err(err).Msg("failed to start cpu profiling")
|
||||
}
|
||||
}
|
||||
if b.memoryProfile != "" {
|
||||
err := startMemoryProfile(b.memoryProfile, b.memoryProfileDuration)
|
||||
if err != nil {
|
||||
log.Printf("Error starting memory profiling, %v", err)
|
||||
log.Error().Err(err).Msg("failed to start memory profiling")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package boomer
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/push"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// Output is primarily responsible for printing test results to different destinations
|
||||
@@ -120,7 +120,7 @@ func (o *ConsoleOutput) OnStop() {
|
||||
func (o *ConsoleOutput) OnEvent(data map[string]interface{}) {
|
||||
output, err := convertData(data)
|
||||
if err != nil {
|
||||
log.Println(fmt.Sprintf("convert data error: %v", err))
|
||||
log.Error().Err(err).Msg("failed to convert data")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ type PrometheusPusherOutput struct {
|
||||
|
||||
// OnStart will register all prometheus metric collectors
|
||||
func (o *PrometheusPusherOutput) OnStart() {
|
||||
log.Println("register prometheus metric collectors")
|
||||
log.Info().Msg("register prometheus metric collectors")
|
||||
registry := prometheus.NewRegistry()
|
||||
registry.MustRegister(
|
||||
// gauge vectors for requests
|
||||
@@ -412,7 +412,7 @@ func (o *PrometheusPusherOutput) OnStop() {
|
||||
func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) {
|
||||
output, err := convertData(data)
|
||||
if err != nil {
|
||||
log.Println(fmt.Sprintf("convert data error: %v", err))
|
||||
log.Error().Err(err).Msg("failed to convert data")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -444,6 +444,6 @@ func (o *PrometheusPusherOutput) OnEvent(data map[string]interface{}) {
|
||||
}
|
||||
|
||||
if err := o.pusher.Push(); err != nil {
|
||||
log.Println(fmt.Sprintf("Could not push to Pushgateway: error: %v", err))
|
||||
log.Error().Err(err).Msg("push to Pushgateway failed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@ package boomer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -116,7 +117,7 @@ func (r *runner) outputOnStop() {
|
||||
}
|
||||
|
||||
func (r *runner) spawnWorkers(spawnCount int, quit chan bool, spawnCompleteFunc func()) {
|
||||
log.Println("Spawning", spawnCount, "clients immediately")
|
||||
log.Info().Int("spawnCount", spawnCount).Msg("Spawning clients immediately")
|
||||
|
||||
for i := 1; i <= spawnCount; i++ {
|
||||
select {
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func round(val float64, roundOn float64, places int) (newVal float64) {
|
||||
@@ -41,14 +42,14 @@ func startMemoryProfile(file string, duration time.Duration) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Println("Start memory profiling for", duration)
|
||||
log.Info().Dur("duration", duration).Msg("Start memory profiling")
|
||||
time.AfterFunc(duration, func() {
|
||||
err = pprof.WriteHeapProfile(f)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Error().Err(err).Msg("failed to write memory profile")
|
||||
}
|
||||
f.Close()
|
||||
log.Println("Stop memory profiling after", duration)
|
||||
log.Info().Dur("duration", duration).Msg("Stop memory profiling")
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -60,7 +61,7 @@ func startCPUProfile(file string, duration time.Duration) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Println("Start cpu profiling for", duration)
|
||||
log.Info().Dur("duration", duration).Msg("Start CPU profiling")
|
||||
err = pprof.StartCPUProfile(f)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
@@ -70,7 +71,7 @@ func startCPUProfile(file string, duration time.Duration) (err error) {
|
||||
time.AfterFunc(duration, func() {
|
||||
pprof.StopCPUProfile()
|
||||
f.Close()
|
||||
log.Println("Stop CPU profiling after", duration)
|
||||
log.Info().Dur("duration", duration).Msg("Stop CPU profiling")
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user