Skip to content

Commit

Permalink
Merge pull request #532 from Shopify/flaky-producer-test
Browse files Browse the repository at this point in the history
Fix the flakiest producer test
  • Loading branch information
eapache committed Sep 1, 2015
2 parents cac0407 + 737294c commit b38baa0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions async_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b38baa0

Please sign in to comment.