Search in sources :

Example 1 with GroupAuthorizationException

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);
}
Also used : ConsumerGroupMetadata(org.apache.kafka.clients.consumer.ConsumerGroupMetadata) GroupAuthorizationException(org.apache.kafka.common.errors.GroupAuthorizationException) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) Test(org.junit.jupiter.api.Test)

Example 2 with GroupAuthorizationException

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());
}
Also used : GroupAuthorizationException(org.apache.kafka.common.errors.GroupAuthorizationException) Test(org.junit.jupiter.api.Test)

Example 3 with GroupAuthorizationException

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());
}
Also used : GroupAuthorizationException(org.apache.kafka.common.errors.GroupAuthorizationException) Test(org.junit.jupiter.api.Test)

Example 4 with GroupAuthorizationException

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);
}
Also used : GroupAuthorizationException(org.apache.kafka.common.errors.GroupAuthorizationException) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) Test(org.junit.Test)

Example 5 with GroupAuthorizationException

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);
}
Also used : GroupAuthorizationException(org.apache.kafka.common.errors.GroupAuthorizationException) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) Test(org.junit.Test)

Aggregations

GroupAuthorizationException (org.apache.kafka.common.errors.GroupAuthorizationException)6 OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)4 TopicPartition (org.apache.kafka.common.TopicPartition)4 Test (org.junit.jupiter.api.Test)4 ConsumerGroupMetadata (org.apache.kafka.clients.consumer.ConsumerGroupMetadata)2 Test (org.junit.Test)2