(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func TestProbeHTTPFailure(t *testing.T) { |
| 98 | t.Parallel() |
| 99 | |
| 100 | log := newLogger(t) |
| 101 | defer func() { _ = log.Sync() }() |
| 102 | |
| 103 | pb := probe.NewProbe( |
| 104 | &kcore.Probe{ |
| 105 | Handler: kcore.Handler{ |
| 106 | HTTPGet: &kcore.HTTPGetAction{ |
| 107 | Path: "/healthz", |
| 108 | Port: intstr.FromString("12345"), |
| 109 | Host: "127.0.0.1", |
| 110 | }, |
| 111 | }, |
| 112 | InitialDelaySeconds: 1, |
| 113 | TimeoutSeconds: 3, |
| 114 | PeriodSeconds: 1, |
| 115 | SuccessThreshold: 1, |
| 116 | FailureThreshold: 1, |
| 117 | }, log, |
| 118 | ) |
| 119 | |
| 120 | stopper := pb.StartProbing() |
| 121 | defer func() { |
| 122 | stopper <- struct{}{} |
| 123 | }() |
| 124 | |
| 125 | for { |
| 126 | if pb.HasRunOnce() { |
| 127 | break |
| 128 | } |
| 129 | time.Sleep(time.Second) |
| 130 | } |
| 131 | |
| 132 | require.False(t, pb.IsHealthy()) |
| 133 | } |
| 134 | |
| 135 | func TestProbeHTTPSuccess(t *testing.T) { |
| 136 | t.Parallel() |
nothing calls this directly
no test coverage detected