mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 05:30:26 +00:00
add Probers to Probe pkgs.
This commit is contained in:
@@ -25,7 +25,13 @@ import (
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
func Probe(host string, port int) (probe.Status, error) {
|
||||
func New() TCPProber {
|
||||
return TCPProber{}
|
||||
}
|
||||
|
||||
type TCPProber struct{}
|
||||
|
||||
func (pr TCPProber) Probe(host string, port int) (probe.Status, error) {
|
||||
return DoTCPProbe(net.JoinHostPort(host, strconv.Itoa(port)))
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTcpHealthChecker(t *testing.T) {
|
||||
prober := New()
|
||||
tests := []struct {
|
||||
expectedStatus probe.Status
|
||||
usePort bool
|
||||
@@ -58,7 +59,7 @@ func TestTcpHealthChecker(t *testing.T) {
|
||||
if !test.usePort {
|
||||
p = -1
|
||||
}
|
||||
status, err := Probe(host, p)
|
||||
status, err := prober.Probe(host, p)
|
||||
if status != test.expectedStatus {
|
||||
t.Errorf("expected: %v, got: %v", test.expectedStatus, status)
|
||||
}
|
||||
|
Reference in New Issue
Block a user