mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmauth: properly initialize URLPrefix in tests
It is assumed that URLPrefix.busOriginal will be initialized
durin Unmarshal of the config. But in tests we set fields manually,
so this field never get initialized properly.
Fixes the error `panic: runtime error: integer divide by zero`
at `vmauth.getLeastLoadedBackendURL`.
Signed-off-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit cb1e618a16
)
This commit is contained in:
parent
86abbe5b67
commit
67efc174a8
1 changed files with 3 additions and 0 deletions
|
@ -701,6 +701,7 @@ func mustParseURL(u string) *URLPrefix {
|
|||
|
||||
func mustParseURLs(us []string) *URLPrefix {
|
||||
bus := make([]*backendURL, len(us))
|
||||
urls := make([]*url.URL, len(us))
|
||||
for i, u := range us {
|
||||
pu, err := url.Parse(u)
|
||||
if err != nil {
|
||||
|
@ -709,6 +710,7 @@ func mustParseURLs(us []string) *URLPrefix {
|
|||
bus[i] = &backendURL{
|
||||
url: pu,
|
||||
}
|
||||
urls[i] = pu
|
||||
}
|
||||
up := &URLPrefix{}
|
||||
if len(us) == 1 {
|
||||
|
@ -717,6 +719,7 @@ func mustParseURLs(us []string) *URLPrefix {
|
|||
up.vOriginal = us
|
||||
}
|
||||
up.bus.Store(&bus)
|
||||
up.busOriginal = urls
|
||||
return up
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue