MCPcopy
hub / github.com/segmentio/kafka-go / TestProduceResponse

Function TestProduceResponse

protocol/produce/produce_test.go:156–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestProduceResponse(t *testing.T) {
157 prototest.TestResponse(t, v0, &produce.Response{
158 Topics: []produce.ResponseTopic{
159 {
160 Topic: "topic-1",
161 Partitions: []produce.ResponsePartition{
162 {
163 Partition: 0,
164 ErrorCode: 0,
165 BaseOffset: 0,
166 },
167 {
168 Partition: 1,
169 ErrorCode: 0,
170 BaseOffset: 42,
171 },
172 },
173 },
174 },
175 })
176
177 prototest.TestResponse(t, v8, &produce.Response{
178 Topics: []produce.ResponseTopic{
179 {
180 Topic: "topic-1",
181 Partitions: []produce.ResponsePartition{
182 {
183 Partition: 0,
184 ErrorCode: 0,
185 BaseOffset: 42,
186 LogAppendTime: 1e9,
187 LogStartOffset: 10,
188 RecordErrors: []produce.ResponseError{},
189 },
190 {
191 Partition: 1,
192 ErrorCode: 1,
193 RecordErrors: []produce.ResponseError{
194 {BatchIndex: 1, BatchIndexErrorMessage: "message-1"},
195 {BatchIndex: 2, BatchIndexErrorMessage: "message-2"},
196 {BatchIndex: 3, BatchIndexErrorMessage: "message-3"},
197 },
198 ErrorMessage: "something went wrong",
199 },
200 },
201 },
202 },
203 })
204}
205
206func BenchmarkProduceRequest(b *testing.B) {
207 t0 := time.Now().Truncate(time.Millisecond)

Callers

nothing calls this directly

Calls 1

TestResponseFunction · 0.92

Tested by

no test coverage detected