forked from submariner-io/submariner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reset gateway connection status when health checker reports connected
When the health checker reports a connection error, the gateway syncer sets the gateway connection status to error. When the health checker subsequently reports connected, the gateway syncer needs to set the status back to connected. The rest of the changes were related to adding unit tests for the health checker's interaction with the gateway syncer. This entailed creating a PingerInterface and a fake implementation that can be injected into the health checker. Signed-off-by: Tom Pantelis <[email protected]>
- Loading branch information
Showing
6 changed files
with
332 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package fake | ||
|
||
import ( | ||
"sync/atomic" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/submariner-io/submariner/pkg/cableengine/healthchecker" | ||
) | ||
|
||
type Pinger struct { | ||
ip string | ||
latencyInfo atomic.Value | ||
start chan struct{} | ||
stop chan struct{} | ||
} | ||
|
||
func NewPinger(ip string) *Pinger { | ||
return &Pinger{ | ||
ip: ip, | ||
start: make(chan struct{}), | ||
stop: make(chan struct{}), | ||
} | ||
} | ||
|
||
func (p *Pinger) Start() { | ||
defer GinkgoRecover() | ||
Expect(p.start).ToNot(BeClosed()) | ||
close(p.start) | ||
} | ||
|
||
func (p *Pinger) Stop() { | ||
defer GinkgoRecover() | ||
Expect(p.stop).ToNot(BeClosed()) | ||
close(p.stop) | ||
} | ||
|
||
func (p *Pinger) GetLatencyInfo() *healthchecker.LatencyInfo { | ||
o := p.latencyInfo.Load() | ||
if o != nil { | ||
info := o.(healthchecker.LatencyInfo) | ||
return &info | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (p *Pinger) SetLatencyInfo(info *healthchecker.LatencyInfo) { | ||
p.latencyInfo.Store(*info) | ||
} | ||
|
||
func (p *Pinger) GetIP() string { | ||
return p.ip | ||
} | ||
|
||
func (p *Pinger) AwaitStart() { | ||
Eventually(p.start).Should(BeClosed(), "Start was not called") | ||
} | ||
|
||
func (p *Pinger) AwaitStop() { | ||
Eventually(p.stop).Should(BeClosed(), "Stop was not called") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.