use of org.apache.kafka.common.errors.NotCoordinatorException in project apache-kafka-on-k8s by banzaicloud.
the class RequestResponseTest method testSerialization.
@Test
public void testSerialization() throws Exception {
checkRequest(createFindCoordinatorRequest(0));
checkRequest(createFindCoordinatorRequest(1));
checkErrorResponse(createFindCoordinatorRequest(0), new UnknownServerException());
checkErrorResponse(createFindCoordinatorRequest(1), new UnknownServerException());
checkResponse(createFindCoordinatorResponse(), 0);
checkResponse(createFindCoordinatorResponse(), 1);
checkRequest(createControlledShutdownRequest());
checkResponse(createControlledShutdownResponse(), 1);
checkErrorResponse(createControlledShutdownRequest(), new UnknownServerException());
checkErrorResponse(createControlledShutdownRequest(0), new UnknownServerException());
checkRequest(createFetchRequest(4));
checkResponse(createFetchResponse(), 4);
List<TopicPartition> toForgetTopics = new ArrayList<>();
toForgetTopics.add(new TopicPartition("foo", 0));
toForgetTopics.add(new TopicPartition("foo", 2));
toForgetTopics.add(new TopicPartition("bar", 0));
checkRequest(createFetchRequest(7, new FetchMetadata(123, 456), toForgetTopics));
checkResponse(createFetchResponse(123), 7);
checkResponse(createFetchResponse(Errors.FETCH_SESSION_ID_NOT_FOUND, 123), 7);
checkErrorResponse(createFetchRequest(4), new UnknownServerException());
checkRequest(createHeartBeatRequest());
checkErrorResponse(createHeartBeatRequest(), new UnknownServerException());
checkResponse(createHeartBeatResponse(), 0);
checkRequest(createJoinGroupRequest(1));
checkErrorResponse(createJoinGroupRequest(0), new UnknownServerException());
checkErrorResponse(createJoinGroupRequest(1), new UnknownServerException());
checkResponse(createJoinGroupResponse(), 0);
checkRequest(createLeaveGroupRequest());
checkErrorResponse(createLeaveGroupRequest(), new UnknownServerException());
checkResponse(createLeaveGroupResponse(), 0);
checkRequest(createListGroupsRequest());
checkErrorResponse(createListGroupsRequest(), new UnknownServerException());
checkResponse(createListGroupsResponse(), 0);
checkRequest(createDescribeGroupRequest());
checkErrorResponse(createDescribeGroupRequest(), new UnknownServerException());
checkResponse(createDescribeGroupResponse(), 0);
checkRequest(createDeleteGroupsRequest());
checkErrorResponse(createDeleteGroupsRequest(), new UnknownServerException());
checkResponse(createDeleteGroupsResponse(), 0);
checkRequest(createListOffsetRequest(1));
checkErrorResponse(createListOffsetRequest(1), new UnknownServerException());
checkResponse(createListOffsetResponse(1), 1);
checkRequest(createListOffsetRequest(2));
checkErrorResponse(createListOffsetRequest(2), new UnknownServerException());
checkResponse(createListOffsetResponse(2), 2);
checkRequest(MetadataRequest.Builder.allTopics().build((short) 2));
checkRequest(createMetadataRequest(1, singletonList("topic1")));
checkErrorResponse(createMetadataRequest(1, singletonList("topic1")), new UnknownServerException());
checkResponse(createMetadataResponse(), 2);
checkErrorResponse(createMetadataRequest(2, singletonList("topic1")), new UnknownServerException());
checkResponse(createMetadataResponse(), 3);
checkErrorResponse(createMetadataRequest(3, singletonList("topic1")), new UnknownServerException());
checkResponse(createMetadataResponse(), 4);
checkErrorResponse(createMetadataRequest(4, singletonList("topic1")), new UnknownServerException());
checkRequest(createOffsetCommitRequest(2));
checkErrorResponse(createOffsetCommitRequest(2), new UnknownServerException());
checkResponse(createOffsetCommitResponse(), 0);
checkRequest(OffsetFetchRequest.forAllPartitions("group1"));
checkErrorResponse(OffsetFetchRequest.forAllPartitions("group1"), new NotCoordinatorException("Not Coordinator"));
checkRequest(createOffsetFetchRequest(0));
checkRequest(createOffsetFetchRequest(1));
checkRequest(createOffsetFetchRequest(2));
checkRequest(OffsetFetchRequest.forAllPartitions("group1"));
checkErrorResponse(createOffsetFetchRequest(0), new UnknownServerException());
checkErrorResponse(createOffsetFetchRequest(1), new UnknownServerException());
checkErrorResponse(createOffsetFetchRequest(2), new UnknownServerException());
checkResponse(createOffsetFetchResponse(), 0);
checkRequest(createProduceRequest(2));
checkErrorResponse(createProduceRequest(2), new UnknownServerException());
checkRequest(createProduceRequest(3));
checkErrorResponse(createProduceRequest(3), new UnknownServerException());
checkResponse(createProduceResponse(), 2);
checkRequest(createStopReplicaRequest(true));
checkRequest(createStopReplicaRequest(false));
checkErrorResponse(createStopReplicaRequest(true), new UnknownServerException());
checkResponse(createStopReplicaResponse(), 0);
checkRequest(createLeaderAndIsrRequest());
checkErrorResponse(createLeaderAndIsrRequest(), new UnknownServerException());
checkResponse(createLeaderAndIsrResponse(), 0);
checkRequest(createSaslHandshakeRequest());
checkErrorResponse(createSaslHandshakeRequest(), new UnknownServerException());
checkResponse(createSaslHandshakeResponse(), 0);
checkRequest(createApiVersionRequest());
checkErrorResponse(createApiVersionRequest(), new UnknownServerException());
checkResponse(createApiVersionResponse(), 0);
checkRequest(createCreateTopicRequest(0));
checkErrorResponse(createCreateTopicRequest(0), new UnknownServerException());
checkResponse(createCreateTopicResponse(), 0);
checkRequest(createCreateTopicRequest(1));
checkErrorResponse(createCreateTopicRequest(1), new UnknownServerException());
checkResponse(createCreateTopicResponse(), 1);
checkRequest(createDeleteTopicsRequest());
checkErrorResponse(createDeleteTopicsRequest(), new UnknownServerException());
checkResponse(createDeleteTopicsResponse(), 0);
checkRequest(createInitPidRequest());
checkErrorResponse(createInitPidRequest(), new UnknownServerException());
checkResponse(createInitPidResponse(), 0);
checkRequest(createAddPartitionsToTxnRequest());
checkResponse(createAddPartitionsToTxnResponse(), 0);
checkErrorResponse(createAddPartitionsToTxnRequest(), new UnknownServerException());
checkRequest(createAddOffsetsToTxnRequest());
checkResponse(createAddOffsetsToTxnResponse(), 0);
checkErrorResponse(createAddOffsetsToTxnRequest(), new UnknownServerException());
checkRequest(createEndTxnRequest());
checkResponse(createEndTxnResponse(), 0);
checkErrorResponse(createEndTxnRequest(), new UnknownServerException());
checkRequest(createWriteTxnMarkersRequest());
checkResponse(createWriteTxnMarkersResponse(), 0);
checkErrorResponse(createWriteTxnMarkersRequest(), new UnknownServerException());
checkRequest(createTxnOffsetCommitRequest());
checkResponse(createTxnOffsetCommitResponse(), 0);
checkErrorResponse(createTxnOffsetCommitRequest(), new UnknownServerException());
checkOlderFetchVersions();
checkResponse(createMetadataResponse(), 0);
checkResponse(createMetadataResponse(), 1);
checkErrorResponse(createMetadataRequest(1, singletonList("topic1")), new UnknownServerException());
checkRequest(createOffsetCommitRequest(0));
checkErrorResponse(createOffsetCommitRequest(0), new UnknownServerException());
checkRequest(createOffsetCommitRequest(1));
checkErrorResponse(createOffsetCommitRequest(1), new UnknownServerException());
checkRequest(createJoinGroupRequest(0));
checkRequest(createUpdateMetadataRequest(0, null));
checkErrorResponse(createUpdateMetadataRequest(0, null), new UnknownServerException());
checkRequest(createUpdateMetadataRequest(1, null));
checkRequest(createUpdateMetadataRequest(1, "rack1"));
checkErrorResponse(createUpdateMetadataRequest(1, null), new UnknownServerException());
checkRequest(createUpdateMetadataRequest(2, "rack1"));
checkRequest(createUpdateMetadataRequest(2, null));
checkErrorResponse(createUpdateMetadataRequest(2, "rack1"), new UnknownServerException());
checkRequest(createUpdateMetadataRequest(3, "rack1"));
checkRequest(createUpdateMetadataRequest(3, null));
checkErrorResponse(createUpdateMetadataRequest(3, "rack1"), new UnknownServerException());
checkResponse(createUpdateMetadataResponse(), 0);
checkRequest(createListOffsetRequest(0));
checkErrorResponse(createListOffsetRequest(0), new UnknownServerException());
checkResponse(createListOffsetResponse(0), 0);
checkRequest(createLeaderEpochRequest());
checkResponse(createLeaderEpochResponse(), 0);
checkErrorResponse(createLeaderEpochRequest(), new UnknownServerException());
checkRequest(createAddPartitionsToTxnRequest());
checkErrorResponse(createAddPartitionsToTxnRequest(), new UnknownServerException());
checkResponse(createAddPartitionsToTxnResponse(), 0);
checkRequest(createAddOffsetsToTxnRequest());
checkErrorResponse(createAddOffsetsToTxnRequest(), new UnknownServerException());
checkResponse(createAddOffsetsToTxnResponse(), 0);
checkRequest(createEndTxnRequest());
checkErrorResponse(createEndTxnRequest(), new UnknownServerException());
checkResponse(createEndTxnResponse(), 0);
checkRequest(createWriteTxnMarkersRequest());
checkErrorResponse(createWriteTxnMarkersRequest(), new UnknownServerException());
checkResponse(createWriteTxnMarkersResponse(), 0);
checkRequest(createTxnOffsetCommitRequest());
checkErrorResponse(createTxnOffsetCommitRequest(), new UnknownServerException());
checkResponse(createTxnOffsetCommitResponse(), 0);
checkRequest(createListAclsRequest());
checkErrorResponse(createListAclsRequest(), new SecurityDisabledException("Security is not enabled."));
checkResponse(createDescribeAclsResponse(), ApiKeys.DESCRIBE_ACLS.latestVersion());
checkRequest(createCreateAclsRequest());
checkErrorResponse(createCreateAclsRequest(), new SecurityDisabledException("Security is not enabled."));
checkResponse(createCreateAclsResponse(), ApiKeys.CREATE_ACLS.latestVersion());
checkRequest(createDeleteAclsRequest());
checkErrorResponse(createDeleteAclsRequest(), new SecurityDisabledException("Security is not enabled."));
checkResponse(createDeleteAclsResponse(), ApiKeys.DELETE_ACLS.latestVersion());
checkRequest(createAlterConfigsRequest());
checkErrorResponse(createAlterConfigsRequest(), new UnknownServerException());
checkResponse(createAlterConfigsResponse(), 0);
checkRequest(createDescribeConfigsRequest(0));
checkRequest(createDescribeConfigsRequestWithConfigEntries(0));
checkErrorResponse(createDescribeConfigsRequest(0), new UnknownServerException());
checkResponse(createDescribeConfigsResponse(), 0);
checkRequest(createDescribeConfigsRequest(1));
checkRequest(createDescribeConfigsRequestWithConfigEntries(1));
checkErrorResponse(createDescribeConfigsRequest(1), new UnknownServerException());
checkResponse(createDescribeConfigsResponse(), 1);
checkDescribeConfigsResponseVersions();
checkRequest(createCreatePartitionsRequest());
checkRequest(createCreatePartitionsRequestWithAssignments());
checkErrorResponse(createCreatePartitionsRequest(), new InvalidTopicException());
checkResponse(createCreatePartitionsResponse(), 0);
checkRequest(createCreateTokenRequest());
checkErrorResponse(createCreateTokenRequest(), new UnknownServerException());
checkResponse(createCreateTokenResponse(), 0);
checkRequest(createDescribeTokenRequest());
checkErrorResponse(createDescribeTokenRequest(), new UnknownServerException());
checkResponse(createDescribeTokenResponse(), 0);
checkRequest(createExpireTokenRequest());
checkErrorResponse(createExpireTokenRequest(), new UnknownServerException());
checkResponse(createExpireTokenResponse(), 0);
checkRequest(createRenewTokenRequest());
checkErrorResponse(createRenewTokenRequest(), new UnknownServerException());
checkResponse(createRenewTokenResponse(), 0);
}
Aggregations