Search in sources :

Example 1 with TransactionalIdAuthorizationException

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

Example 2 with TransactionalIdAuthorizationException

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

Example 3 with TransactionalIdAuthorizationException

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

Example 4 with TransactionalIdAuthorizationException

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

Example 5 with TransactionalIdAuthorizationException

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

Aggregations

TransactionalIdAuthorizationException (org.apache.kafka.common.errors.TransactionalIdAuthorizationException)7 TopicPartition (org.apache.kafka.common.TopicPartition)6 OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)4 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 ConsumerGroupMetadata (org.apache.kafka.clients.consumer.ConsumerGroupMetadata)2 TransactionalIdNotFoundException (org.apache.kafka.common.errors.TransactionalIdNotFoundException)1