(t *testing.T)
| 2362 | } |
| 2363 | |
| 2364 | func TestTxnProduceRecordWithCommit(t *testing.T) { |
| 2365 | broker := NewMockBroker(t, 1) |
| 2366 | defer broker.Close() |
| 2367 | |
| 2368 | config := NewTestConfig() |
| 2369 | config.Producer.Idempotent = true |
| 2370 | config.Producer.Transaction.ID = "test" |
| 2371 | config.Version = V0_11_0_0 |
| 2372 | config.Producer.RequiredAcks = WaitForAll |
| 2373 | config.Net.MaxOpenRequests = 1 |
| 2374 | |
| 2375 | metadataLeader := new(MetadataResponse) |
| 2376 | metadataLeader.Version = 4 |
| 2377 | metadataLeader.ControllerID = broker.brokerID |
| 2378 | metadataLeader.AddBroker(broker.Addr(), broker.BrokerID()) |
| 2379 | metadataLeader.AddTopic("test-topic", ErrNoError) |
| 2380 | metadataLeader.AddTopicPartition("test-topic", 0, broker.BrokerID(), nil, nil, nil, ErrNoError) |
| 2381 | broker.Returns(metadataLeader) |
| 2382 | |
| 2383 | client, err := NewClient([]string{broker.Addr()}, config) |
| 2384 | require.NoError(t, err) |
| 2385 | defer client.Close() |
| 2386 | |
| 2387 | findCoordinatorResponse := FindCoordinatorResponse{ |
| 2388 | Coordinator: client.Brokers()[0], |
| 2389 | Err: ErrNoError, |
| 2390 | Version: 1, |
| 2391 | } |
| 2392 | broker.Returns(&findCoordinatorResponse) |
| 2393 | |
| 2394 | producerIdResponse := &InitProducerIDResponse{ |
| 2395 | Err: ErrNoError, |
| 2396 | ProducerID: 1, |
| 2397 | ProducerEpoch: 0, |
| 2398 | } |
| 2399 | broker.Returns(producerIdResponse) |
| 2400 | |
| 2401 | ap, err := NewAsyncProducerFromClient(client) |
| 2402 | producer := ap.(*asyncProducer) |
| 2403 | require.NoError(t, err) |
| 2404 | defer ap.Close() |
| 2405 | |
| 2406 | addPartitionsToTxnResponse := &AddPartitionsToTxnResponse{ |
| 2407 | Errors: map[string][]*PartitionError{ |
| 2408 | "test-topic": { |
| 2409 | { |
| 2410 | Partition: 0, |
| 2411 | }, |
| 2412 | }, |
| 2413 | }, |
| 2414 | } |
| 2415 | broker.Returns(addPartitionsToTxnResponse) |
| 2416 | |
| 2417 | produceResponse := new(ProduceResponse) |
| 2418 | produceResponse.Version = 3 |
| 2419 | produceResponse.AddTopicPartition("test-topic", 0, ErrNoError) |
| 2420 | broker.Returns(produceResponse) |
| 2421 |
nothing calls this directly
no test coverage detected