use of org.apache.kafka.common.errors.TransactionalIdAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testTransactionalIdAuthorizationFailureInAddOffsetsToTxn.
@Test
public void testTransactionalIdAuthorizationFailureInAddOffsetsToTxn() {
final String consumerGroupId = "consumer";
final long pid = 13131L;
final short epoch = 1;
final TopicPartition tp = new TopicPartition("foo", 0);
doInitTransactions(pid, epoch);
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp, new OffsetAndMetadata(39L)), consumerGroupId);
prepareAddOffsetsToTxnResponse(Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED, consumerGroupId, pid, epoch);
// AddOffsetsToTxn Handled
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof TransactionalIdAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof TransactionalIdAuthorizationException);
assertFatalError(TransactionalIdAuthorizationException.class);
}
use of org.apache.kafka.common.errors.TransactionalIdAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testTransactionalIdAuthorizationFailureInAddPartitions.
@Test
public void testTransactionalIdAuthorizationFailureInAddPartitions() {
final long pid = 13131L;
final short epoch = 1;
final TopicPartition tp = new TopicPartition("foo", 0);
doInitTransactions(pid, epoch);
transactionManager.beginTransaction();
transactionManager.maybeAddPartitionToTransaction(tp);
prepareAddPartitionsToTxn(tp, Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED);
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof TransactionalIdAuthorizationException);
assertFatalError(TransactionalIdAuthorizationException.class);
}
use of org.apache.kafka.common.errors.TransactionalIdAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testTransactionalIdAuthorizationFailureInTxnOffsetCommit.
@Test
public void testTransactionalIdAuthorizationFailureInTxnOffsetCommit() {
final String consumerGroupId = "consumer";
final long pid = 13131L;
final short epoch = 1;
final TopicPartition tp = new TopicPartition("foo", 0);
doInitTransactions(pid, epoch);
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp, new OffsetAndMetadata(39L)), consumerGroupId);
prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, pid, epoch);
// AddOffsetsToTxn Handled, TxnOffsetCommit Enqueued
sender.run(time.milliseconds());
// FindCoordinator Enqueued
sender.run(time.milliseconds());
prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.GROUP, consumerGroupId);
// FindCoordinator Returned
sender.run(time.milliseconds());
prepareTxnOffsetCommitResponse(consumerGroupId, pid, epoch, singletonMap(tp, Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED));
// TxnOffsetCommit Handled
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof TransactionalIdAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof TransactionalIdAuthorizationException);
assertFatalError(TransactionalIdAuthorizationException.class);
}
use of org.apache.kafka.common.errors.TransactionalIdAuthorizationException in project kafka by apache.
the class TransactionManagerTest method testTransactionalIdAuthorizationFailureInAddPartitions.
@Test
public void testTransactionalIdAuthorizationFailureInAddPartitions() {
final TopicPartition tp = new TopicPartition("foo", 0);
doInitTransactions();
transactionManager.beginTransaction();
transactionManager.maybeAddPartition(tp);
prepareAddPartitionsToTxn(tp, Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED);
runUntil(transactionManager::hasError);
assertTrue(transactionManager.lastError() instanceof TransactionalIdAuthorizationException);
assertFatalError(TransactionalIdAuthorizationException.class);
}
use of org.apache.kafka.common.errors.TransactionalIdAuthorizationException in project kafka by apache.
the class TransactionManagerTest method testTransactionalIdAuthorizationFailureInTxnOffsetCommit.
@Test
public void testTransactionalIdAuthorizationFailureInTxnOffsetCommit() {
final TopicPartition tp = new TopicPartition("foo", 0);
doInitTransactions();
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp, new OffsetAndMetadata(39L)), new ConsumerGroupMetadata(consumerGroupId));
prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, producerId, epoch);
runUntil(() -> !transactionManager.hasPartitionsToAdd());
prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.GROUP, consumerGroupId);
prepareTxnOffsetCommitResponse(consumerGroupId, producerId, epoch, singletonMap(tp, Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED));
runUntil(transactionManager::hasError);
assertTrue(transactionManager.lastError() instanceof TransactionalIdAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof TransactionalIdAuthorizationException);
assertFatalError(TransactionalIdAuthorizationException.class);
}
Aggregations