Search in sources :

Example 6 with GetBrokerConfigResponse

use of io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse in project kafka-rest by confluentinc.

the class ClusterConfigsResourceIntegrationTest method alterConfigBatch_withExistingConfig.

@Test
public void alterConfigBatch_withExistingConfig() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    int brokerId = getBrokers().get(0).id();
    Response updateResponse = request("/v3/clusters/" + clusterId + "/broker-configs:alter").accept(MediaType.APPLICATION_JSON).post(Entity.entity("{\"data\":[" + "{\"name\": \"max.connections\",\"value\":\"1000\"}," + "{\"name\": \"compression.type\",\"value\":\"gzip\"}]}", MediaType.APPLICATION_JSON));
    assertEquals(Status.NO_CONTENT.getStatusCode(), updateResponse.getStatus());
    GetBrokerConfigResponse expectedAfterUpdate1 = GetBrokerConfigResponse.create(BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/max.connections").setResourceName("crn:///kafka=" + clusterId + "/broker=" + brokerId + "/config=max.connections").build()).setClusterId(clusterId).setBrokerId(brokerId).setName("max.connections").setValue("1000").setDefault(false).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DYNAMIC_DEFAULT_BROKER_CONFIG).setSynonyms(Arrays.asList(ConfigSynonymData.builder().setName("max.connections").setValue("1000").setSource(ConfigSource.DYNAMIC_DEFAULT_BROKER_CONFIG).build(), ConfigSynonymData.builder().setName("max.connections").setValue("2147483647").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    GetBrokerConfigResponse expectedAfterUpdate2 = GetBrokerConfigResponse.create(BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").setResourceName("crn:///kafka=" + clusterId + "/broker=" + brokerId + "/config=compression.type").build()).setClusterId(clusterId).setBrokerId(brokerId).setName("compression.type").setValue("gzip").setDefault(false).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DYNAMIC_DEFAULT_BROKER_CONFIG).setSynonyms(Arrays.asList(ConfigSynonymData.builder().setName("compression.type").setValue("gzip").setSource(ConfigSource.DYNAMIC_DEFAULT_BROKER_CONFIG).build(), ConfigSynonymData.builder().setName("compression.type").setValue("producer").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    testWithRetry(() -> {
        Response responseAfterUpdate1 = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/max.connections").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.OK.getStatusCode(), responseAfterUpdate1.getStatus());
        GetBrokerConfigResponse actualResponseAfterUpdate1 = responseAfterUpdate1.readEntity(GetBrokerConfigResponse.class);
        assertEquals(expectedAfterUpdate1, actualResponseAfterUpdate1);
    });
    testWithRetry(() -> {
        Response responseAfterUpdate2 = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.OK.getStatusCode(), responseAfterUpdate2.getStatus());
        GetBrokerConfigResponse actualResponseAfterUpdate2 = responseAfterUpdate2.readEntity(GetBrokerConfigResponse.class);
        assertEquals(expectedAfterUpdate2, actualResponseAfterUpdate2);
    });
}
Also used : GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) GetClusterConfigResponse(io.confluent.kafkarest.entities.v3.GetClusterConfigResponse) Response(javax.ws.rs.core.Response) GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) Test(org.junit.jupiter.api.Test)

Aggregations

GetBrokerConfigResponse (io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse)6 Test (org.junit.jupiter.api.Test)6 Response (javax.ws.rs.core.Response)5 ListBrokerConfigsResponse (io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse)3 GetClusterConfigResponse (io.confluent.kafkarest.entities.v3.GetClusterConfigResponse)2 ConfigSynonymData (io.confluent.kafkarest.entities.v3.ConfigSynonymData)1 FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)1