MCPcopy
hub / github.com/grafana/tempo / TestOTLPLimitsVanillaClient

Function TestOTLPLimitsVanillaClient

integration/limits/limits_test.go:128–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestOTLPLimitsVanillaClient(t *testing.T) {
129 util.RunIntegrationTests(t, util.TestHarnessConfig{
130 ConfigOverlay: configIngest,
131 }, func(h *util.TempoHarness) {
132 h.WaitTracesWritable(t)
133
134 trace := test.MakeTrace(10, []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
135
136 testCases := []struct {
137 name string
138 payload func() []byte
139 headers map[string]string
140 }{
141 // TODO There is an issue when sending the payload in json format. The server returns a 200 instead of a 429.
142 // {
143 // "JSON format",
144 // func() []byte {
145 // b := &bytes.Buffer{}
146 // err := (&jsonpb.Marshaler{}).Marshal(b, trace)
147 // require.NoError(t, err)
148 // return b.Bytes()
149 // },
150 // map[string]string{
151 // "Content-Type": "application/json",
152 // },
153 // },
154 {
155 "Proto format",
156 func() []byte {
157 b, err := trace.Marshal()
158 require.NoError(t, err)
159 return b
160 },
161 map[string]string{
162 "Content-Type": "application/x-protobuf",
163 },
164 },
165 }
166
167 for _, tc := range testCases {
168 t.Run(tc.name, func(t *testing.T) {
169 req, err := http.NewRequest(http.MethodPost, "http://"+h.Services[util.ServiceDistributor].Endpoint(4318)+"/v1/traces", bytes.NewReader(tc.payload()))
170 require.NoError(t, err)
171 for k, v := range tc.headers {
172 req.Header.Set(k, v)
173 }
174
175 resp, err := http.DefaultClient.Do(req)
176 require.NoError(t, err)
177 defer func() { _ = resp.Body.Close() }()
178 bodyBytes, err := io.ReadAll(resp.Body)
179 require.NoError(t, err)
180 fmt.Println(string(bodyBytes))
181
182 assert.Equal(t, http.StatusTooManyRequests, resp.StatusCode)
183 })
184 }
185 })

Callers

nothing calls this directly

Calls 9

MakeTraceFunction · 0.92
WaitTracesWritableMethod · 0.80
MarshalMethod · 0.65
SetMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
ReadAllMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected