Skip to content

Commit

Permalink
HOTFIX: testInitTransactionTimeout should use prepareResponse instead…
Browse files Browse the repository at this point in the history
… of respond (apache#8179)

We have seen a flaky behavior due to using #respond instead of #prepareResponse call for the txn test.

Reviewers: Guozhang Wang <[email protected]>
  • Loading branch information
Boyang Chen authored Feb 27, 2020
1 parent fb5bd9e commit 399d18f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@
* A mock network client for use testing code
*/
public class MockClient implements KafkaClient {
public static final RequestMatcher ALWAYS_TRUE = new RequestMatcher() {
@Override
public boolean matches(AbstractRequest body) {
return true;
}
};
public static final RequestMatcher ALWAYS_TRUE = body -> true;

private static class FutureResponse {
private final Node node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,11 @@ public void testInitTransactionTimeout() {

assertThrows(TimeoutException.class, producer::initTransactions);

client.respond(FindCoordinatorResponse.prepareResponse(Errors.NONE, host1));
client.prepareResponse(
request -> request instanceof FindCoordinatorRequest &&
((FindCoordinatorRequest) request).data().keyType() == FindCoordinatorRequest.CoordinatorType.TRANSACTION.id(),
FindCoordinatorResponse.prepareResponse(Errors.NONE, host1));

client.prepareResponse(initProducerIdResponse(1L, (short) 5, Errors.NONE));

// retry initialization should work
Expand Down

0 comments on commit 399d18f

Please sign in to comment.