MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestFrontendCheckReady

Function TestFrontendCheckReady

pkg/frontend/v1/frontend_test.go:119–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestFrontendCheckReady(t *testing.T) {
120 limits := MockLimits{MockLimits: queue.MockLimits{MaxOutstanding: 100}}
121 for _, tt := range []struct {
122 name string
123 connectedClients int
124 msg string
125 readyForRequests bool
126 }{
127 {"connected clients are ready", 3, "", true},
128 {"no url, no clients is not ready", 0, "not ready: number of queriers connected to query-frontend is 0", false},
129 } {
130 t.Run(tt.name, func(t *testing.T) {
131 f := &Frontend{
132 log: log.NewNopLogger(),
133 requestQueue: queue.NewRequestQueue(5,
134 prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
135 prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
136 limits,
137 nil,
138 ),
139 }
140 for i := 0; i < tt.connectedClients; i++ {
141 f.requestQueue.RegisterQuerierConnection("test")
142 }
143 err := f.CheckReady(context.Background())
144 errMsg := ""
145
146 if err != nil {
147 errMsg = err.Error()
148 }
149
150 require.Equal(t, tt.msg, errMsg)
151 })
152 }
153}
154
155// TestFrontendCancel ensures that when client requests are cancelled,
156// the underlying query is correctly cancelled _and not retried_.

Callers

nothing calls this directly

Calls 6

CheckReadyMethod · 0.95
NewRequestQueueFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected