MCPcopy Index your code
hub / github.com/cortexlabs/cortex / TestDefaultProbeSuccess

Function TestDefaultProbeSuccess

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

Source from the content-addressed store, hash-verified

44}
45
46func TestDefaultProbeSuccess(t *testing.T) {
47 t.Parallel()
48
49 log := newLogger(t)
50 defer func() { _ = log.Sync() }()
51
52 var handler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
53 w.WriteHeader(http.StatusOK)
54 }
55 server := httptest.NewServer(handler)
56 pb := probe.NewDefaultProbe(server.URL, log)
57
58 stopper := pb.StartProbing()
59 defer func() {
60 stopper <- struct{}{}
61 }()
62
63 for {
64 if pb.HasRunOnce() {
65 break
66 }
67 time.Sleep(time.Second)
68 }
69
70 require.True(t, pb.IsHealthy())
71}
72
73func TestDefaultProbeFailure(t *testing.T) {
74 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewDefaultProbeFunction · 0.92
StartProbingMethod · 0.80
HasRunOnceMethod · 0.80
IsHealthyMethod · 0.80
newLoggerFunction · 0.70

Tested by

no test coverage detected