(t *testing.T)
| 2550 | } |
| 2551 | |
| 2552 | func TestTxnProduceRecordWithAbort(t *testing.T) { |
| 2553 | broker := NewMockBroker(t, 1) |
| 2554 | defer broker.Close() |
| 2555 | |
| 2556 | config := NewTestConfig() |
| 2557 | config.Producer.Idempotent = true |
| 2558 | config.Producer.Transaction.ID = "test" |
| 2559 | config.Version = V0_11_0_0 |
| 2560 | config.Producer.RequiredAcks = WaitForAll |
| 2561 | config.Net.MaxOpenRequests = 1 |
| 2562 | |
| 2563 | metadataLeader := new(MetadataResponse) |
| 2564 | metadataLeader.Version = 4 |
| 2565 | metadataLeader.ControllerID = broker.brokerID |
| 2566 | metadataLeader.AddBroker(broker.Addr(), broker.BrokerID()) |
| 2567 | metadataLeader.AddTopic("test-topic", ErrNoError) |
| 2568 | metadataLeader.AddTopicPartition("test-topic", 0, broker.BrokerID(), nil, nil, nil, ErrNoError) |
| 2569 | broker.Returns(metadataLeader) |
| 2570 | |
| 2571 | client, err := NewClient([]string{broker.Addr()}, config) |
| 2572 | require.NoError(t, err) |
| 2573 | defer client.Close() |
| 2574 | |
| 2575 | findCoordinatorResponse := FindCoordinatorResponse{ |
| 2576 | Coordinator: client.Brokers()[0], |
| 2577 | Err: ErrNoError, |
| 2578 | Version: 1, |
| 2579 | } |
| 2580 | broker.Returns(&findCoordinatorResponse) |
| 2581 | |
| 2582 | producerIdResponse := &InitProducerIDResponse{ |
| 2583 | Err: ErrNoError, |
| 2584 | ProducerID: 1, |
| 2585 | ProducerEpoch: 0, |
| 2586 | } |
| 2587 | broker.Returns(producerIdResponse) |
| 2588 | |
| 2589 | ap, err := NewAsyncProducerFromClient(client) |
| 2590 | producer := ap.(*asyncProducer) |
| 2591 | require.NoError(t, err) |
| 2592 | defer ap.Close() |
| 2593 | |
| 2594 | broker.Returns(&AddPartitionsToTxnResponse{ |
| 2595 | Errors: map[string][]*PartitionError{ |
| 2596 | "test-topic": { |
| 2597 | { |
| 2598 | Partition: 0, |
| 2599 | Err: ErrNoError, |
| 2600 | }, |
| 2601 | }, |
| 2602 | }, |
| 2603 | }) |
| 2604 | |
| 2605 | produceResponse := new(ProduceResponse) |
| 2606 | produceResponse.Version = 3 |
| 2607 | produceResponse.AddTopicPartition("test-topic", 0, ErrNoError) |
| 2608 | broker.Returns(produceResponse) |
| 2609 |
nothing calls this directly
no test coverage detected