use of org.apache.kafka.common.errors.GroupAuthorizationException in project kafka by apache.
the class TransactionManagerTest method testGroupAuthorizationFailureInFindCoordinator.
@Test
public void testGroupAuthorizationFailureInFindCoordinator() {
doInitTransactions();
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(new TopicPartition("foo", 0), new OffsetAndMetadata(39L)), new ConsumerGroupMetadata(consumerGroupId));
prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, producerId, epoch);
runUntil(() -> !transactionManager.hasPartitionsToAdd());
prepareFindCoordinatorResponse(Errors.GROUP_AUTHORIZATION_FAILED, false, CoordinatorType.GROUP, consumerGroupId);
runUntil(transactionManager::hasError);
assertTrue(transactionManager.lastError() instanceof GroupAuthorizationException);
runUntil(sendOffsetsResult::isCompleted);
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) sendOffsetsResult.error();
assertEquals(consumerGroupId, exception.groupId());
assertAbortableError(GroupAuthorizationException.class);
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project kafka by apache.
the class CoordinatorStrategyTest method testFatalErrorOldLookupResponses.
@Test
public void testFatalErrorOldLookupResponses() {
CoordinatorKey group = CoordinatorKey.byTransactionalId("foo");
assertFatalOldLookup(group, Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED);
assertFatalOldLookup(group, Errors.UNKNOWN_SERVER_ERROR);
Throwable throwable = assertFatalOldLookup(group, Errors.GROUP_AUTHORIZATION_FAILED);
assertTrue(throwable instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) throwable;
assertEquals("foo", exception.groupId());
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project kafka by apache.
the class CoordinatorStrategyTest method testFatalErrorLookupResponses.
@Test
public void testFatalErrorLookupResponses() {
CoordinatorKey group = CoordinatorKey.byTransactionalId("foo");
assertFatalLookup(group, Errors.TRANSACTIONAL_ID_AUTHORIZATION_FAILED);
assertFatalLookup(group, Errors.UNKNOWN_SERVER_ERROR);
Throwable throwable = assertFatalLookup(group, Errors.GROUP_AUTHORIZATION_FAILED);
assertTrue(throwable instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) throwable;
assertEquals("foo", exception.groupId());
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testGroupAuthorizationFailureInTxnOffsetCommit.
@Test
public void testGroupAuthorizationFailureInTxnOffsetCommit() {
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.GROUP_AUTHORIZATION_FAILED));
// TxnOffsetCommit Handled
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof GroupAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) sendOffsetsResult.error();
assertEquals(consumerGroupId, exception.groupId());
assertAbortableError(GroupAuthorizationException.class);
}
use of org.apache.kafka.common.errors.GroupAuthorizationException in project apache-kafka-on-k8s by banzaicloud.
the class TransactionManagerTest method testGroupAuthorizationFailureInFindCoordinator.
@Test
public void testGroupAuthorizationFailureInFindCoordinator() {
final String consumerGroupId = "consumer";
final long pid = 13131L;
final short epoch = 1;
doInitTransactions(pid, epoch);
transactionManager.beginTransaction();
TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(new TopicPartition("foo", 0), 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.GROUP_AUTHORIZATION_FAILED, false, CoordinatorType.GROUP, consumerGroupId);
// FindCoordinator Failed
sender.run(time.milliseconds());
// TxnOffsetCommit Aborted
sender.run(time.milliseconds());
assertTrue(transactionManager.hasError());
assertTrue(transactionManager.lastError() instanceof GroupAuthorizationException);
assertTrue(sendOffsetsResult.isCompleted());
assertFalse(sendOffsetsResult.isSuccessful());
assertTrue(sendOffsetsResult.error() instanceof GroupAuthorizationException);
GroupAuthorizationException exception = (GroupAuthorizationException) sendOffsetsResult.error();
assertEquals(consumerGroupId, exception.groupId());
assertAbortableError(GroupAuthorizationException.class);
}
Aggregations