MCPcopy
hub / github.com/cortexlabs/cortex / TestProbeHTTPFailure

Function TestProbeHTTPFailure

pkg/probe/probe_test.go:97–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func 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
135func TestProbeHTTPSuccess(t *testing.T) {
136 t.Parallel()

Callers

nothing calls this directly

Calls 5

StartProbingMethod · 0.95
HasRunOnceMethod · 0.95
IsHealthyMethod · 0.95
NewProbeFunction · 0.92
newLoggerFunction · 0.70

Tested by

no test coverage detected