Fix health race (#645)
* Revert "middleware/proxy: Make Unhealthy a pointer (#615)"
This reverts commit acbf522ceb
.
* middleware/proxy: add proper locking
This add the proper locking around `Unhealthy`.
This commit is contained in:
parent
bfa18470e5
commit
003b1bf678
6 changed files with 26 additions and 28 deletions
|
@ -42,13 +42,13 @@ func TestSelect(t *testing.T) {
|
|||
FailTimeout: 10 * time.Second,
|
||||
MaxFails: 1,
|
||||
}
|
||||
*upstream.Hosts[0].Unhealthy = true
|
||||
*upstream.Hosts[1].Unhealthy = true
|
||||
*upstream.Hosts[2].Unhealthy = true
|
||||
upstream.Hosts[0].Unhealthy = true
|
||||
upstream.Hosts[1].Unhealthy = true
|
||||
upstream.Hosts[2].Unhealthy = true
|
||||
if h := upstream.Select(); h != nil {
|
||||
t.Error("Expected select to return nil as all host are down")
|
||||
}
|
||||
*upstream.Hosts[2].Unhealthy = false
|
||||
upstream.Hosts[2].Unhealthy = false
|
||||
if h := upstream.Select(); h == nil {
|
||||
t.Error("Expected select to not return nil")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue