Search in sources :

Example 1 with CruiseControlSpec

use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.

the class CruiseControlConfigurationST method testDeployAndUnDeployCruiseControl.

@ParallelNamespaceTest
void testDeployAndUnDeployCruiseControl(ExtensionContext extensionContext) throws IOException {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaWithCruiseControl(clusterName, 3, 3).build());
    Map<String, String> kafkaPods = PodUtils.podSnapshot(namespaceName, kafkaSelector);
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        LOGGER.info("Removing Cruise Control to the classic Kafka.");
        kafka.getSpec().setCruiseControl(null);
    }, namespaceName);
    kafkaPods = RollingUpdateUtils.waitTillComponentHasRolled(namespaceName, kafkaSelector, 3, kafkaPods);
    LOGGER.info("Verifying that in {} is not present in the Kafka cluster", Constants.CRUISE_CONTROL_NAME);
    assertThat(KafkaResource.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getSpec().getCruiseControl(), nullValue());
    LOGGER.info("Verifying that {} pod is not present", clusterName + "-cruise-control-");
    PodUtils.waitUntilPodStabilityReplicasCount(namespaceName, clusterName + "-cruise-control-", 0);
    LOGGER.info("Verifying that in Kafka config map there is no configuration to cruise control metric reporter");
    assertThrows(WaitException.class, () -> CruiseControlUtils.verifyCruiseControlMetricReporterConfigurationInKafkaConfigMapIsPresent(CruiseControlUtils.getKafkaCruiseControlMetricsReporterConfiguration(namespaceName, clusterName)));
    LOGGER.info("Cruise Control topics will not be deleted and will stay in the Kafka cluster");
    CruiseControlUtils.verifyThatCruiseControlTopicsArePresent(namespaceName);
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        LOGGER.info("Adding Cruise Control to the classic Kafka.");
        kafka.getSpec().setCruiseControl(new CruiseControlSpec());
    }, namespaceName);
    RollingUpdateUtils.waitTillComponentHasRolled(namespaceName, kafkaSelector, 3, kafkaPods);
    LOGGER.info("Verifying that in Kafka config map there is configuration to cruise control metric reporter");
    CruiseControlUtils.verifyCruiseControlMetricReporterConfigurationInKafkaConfigMapIsPresent(CruiseControlUtils.getKafkaCruiseControlMetricsReporterConfiguration(namespaceName, clusterName));
    LOGGER.info("Verifying that {} topics are created after CC is instantiated.", Constants.CRUISE_CONTROL_NAME);
    CruiseControlUtils.verifyThatCruiseControlTopicsArePresent(namespaceName);
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Example 2 with CruiseControlSpec

use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.

the class CruiseControlConfigurationST method testConfigurationDiskChangeDoNotTriggersRollingUpdateOfKafkaPods.

@ParallelNamespaceTest
void testConfigurationDiskChangeDoNotTriggersRollingUpdateOfKafkaPods(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaWithCruiseControl(clusterName, 3, 3).build());
    Map<String, String> kafkaSnapShot = PodUtils.podSnapshot(namespaceName, kafkaSelector);
    Map<String, String> cruiseControlSnapShot = DeploymentUtils.depSnapshot(namespaceName, CruiseControlResources.deploymentName(clusterName));
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        LOGGER.info("Changing the broker capacity of the cruise control");
        CruiseControlSpec cruiseControl = new CruiseControlSpecBuilder().withNewBrokerCapacity().withOutboundNetwork("20KB/s").endBrokerCapacity().build();
        kafka.getSpec().setCruiseControl(cruiseControl);
    }, namespaceName);
    LOGGER.info("Verifying that CC pod is rolling, because of change size of disk");
    DeploymentUtils.waitTillDepHasRolled(namespaceName, CruiseControlResources.deploymentName(clusterName), 1, cruiseControlSnapShot);
    LOGGER.info("Verifying that Kafka pods did not roll");
    RollingUpdateUtils.waitForNoRollingUpdate(namespaceName, kafkaSelector, kafkaSnapShot);
    LOGGER.info("Verifying new configuration in the Kafka CR");
    assertThat(KafkaResource.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getSpec().getCruiseControl().getBrokerCapacity().getOutboundNetwork(), is("20KB/s"));
    CruiseControlUtils.verifyThatCruiseControlTopicsArePresent(namespaceName);
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Example 3 with CruiseControlSpec

use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.

the class CruiseControlTest method testProbeConfiguration.

