From 737294ce64d38c71bc24921cf33a67e544d1d0ac Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Tue, 1 Sep 2015 08:02:14 -0400 Subject: [PATCH] Fix the flakiest producer test This should fix the last remaining annoyingly-flaky test after all the work Maxim did on the flaky consumer tests. I hope. --- async_producer_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/async_producer_test.go b/async_producer_test.go index 403456839..7febbb7de 100644 --- a/async_producer_test.go +++ b/async_producer_test.go @@ -580,20 +580,23 @@ func TestAsyncProducerFlusherRetryCondition(t *testing.T) { prodNotLeader.AddTopicPartition("my_topic", 0, ErrNotLeaderForPartition) leader.Returns(prodNotLeader) + time.Sleep(50 * time.Millisecond) + + leader.SetHandlerByMap(map[string]MockResponse{ + "ProduceRequest": newMockProduceResponse(t). + SetError("my_topic", 0, ErrNoError), + }) + // tell partition 0 to go to that broker again seedBroker.Returns(metadataResponse) // succeed this time - prodSuccess := new(ProduceResponse) - prodSuccess.AddTopicPartition("my_topic", 0, ErrNoError) - leader.Returns(prodSuccess) expectResults(t, producer, 5, 0) // put five more through for i := 0; i < 5; i++ { producer.Input() <- &ProducerMessage{Topic: "my_topic", Key: nil, Value: StringEncoder(TestMessage), Partition: 0} } - leader.Returns(prodSuccess) expectResults(t, producer, 5, 0) // shutdown