mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 15:13:08 +00:00
add Probers to Probe pkgs.
This commit is contained in:
@@ -27,7 +27,13 @@ import (
|
||||
|
||||
const defaultHealthyOutput = "ok"
|
||||
|
||||
func Probe(e uexec.Cmd) (probe.Status, error) {
|
||||
func New() ExecProber {
|
||||
return ExecProber{}
|
||||
}
|
||||
|
||||
type ExecProber struct{}
|
||||
|
||||
func (pr ExecProber) Probe(e uexec.Cmd) (probe.Status, error) {
|
||||
data, err := e.CombinedOutput()
|
||||
glog.V(4).Infof("health check response: %s", string(data))
|
||||
if err != nil {
|
||||
|
@@ -42,6 +42,7 @@ type healthCheckTest struct {
|
||||
}
|
||||
|
||||
func TestExec(t *testing.T) {
|
||||
prober := New()
|
||||
fake := FakeCmd{}
|
||||
tests := []healthCheckTest{
|
||||
// Ok
|
||||
@@ -54,7 +55,7 @@ func TestExec(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
fake.out = test.output
|
||||
fake.err = test.err
|
||||
status, err := Probe(&fake)
|
||||
status, err := prober.Probe(&fake)
|
||||
if status != test.expectedStatus {
|
||||
t.Errorf("expected %v, got %v", test.expectedStatus, status)
|
||||
}
|
||||
|
Reference in New Issue
Block a user