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

Function TestRoundRobinQueues

pkg/frontend/v1/queue_test.go:92–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestRoundRobinQueues(t *testing.T) {
93 var config Config
94 flagext.DefaultValues(&config)
95
96 const (
97 requests = 100
98 tenants = 10
99 )
100
101 f, err := setupFrontend(t, requests, config)
102 require.NoError(t, err)
103
104 for i := range requests {
105 userID := fmt.Sprint(i / tenants)
106 ctx := user.InjectOrgID(context.Background(), userID)
107
108 err = f.queueRequest(ctx, testReq(ctx, fmt.Sprintf("%d", i), userID))
109 require.NoError(t, err)
110 }
111
112 // Calling Process will only return when client disconnects or context is finished.
113 // We use context timeout to stop Process call.
114 ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
115 defer cancel()
116
117 m := &processServerMock{ctx: ctx, querierID: "querier"}
118 err = f.Process(m)
119 require.EqualError(t, err, context.DeadlineExceeded.Error())
120
121 require.Len(t, m.requests, requests)
122 for i, r := range m.requests {
123 intUserID, err := strconv.Atoi(r.Method)
124 require.NoError(t, err)
125
126 require.Equal(t, i%tenants, intUserID)
127 }
128}
129
130// This mock behaves as connected querier worker to frontend. It will remember each request
131// that frontend sends, and reply with 200 HTTP status code.

Callers

nothing calls this directly

Calls 8

DefaultValuesFunction · 0.92
testReqFunction · 0.85
queueRequestMethod · 0.80
setupFrontendFunction · 0.70
ProcessMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected