Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAFKA-15915: Flaky ProducerIdManagerTest error injection fix (apache#…
…15605) testUnrecoverableErrors was flaky as the wanted error either affected the next block request (prefecthing) or just missed that. First I tried to wait for the background thread to be finished before setting the Errors.X. But then it consistently failed, because the generateProducerId call does prefetching too and after a successful producer id generation we set the error and expected that it will fail again with coordinator-load-in-progress exception but since the block was prefetched, it was able to serve us with a proper producer id. calling generateProducerId --> no current block exists, so requesting block --> CoordinatorLoadInProgressException asserting exception calling generateProducerId again --> prefetching, requesting the next block --> giving back the producer id from the first block asserting received producer id setting error -- waiting for the background callback(s) to be finished first calling generateProducerId, expecting CoordinatorLoadInProgressException, but --> works like 2), just the prefetching callback is failing due to the error we set before Note: without the waiting for the background thread completions the error setting could happened before the 2) step's callback or after that, the test was written in a way that it expected to happen before the cb. This was the point I realised that we need to have a queue to control the responses rather than trying to do it in the middle of the test method. Errors can be passed in a queue at creation of the mock id manager instead modifying on-the-fly. In the queue we're specifying Errors, how the background thread (which imitates the controllerChannel) should behave, return an error or a proper response and call the callback accordingly with that. I was able to simplify the mock manager id class as well, no need for the maybeRequestNextBlock overriding if the errors are handled this way via a queue. Reviewers: Igor Soarez <[email protected]>, Daniel Urban <[email protected]>, Viktor Somogyi-Vass <[email protected]>
- Loading branch information