jolshan commented on code in PR #12149:
URL: https://github.com/apache/kafka/pull/12149#discussion_r1166062401
##########
clients/src/test/java/org/apache/kafka/clients/producer/KafkaProducerTest.java:
##########
@@ -1237,6 +1238,34 @@ public void testInitTransactionWhileThrottled() {
}
}
+ @Test
+ public void testClusterAuthorizationFailure() throws Exception {
+ int maxBlockMs = 500;
+
+ Map<String, Object> configs = new HashMap<>();
+ configs.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, maxBlockMs);
+ configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9000");
+ configs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
+ configs.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "some-txn");
+
+ Time time = new MockTime(1);
+ MetadataResponse initialUpdateResponse =
RequestTestUtils.metadataUpdateWith(1, singletonMap("topic", 1));
+ ProducerMetadata metadata = newMetadata(500, Long.MAX_VALUE);
+
+ MockClient client = new MockClient(time, metadata);
+ client.updateMetadata(initialUpdateResponse);
+
+
client.prepareResponse(FindCoordinatorResponse.prepareResponse(Errors.NONE,
"some-txn", NODE));
+ client.prepareResponse(initProducerIdResponse(1L, (short) 5,
Errors.CLUSTER_AUTHORIZATION_FAILED));
+ Producer<String, String> producer = kafkaProducer(configs, new
StringSerializer(),
+ new StringSerializer(), metadata, client, null, time);
+ assertThrows(ClusterAuthorizationException.class,
producer::initTransactions);
+
+ // retry initTransactions after the ClusterAuthorizationException not
being thrown
+ client.prepareResponse(initProducerIdResponse(1L, (short) 5,
Errors.NONE));
+ TestUtils.retryOnExceptionWithTimeout(1000, 100,
producer::initTransactions);
Review Comment:
Are we fully validating the request is successful? Is that what the
TestUtils method does here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]