MCPcopy
hub / github.com/IBM/sarama / TestAsyncProducerIdempotentRetryCheckBatch

Function TestAsyncProducerIdempotentRetryCheckBatch

async_producer_test.go:1233–1378  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1231}
1232
1233func TestAsyncProducerIdempotentRetryCheckBatch(t *testing.T) {
1234 // Logger = log.New(os.Stderr, "", log.LstdFlags)
1235 tests := []struct {
1236 name string
1237 failAfterWrite bool
1238 }{
1239 {"FailAfterWrite", true},
1240 {"FailBeforeWrite", false},
1241 }
1242
1243 for _, test := range tests {
1244 broker := NewMockBroker(t, 1)
1245
1246 metadataResponse := &MetadataResponse{
1247 Version: 4,
1248 ControllerID: 1,
1249 }
1250 metadataResponse.AddBroker(broker.Addr(), broker.BrokerID())
1251 metadataResponse.AddTopicPartition("my_topic", 0, broker.BrokerID(), nil, nil, nil, ErrNoError)
1252
1253 initProducerIDResponse := &InitProducerIDResponse{
1254 ThrottleTime: 0,
1255 ProducerID: 1000,
1256 ProducerEpoch: 1,
1257 }
1258
1259 prodNotLeaderResponse := &ProduceResponse{
1260 Version: 3,
1261 ThrottleTime: 0,
1262 }
1263 prodNotLeaderResponse.AddTopicPartition("my_topic", 0, ErrNotEnoughReplicas)
1264
1265 prodDuplicate := &ProduceResponse{
1266 Version: 3,
1267 ThrottleTime: 0,
1268 }
1269 prodDuplicate.AddTopicPartition("my_topic", 0, ErrDuplicateSequenceNumber)
1270
1271 prodOutOfSeq := &ProduceResponse{
1272 Version: 3,
1273 ThrottleTime: 0,
1274 }
1275 prodOutOfSeq.AddTopicPartition("my_topic", 0, ErrOutOfOrderSequenceNumber)
1276
1277 prodSuccessResponse := &ProduceResponse{
1278 Version: 3,
1279 ThrottleTime: 0,
1280 }
1281 prodSuccessResponse.AddTopicPartition("my_topic", 0, ErrNoError)
1282
1283 prodCounter := 0
1284 lastBatchFirstSeq := -1
1285 lastBatchSize := -1
1286 lastSequenceWrittenToDisk := -1
1287 handlerFailBeforeWrite := func(req *request) (res encoderWithHeader) {
1288 switch req.body.key() {
1289 case 3:
1290 return metadataResponse

Callers

nothing calls this directly

Calls 15

AddBrokerMethod · 0.95
AddrMethod · 0.95
BrokerIDMethod · 0.95
AddTopicPartitionMethod · 0.95
AddTopicPartitionMethod · 0.95
setHandlerMethod · 0.95
InputMethod · 0.95
CloseMethod · 0.95
NewMockBrokerFunction · 0.85
StringEncoderTypeAlias · 0.85
expectResultsFunction · 0.85
closeProducerFunction · 0.85

Tested by

no test coverage detected