Search in sources :

Example 1 with DescribeClusterResponseData

use of org.apache.kafka.common.message.DescribeClusterResponseData in project kafka by apache.

the class KafkaAdminClientTest method testDescribeClusterHandleError.

@Test
public void testDescribeClusterHandleError() {
    try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(mockCluster(4, 0), AdminClientConfig.RETRIES_CONFIG, "2")) {
        env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
        // Prepare the describe cluster response used for the first describe cluster
        String errorMessage = "my error";
        env.kafkaClient().prepareResponse(new DescribeClusterResponse(new DescribeClusterResponseData().setErrorCode(Errors.INVALID_REQUEST.code()).setErrorMessage(errorMessage)));
        final DescribeClusterResult result = env.adminClient().describeCluster();
        TestUtils.assertFutureThrows(result.clusterId(), InvalidRequestException.class, errorMessage);
        TestUtils.assertFutureThrows(result.controller(), InvalidRequestException.class, errorMessage);
        TestUtils.assertFutureThrows(result.nodes(), InvalidRequestException.class, errorMessage);
        TestUtils.assertFutureThrows(result.authorizedOperations(), InvalidRequestException.class, errorMessage);
    }
}
Also used : DescribeClusterResponseData(org.apache.kafka.common.message.DescribeClusterResponseData) DescribeClusterResponse(org.apache.kafka.common.requests.DescribeClusterResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with DescribeClusterResponseData

use of org.apache.kafka.common.message.DescribeClusterResponseData in project kafka by apache.

the class KafkaAdminClientTest method prepareDescribeClusterResponse.

private static DescribeClusterResponse prepareDescribeClusterResponse(int throttleTimeMs, Collection<Node> brokers, String clusterId, int controllerId, int clusterAuthorizedOperations) {
    DescribeClusterResponseData data = new DescribeClusterResponseData().setErrorCode(Errors.NONE.code()).setThrottleTimeMs(throttleTimeMs).setControllerId(controllerId).setClusterId(clusterId).setClusterAuthorizedOperations(clusterAuthorizedOperations);
    brokers.forEach(broker -> data.brokers().add(new DescribeClusterBroker().setHost(broker.host()).setPort(broker.port()).setBrokerId(broker.id()).setRack(broker.rack())));
    return new DescribeClusterResponse(data);
}
Also used : DescribeClusterResponseData(org.apache.kafka.common.message.DescribeClusterResponseData) DescribeClusterResponse(org.apache.kafka.common.requests.DescribeClusterResponse) DescribeClusterBroker(org.apache.kafka.common.message.DescribeClusterResponseData.DescribeClusterBroker)

Aggregations

DescribeClusterResponseData (org.apache.kafka.common.message.DescribeClusterResponseData)2 DescribeClusterResponse (org.apache.kafka.common.requests.DescribeClusterResponse)2 DescribeClusterBroker (org.apache.kafka.common.message.DescribeClusterResponseData.DescribeClusterBroker)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1