plugin/loadbalance: Improve weights update (#5906)

Don't lock weights for duration of parsing weight file. Add
missing check to reject zero weight values.

Signed-off-by: Gabor Dozsa <gabor.dozsa@ibm.com>
This commit is contained in:
Gabor Dozsa
2023-02-15 18:43:19 +01:00
committed by GitHub
parent 156da74ad3
commit 52f1c64e7d
2 changed files with 26 additions and 20 deletions

View File

@@ -79,6 +79,11 @@ w1,example.org
192.168.1.14 300
`
const zeroWeightWRR = `
w1,example.org
192.168.1.14 0
`
func TestWeightFileUpdate(t *testing.T) {
tests := []struct {
weightFilContent string
@@ -95,6 +100,7 @@ func TestWeightFileUpdate(t *testing.T) {
{missingDomainWRR, true, nil, "Missing domain name"},
{wrongIpWRR, true, nil, "Wrong IP address"},
{wrongWeightWRR, true, nil, "Wrong weight value"},
{zeroWeightWRR, true, nil, "Wrong weight value"},
}
for i, test := range tests {