@ParallelTest
public void testProbeConfiguration() {
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withNewLivenessProbe().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).endLivenessProbe().withNewReadinessProbe().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).endReadinessProbe().build();
    Kafka resource = createKafka(cruiseControlSpec);
    CruiseControl cc = createCruiseControl(resource);
    Deployment dep = cc.generateDeployment(true, null, null, null);
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    // checks on the main Cruise Control container
    Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().orElseThrow();
    assertThat(ccContainer.getImage(), is(cc.image));
    assertThat(ccContainer.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay)));
    assertThat(ccContainer.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout)));
    assertThat(ccContainer.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay)));
    assertThat(ccContainer.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout)));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 4 with CruiseControlSpec

use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.

the class CruiseControlTest method testApiSecurity.

public void testApiSecurity(Boolean apiAuthEnabled, Boolean apiSslEnabled) {
    String e1Key = CruiseControl.ENV_VAR_API_AUTH_ENABLED;
    String e1Value = apiAuthEnabled.toString();
    EnvVar e1 = new EnvVar(e1Key, e1Value, null);
    String e2Key = CruiseControl.ENV_VAR_API_SSL_ENABLED;
    String e2Value = apiSslEnabled.toString();
    EnvVar e2 = new EnvVar(e2Key, e2Value, null);
    Map<String, Object> config = ccConfig;
    config.put(CruiseControlConfigurationParameters.CRUISE_CONTROL_WEBSERVER_SECURITY_ENABLE.getValue(), apiAuthEnabled);
    config.put(CruiseControlConfigurationParameters.CRUISE_CONTROL_WEBSERVER_SSL_ENABLE.getValue(), apiSslEnabled);
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withConfig(config).build();
    Kafka resource = createKafka(cruiseControlSpec);
    CruiseControl cc = createCruiseControl(resource);
    Deployment dep = cc.generateDeployment(true, null, null, null);
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    // checks on the main Cruise Control container
    Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().get();
    List<EnvVar> envVarList = ccContainer.getEnv();
    assertThat(envVarList.contains(e1), is(true));
    assertThat(envVarList.contains(e2), is(true));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 5 with CruiseControlSpec

use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.

the class CruiseControlTest method testResources.

@ParallelTest
public void testResources() {
    Map<String, Quantity> requests = new HashMap<>(2);
    requests.put("cpu", new Quantity("250m"));
    requests.put("memory", new Quantity("512Mi"));
    Map<String, Quantity> limits = new HashMap<>(2);
    limits.put("cpu", new Quantity("500m"));
    limits.put("memory", new Quantity("1024Mi"));
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withResources(new ResourceRequirementsBuilder().withLimits(limits).withRequests(requests).build()).build();
    Kafka resource = createKafka(cruiseControlSpec);
    CruiseControl cc = createCruiseControl(resource);
    Deployment dep = cc.generateDeployment(true, null, null, null);
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().orElseThrow();
    assertThat(ccContainer.getResources().getLimits(), is(limits));
    assertThat(ccContainer.getResources().getRequests(), is(requests));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) HashMap(java.util.HashMap) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) Quantity(io.fabric8.kubernetes.api.model.Quantity) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

CruiseControlSpec (io.strimzi.api.kafka.model.CruiseControlSpec)38 CruiseControlSpecBuilder (io.strimzi.api.kafka.model.CruiseControlSpecBuilder)34 Kafka (io.strimzi.api.kafka.model.Kafka)30 ParallelTest (io.strimzi.test.annotations.ParallelTest)30 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)16 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 Container (io.fabric8.kubernetes.api.model.Container)8 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)8 ContainerEnvVar (io.strimzi.api.kafka.model.ContainerEnvVar)8 PodSecurityContextBuilder (io.fabric8.kubernetes.api.model.PodSecurityContextBuilder)6 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)4 SecurityContext (io.fabric8.kubernetes.api.model.SecurityContext)4 SecurityContextBuilder (io.fabric8.kubernetes.api.model.SecurityContextBuilder)4 Capacity (io.strimzi.operator.cluster.model.cruisecontrol.Capacity)4 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)4 Affinity (io.fabric8.kubernetes.api.model.Affinity)2 AffinityBuilder (io.fabric8.kubernetes.api.model.AffinityBuilder)2 ConfigMapKeySelectorBuilder (io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder)2 HostAlias (io.fabric8.kubernetes.api.model.HostAlias)2