mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 17:59:36 +08:00
fix: use master IP if PrometheusPushgatewayURL IP is not set in worker
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -209,6 +210,18 @@ func (b *HRPBoomer) runTestCases(testCases []*TCase, profile *boomer.Profile) {
|
|||||||
testcases = append(testcases, tesecase)
|
testcases = append(testcases, tesecase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if profile.PrometheusPushgatewayURL != "" {
|
||||||
|
urlSlice := strings.Split(profile.PrometheusPushgatewayURL, ":")
|
||||||
|
if len(urlSlice) != 2 {
|
||||||
|
profile.PrometheusPushgatewayURL = ""
|
||||||
|
} else {
|
||||||
|
if urlSlice[0] == "" {
|
||||||
|
urlSlice[0] = b.Boomer.GetMasterHost()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profile.PrometheusPushgatewayURL = strings.Join(urlSlice, ":")
|
||||||
|
}
|
||||||
|
|
||||||
b.SetProfile(profile)
|
b.SetProfile(profile)
|
||||||
b.InitBoomer()
|
b.InitBoomer()
|
||||||
log.Info().Interface("testcases", testcases).Interface("profile", profile).Msg("run tasks successful")
|
log.Info().Interface("testcases", testcases).Interface("profile", profile).Msg("run tasks successful")
|
||||||
|
|||||||
@@ -148,26 +148,12 @@ func makeHRPBoomer() *hrp.HRPBoomer {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hrpBoomer := hrp.NewStandaloneBoomer(boomArgs.SpawnCount, boomArgs.SpawnRate)
|
hrpBoomer := hrp.NewStandaloneBoomer(boomArgs.SpawnCount, boomArgs.SpawnRate)
|
||||||
hrpBoomer.SetRateLimiter(boomArgs.MaxRPS, boomArgs.RequestIncreaseRate)
|
|
||||||
if boomArgs.LoopCount > 0 {
|
|
||||||
hrpBoomer.SetLoopCount(boomArgs.LoopCount)
|
|
||||||
}
|
|
||||||
if !boomArgs.DisableConsoleOutput {
|
|
||||||
hrpBoomer.AddOutput(boomer.NewConsoleOutput())
|
|
||||||
}
|
|
||||||
if boomArgs.PrometheusPushgatewayURL != "" {
|
|
||||||
hrpBoomer.AddOutput(boomer.NewPrometheusPusherOutput(boomArgs.PrometheusPushgatewayURL, "hrp", hrpBoomer.GetMode()))
|
|
||||||
}
|
|
||||||
hrpBoomer.SetDisableKeepAlive(boomArgs.DisableKeepalive)
|
|
||||||
hrpBoomer.SetDisableCompression(boomArgs.DisableCompression)
|
|
||||||
hrpBoomer.SetClientTransport()
|
|
||||||
if venv != "" {
|
if venv != "" {
|
||||||
hrpBoomer.SetPython3Venv(venv)
|
hrpBoomer.SetPython3Venv(venv)
|
||||||
}
|
}
|
||||||
hrpBoomer.EnableCPUProfile(boomArgs.CPUProfile, boomArgs.CPUProfileDuration)
|
hrpBoomer.SetProfile(&boomArgs.Profile)
|
||||||
hrpBoomer.EnableMemoryProfile(boomArgs.MemoryProfile, boomArgs.MemoryProfileDuration)
|
hrpBoomer.EnableGracefulQuit(context.Background())
|
||||||
hrpBoomer.EnableGracefulQuit()
|
hrpBoomer.InitBoomer()
|
||||||
return hrpBoomer
|
return hrpBoomer
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,11 @@ func (b *Boomer) ParseTestCasesChan() chan bool {
|
|||||||
return b.masterRunner.parseTestCasesChan
|
return b.masterRunner.parseTestCasesChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMasterHost returns master IP
|
||||||
|
func (b *Boomer) GetMasterHost() string {
|
||||||
|
return b.masterHost
|
||||||
|
}
|
||||||
|
|
||||||
// GetState gets worker state
|
// GetState gets worker state
|
||||||
func (b *Boomer) GetState() int32 {
|
func (b *Boomer) GetState() int32 {
|
||||||
switch b.mode {
|
switch b.mode {
|
||||||
|
|||||||
Reference in New Issue
Block a user