Search in sources :

Example 1 with GetBrokerConfigResponse

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

the class BrokerConfigResourceTest method getBrokerConfig_existingConfig_returnsConfig.

@Test
public void getBrokerConfig_existingConfig_returnsConfig() {
    expect(brokerConfigManager.getBrokerConfig(CLUSTER_ID, BROKER_ID, CONFIG_1.getName())).andReturn(completedFuture(Optional.of(CONFIG_1)));
    replay(brokerConfigManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    brokerConfigsResource.getBrokerConfig(response, CLUSTER_ID, BROKER_ID, CONFIG_1.getName());
    GetBrokerConfigResponse expected = GetBrokerConfigResponse.create(BrokerConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1/brokers/1/configs/config-1").setResourceName("crn:///kafka=cluster-1/broker=1/config=config-1").build()).setClusterId(CLUSTER_ID).setBrokerId(BROKER_ID).setName(CONFIG_1.getName()).setValue(CONFIG_1.getValue()).setDefault(CONFIG_1.isDefault()).setReadOnly(CONFIG_1.isReadOnly()).setSensitive(CONFIG_1.isSensitive()).setSource(CONFIG_1.getSource()).setSynonyms(CONFIG_1.getSynonyms().stream().map(ConfigSynonymData::fromConfigSynonym).collect(Collectors.toList())).build());
    assertEquals(expected, response.getValue());
}
Also used : ConfigSynonymData(io.confluent.kafkarest.entities.v3.ConfigSynonymData) FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) Test(org.junit.jupiter.api.Test)

Example 2 with GetBrokerConfigResponse

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

the class BrokerConfigsResourceIntegrationTest 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 + "/brokers/" + brokerId + "/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_BROKER_CONFIG).setSynonyms(Arrays.asList(ConfigSynonymData.builder().setName("max.connections").setValue("1000").setSource(ConfigSource.DYNAMIC_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_BROKER_CONFIG).setSynonyms(Arrays.asList(ConfigSynonymData.builder().setName("compression.type").setValue("gzip").setSource(ConfigSource.DYNAMIC_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) ListBrokerConfigsResponse(io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse) Response(javax.ws.rs.core.Response) GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) Test(org.junit.jupiter.api.Test)

Example 3 with GetBrokerConfigResponse

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

the class BrokerConfigsResourceIntegrationTest method getBrokerConfig_existingConfig_returnsConfig.

@Test
public void getBrokerConfig_existingConfig_returnsConfig() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    int brokerId = getBrokers().get(0).id();
    GetBrokerConfigResponse expected = 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("2147483647").setDefault(true).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DEFAULT_CONFIG).setSynonyms(singletonList(ConfigSynonymData.builder().setName("max.connections").setValue("2147483647").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    Response response = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/max.connections").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    GetBrokerConfigResponse actual = response.readEntity(GetBrokerConfigResponse.class);
    assertEquals(expected, actual);
}
Also used : GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) ListBrokerConfigsResponse(io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse) Response(javax.ws.rs.core.Response) GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) Test(org.junit.jupiter.api.Test)

Example 4 with GetBrokerConfigResponse

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

the class BrokerConfigsResourceIntegrationTest method updateAndReset_existingConfig_returnsDefaultUpdatedAndDefaultAgain.

@Test
public void updateAndReset_existingConfig_returnsDefaultUpdatedAndDefaultAgain() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    int brokerId = getBrokers().get(0).id();
    GetBrokerConfigResponse expectedBeforeUpdate = 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("producer").setDefault(true).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DEFAULT_CONFIG).setSynonyms(singletonList(ConfigSynonymData.builder().setName("compression.type").setValue("producer").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    Response responseBeforeUpdate = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), responseBeforeUpdate.getStatus());
    GetBrokerConfigResponse actualBeforeUpdate = responseBeforeUpdate.readEntity(GetBrokerConfigResponse.class);
    assertEquals(expectedBeforeUpdate, actualBeforeUpdate);
    Response updateResponse = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).put(Entity.entity("{\"value\":\"gzip\"}", MediaType.APPLICATION_JSON));
    assertEquals(Status.NO_CONTENT.getStatusCode(), updateResponse.getStatus());
    GetBrokerConfigResponse expectedAfterUpdate = 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_BROKER_CONFIG).setSynonyms(Arrays.asList(ConfigSynonymData.builder().setName("compression.type").setValue("gzip").setSource(ConfigSource.DYNAMIC_BROKER_CONFIG).build(), ConfigSynonymData.builder().setName("compression.type").setValue("producer").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    testWithRetry(() -> {
        Response responseAfterUpdate = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.OK.getStatusCode(), responseAfterUpdate.getStatus());
        GetBrokerConfigResponse actualAfterUpdate = responseAfterUpdate.readEntity(GetBrokerConfigResponse.class);
        assertEquals(expectedAfterUpdate, actualAfterUpdate);
    });
    Response resetResponse = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).delete();
    assertEquals(Status.NO_CONTENT.getStatusCode(), resetResponse.getStatus());
    GetBrokerConfigResponse expectedAfterReset = 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("producer").setDefault(true).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DEFAULT_CONFIG).setSynonyms(singletonList(ConfigSynonymData.builder().setName("compression.type").setValue("producer").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    testWithRetry(() -> {
        Response responseAfterReset = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.OK.getStatusCode(), responseAfterReset.getStatus());
        GetBrokerConfigResponse actualAfterReset = responseAfterReset.readEntity(GetBrokerConfigResponse.class);
        assertEquals(expectedAfterReset, actualAfterReset);
    });
}
Also used : GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) ListBrokerConfigsResponse(io.confluent.kafkarest.entities.v3.ListBrokerConfigsResponse) Response(javax.ws.rs.core.Response) GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) Test(org.junit.jupiter.api.Test)

