(t *testing.T)
| 2261 | } |
| 2262 | |
| 2263 | func TestTxnProduceBumpEpoch(t *testing.T) { |
| 2264 | broker := NewMockBroker(t, 1) |
| 2265 | defer broker.Close() |
| 2266 | |
| 2267 | config := NewTestConfig() |
| 2268 | config.Producer.Idempotent = true |
| 2269 | config.Producer.Transaction.ID = "test" |
| 2270 | config.Version = V2_6_0_0 |
| 2271 | config.Producer.RequiredAcks = WaitForAll |
| 2272 | config.Net.MaxOpenRequests = 1 |
| 2273 | config.Producer.Return.Errors = false |
| 2274 | |
| 2275 | config.ApiVersionsRequest = false |
| 2276 | |
| 2277 | metadataLeader := new(MetadataResponse) |
| 2278 | metadataLeader.Version = 9 |
| 2279 | metadataLeader.ControllerID = broker.brokerID |
| 2280 | metadataLeader.AddBroker(broker.Addr(), broker.BrokerID()) |
| 2281 | metadataLeader.AddTopic("test-topic", ErrNoError) |
| 2282 | metadataLeader.AddTopicPartition("test-topic", 0, broker.BrokerID(), nil, nil, nil, ErrNoError) |
| 2283 | broker.Returns(metadataLeader) |
| 2284 | |
| 2285 | client, err := NewClient([]string{broker.Addr()}, config) |
| 2286 | require.NoError(t, err) |
| 2287 | defer client.Close() |
| 2288 | |
| 2289 | findCoordinatorResponse := FindCoordinatorResponse{ |
| 2290 | Coordinator: client.Brokers()[0], |
| 2291 | Err: ErrNoError, |
| 2292 | Version: 1, |
| 2293 | } |
| 2294 | broker.Returns(&findCoordinatorResponse) |
| 2295 | |
| 2296 | producerIdResponse := &InitProducerIDResponse{ |
| 2297 | Err: ErrNoError, |
| 2298 | ProducerID: 1000, |
| 2299 | ProducerEpoch: 0, |
| 2300 | Version: 3, |
| 2301 | } |
| 2302 | broker.Returns(producerIdResponse) |
| 2303 | |
| 2304 | ap, err := NewAsyncProducerFromClient(client) |
| 2305 | producer := ap.(*asyncProducer) |
| 2306 | require.NoError(t, err) |
| 2307 | defer ap.Close() |
| 2308 | require.Equal(t, int64(1000), producer.txnmgr.producerID) |
| 2309 | require.Equal(t, int16(0), producer.txnmgr.producerEpoch) |
| 2310 | |
| 2311 | addPartitionsToTxnResponse := &AddPartitionsToTxnResponse{ |
| 2312 | Errors: map[string][]*PartitionError{ |
| 2313 | "test-topic": { |
| 2314 | { |
| 2315 | Partition: 0, |
| 2316 | }, |
| 2317 | }, |
| 2318 | }, |
| 2319 | } |
| 2320 | broker.Returns(addPartitionsToTxnResponse) |
nothing calls this directly
no test coverage detected