Example 5 with GetBrokerConfigResponse

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

the class ClusterConfigsResourceIntegrationTest method updateAndReset_existingConfig_returnsDefaultUpdatedAndDefaultAgain.

@Test
public void updateAndReset_existingConfig_returnsDefaultUpdatedAndDefaultAgain() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    int brokerId = getBrokers().get(0).id();
    Response responseBeforeUpdate = request("/v3/clusters/" + clusterId + "/broker-configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.NOT_FOUND.getStatusCode(), responseBeforeUpdate.getStatus());
    GetBrokerConfigResponse expectedBrokerBeforeUpdate = 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("producer").setDefault(true).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DEFAULT_CONFIG).setSynonyms(singletonList(ConfigSynonymData.builder().setName("compression.type").setValue("producer").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    Response brokerResponseBeforeUpdate = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), brokerResponseBeforeUpdate.getStatus());
    GetBrokerConfigResponse actualBrokerBeforeUpdate = brokerResponseBeforeUpdate.readEntity(GetBrokerConfigResponse.class);
    assertEquals(expectedBrokerBeforeUpdate, actualBrokerBeforeUpdate);
    Response updateResponse = request("/v3/clusters/" + clusterId + "/broker-configs/compression.type").accept(MediaType.APPLICATION_JSON).put(Entity.entity("{\"value\":\"gzip\"}", MediaType.APPLICATION_JSON));
    assertEquals(Status.NO_CONTENT.getStatusCode(), updateResponse.getStatus());
    GetClusterConfigResponse expectedAfterUpdate = GetClusterConfigResponse.create(ClusterConfigData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId + "/broker-configs/compression.type").setResourceName("crn:///kafka=" + clusterId + "/broker-config=compression.type").build()).setClusterId(clusterId).setConfigType(ClusterConfig.Type.BROKER).setName("compression.type").setValue("gzip").setDefault(false).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DYNAMIC_DEFAULT_BROKER_CONFIG).setSynonyms(singletonList(ConfigSynonymData.builder().setName("compression.type").setValue("gzip").setSource(ConfigSource.DYNAMIC_DEFAULT_BROKER_CONFIG).build())).build());
    testWithRetry(() -> {
        Response responseAfterUpdate = request("/v3/clusters/" + clusterId + "/broker-configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.OK.getStatusCode(), responseAfterUpdate.getStatus());
        GetClusterConfigResponse actualAfterUpdate = responseAfterUpdate.readEntity(GetClusterConfigResponse.class);
        assertEquals(expectedAfterUpdate, actualAfterUpdate);
    });
    GetBrokerConfigResponse expectedBrokerAfterUpdate = 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());
    Response responseBrokerAfterUpdate = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), responseBrokerAfterUpdate.getStatus());
    GetBrokerConfigResponse actualBrokerAfterUpdate = responseBrokerAfterUpdate.readEntity(GetBrokerConfigResponse.class);
    assertEquals(expectedBrokerAfterUpdate, actualBrokerAfterUpdate);
    Response resetResponse = request("/v3/clusters/" + clusterId + "/broker-configs/compression.type").accept(MediaType.APPLICATION_JSON).delete();
    assertEquals(Status.NO_CONTENT.getStatusCode(), resetResponse.getStatus());
    testWithRetry(() -> {
        Response responseAfterReset = request("/v3/clusters/" + clusterId + "/broker-configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.NOT_FOUND.getStatusCode(), responseAfterReset.getStatus());
    });
    GetBrokerConfigResponse expectedBrokerAfterReset = 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("producer").setDefault(true).setReadOnly(false).setSensitive(false).setSource(ConfigSource.DEFAULT_CONFIG).setSynonyms(singletonList(ConfigSynonymData.builder().setName("compression.type").setValue("producer").setSource(ConfigSource.DEFAULT_CONFIG).build())).build());
    testWithRetry(() -> {
        Response brokerResponseAfterReset = request("/v3/clusters/" + clusterId + "/brokers/" + brokerId + "/configs/compression.type").accept(MediaType.APPLICATION_JSON).get();
        assertEquals(Status.OK.getStatusCode(), brokerResponseAfterReset.getStatus());
        GetBrokerConfigResponse actualBrokerAfterReset = brokerResponseAfterReset.readEntity(GetBrokerConfigResponse.class);
        assertEquals(expectedBrokerAfterReset, actualBrokerAfterReset);
    });
}
Also used : GetBrokerConfigResponse(io.confluent.kafkarest.entities.v3.GetBrokerConfigResponse) GetClusterConfigResponse(io.confluent.kafkarest.entities.v3.GetClusterConfigResponse) Response(javax.ws.rs.core.Response) GetClusterConfigResponse(io.confluent.kafkarest.entities.v3.GetClusterConfigResponse) 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