Search in sources :

Example 6 with CruiseControlSpecBuilder

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

the class CruiseControlTest method testGoalsCheck.

@ParallelTest
public void testGoalsCheck() {
    String customGoals = "com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal," + "com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal";
    Map<String, Object> customGoalConfig = ccConfig;
    customGoalConfig.put(CRUISE_CONTROL_DEFAULT_GOALS_CONFIG_KEY.getValue(), customGoals);
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withConfig(customGoalConfig).build();
    Kafka resourceWithCustomGoals = createKafka(cruiseControlSpec);
    CruiseControl cruiseControlWithCustomGoals = createCruiseControl(resourceWithCustomGoals);
    String anomalyDetectionGoals = cruiseControlWithCustomGoals.getConfiguration().asOrderedProperties().asMap().get(CRUISE_CONTROL_ANOMALY_DETECTION_CONFIG_KEY.getValue());
    assertThat(anomalyDetectionGoals, is(customGoals));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 7 with CruiseControlSpecBuilder

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

the class KafkaBrokerConfigurationBuilderTest method testCruiseControl.

@ParallelTest
public void testCruiseControl() {
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withCruiseControl("my-cluster", cruiseControlSpec, "1", "1", "1").build();
    assertThat(configuration, containsString(CruiseControlConfigurationParameters.METRICS_TOPIC_NAME + "=strimzi.cruisecontrol.metrics\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_ENDPOINT_ID_ALGO + "=HTTPS\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_BOOTSTRAP_SERVERS + "=my-cluster-kafka-brokers:9091\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SECURITY_PROTOCOL + "=SSL\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_KEYSTORE_TYPE + "=PKCS12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_KEYSTORE_LOCATION + "=/tmp/kafka/cluster.keystore.p12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_KEYSTORE_PASSWORD + "=${CERTS_STORE_PASSWORD}\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_TRUSTSTORE_TYPE + "=PKCS12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_TRUSTSTORE_LOCATION + "=/tmp/kafka/cluster.truststore.p12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_TRUSTSTORE_PASSWORD + "=${CERTS_STORE_PASSWORD}\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_AUTO_CREATE + "=true\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_NUM_PARTITIONS + "=1\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_REPLICATION_FACTOR + "=1\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_MIN_ISR + "=1"));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 8 with CruiseControlSpecBuilder

use of io.strimzi.api.kafka.model.CruiseControlSpecBuilder in project strimzi-kafka-operator by strimzi.

the class KafkaBrokerConfigurationBuilderTest method testCruiseControl.

@ParallelTest
public void testCruiseControl() {
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withCruiseControl("my-cluster", cruiseControlSpec, "1", "1", "1").build();
    assertThat(configuration, containsString(CruiseControlConfigurationParameters.METRICS_TOPIC_NAME + "=strimzi.cruisecontrol.metrics\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_ENDPOINT_ID_ALGO + "=HTTPS\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_BOOTSTRAP_SERVERS + "=my-cluster-kafka-brokers:9091\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SECURITY_PROTOCOL + "=SSL\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_KEYSTORE_TYPE + "=PKCS12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_KEYSTORE_LOCATION + "=/tmp/kafka/cluster.keystore.p12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_KEYSTORE_PASSWORD + "=${CERTS_STORE_PASSWORD}\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_TRUSTSTORE_TYPE + "=PKCS12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_TRUSTSTORE_LOCATION + "=/tmp/kafka/cluster.truststore.p12\n" + CruiseControlConfigurationParameters.METRICS_REPORTER_SSL_TRUSTSTORE_PASSWORD + "=${CERTS_STORE_PASSWORD}\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_AUTO_CREATE + "=true\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_NUM_PARTITIONS + "=1\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_REPLICATION_FACTOR + "=1\n" + CruiseControlConfigurationParameters.METRICS_TOPIC_MIN_ISR + "=1"));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 9 with CruiseControlSpecBuilder

use of io.strimzi.api.kafka.model.CruiseControlSpecBuilder in project strimzi-kafka-operator by strimzi.

the class CruiseControlConfigurationST method testConfigurationPerformanceOptions.

@ParallelNamespaceTest
void testConfigurationPerformanceOptions(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());
    Container cruiseControlContainer;
    EnvVar cruiseControlConfiguration;
    Map<String, String> kafkaSnapShot = PodUtils.podSnapshot(namespaceName, kafkaSelector);
    Map<String, String> cruiseControlSnapShot = DeploymentUtils.depSnapshot(namespaceName, CruiseControlResources.deploymentName(clusterName));
    Map<String, Object> performanceTuningOpts = new HashMap<String, Object>() {

        {
            put(CruiseControlConfigurationParameters.CONCURRENT_INTRA_PARTITION_MOVEMENTS.getValue(), 2);
            put(CruiseControlConfigurationParameters.CONCURRENT_PARTITION_MOVEMENTS.getValue(), 5);
            put(CruiseControlConfigurationParameters.CONCURRENT_LEADER_MOVEMENTS.getValue(), 1000);
            put(CruiseControlConfigurationParameters.REPLICATION_THROTTLE.getValue(), -1);
        }
    };
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        LOGGER.info("Changing cruise control performance tuning options");
        kafka.getSpec().setCruiseControl(new CruiseControlSpecBuilder().addToConfig(performanceTuningOpts).build());
    }, namespaceName);
    LOGGER.info("Verifying that CC pod is rolling, after changing options");
    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");
    Pod cruiseControlPod = kubeClient(namespaceName).listPodsByPrefixInName(namespaceName, clusterName + "-cruise-control-").get(0);
    // Get CruiseControl resource properties
    cruiseControlContainer = cruiseControlPod.getSpec().getContainers().stream().filter(container -> container.getName().equals(Constants.CRUISE_CONTROL_CONTAINER_NAME)).findFirst().orElse(null);
    cruiseControlConfiguration = Objects.requireNonNull(cruiseControlContainer).getEnv().stream().filter(envVar -> envVar.getName().equals(Constants.CRUISE_CONTROL_CONFIGURATION_ENV)).findFirst().orElse(null);
    InputStream configurationContainerStream = new ByteArrayInputStream(Objects.requireNonNull(cruiseControlConfiguration).getValue().getBytes(StandardCharsets.UTF_8));
    Properties containerConfiguration = new Properties();
    containerConfiguration.load(configurationContainerStream);
    LOGGER.info("Verifying Cruise control performance options are set in Kafka CR");
    performanceTuningOpts.forEach((key, value) -> assertThat(containerConfiguration, hasEntry(key, value.toString())));
}
Also used : AbstractST(io.strimzi.systemtest.AbstractST) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Arrays(java.util.Arrays) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) Container(io.fabric8.kubernetes.api.model.Container) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) ParallelSuite(io.strimzi.systemtest.annotations.ParallelSuite) CruiseControlUtils(io.strimzi.systemtest.utils.specific.CruiseControlUtils) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) CoreMatchers.not(org.hamcrest.CoreMatchers.not) HashMap(java.util.HashMap) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) ByteArrayInputStream(java.io.ByteArrayInputStream) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Map(java.util.Map) JsonObject(io.vertx.core.json.JsonObject) Tag(org.junit.jupiter.api.Tag) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) StUtils(io.strimzi.systemtest.utils.StUtils) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) CruiseControlConfigurationParameters(io.strimzi.operator.cluster.operator.resource.cruisecontrol.CruiseControlConfigurationParameters) RollingUpdateUtils(io.strimzi.systemtest.utils.RollingUpdateUtils) WaitException(io.strimzi.test.WaitException) Properties(java.util.Properties) Constants(io.strimzi.systemtest.Constants) Pod(io.fabric8.kubernetes.api.model.Pod) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) IOException(java.io.IOException) StandardCharsets(java.nio.charset.StandardCharsets) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) CruiseControlResources(io.strimzi.api.kafka.model.CruiseControlResources) Objects(java.util.Objects) List(java.util.List) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) Logger(org.apache.logging.log4j.Logger) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) LogManager(org.apache.logging.log4j.LogManager) CRUISE_CONTROL(io.strimzi.systemtest.Constants.CRUISE_CONTROL) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) InputStream(java.io.InputStream) Pod(io.fabric8.kubernetes.api.model.Pod) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Properties(java.util.Properties) Container(io.fabric8.kubernetes.api.model.Container) ByteArrayInputStream(java.io.ByteArrayInputStream) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) JsonObject(io.vertx.core.json.JsonObject) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Example 10 with CruiseControlSpecBuilder

use of io.strimzi.api.kafka.model.CruiseControlSpecBuilder in project strimzi-kafka-operator 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)

Aggregations

CruiseControlSpec (io.strimzi.api.kafka.model.CruiseControlSpec)36 CruiseControlSpecBuilder (io.strimzi.api.kafka.model.CruiseControlSpecBuilder)36 Kafka (io.strimzi.api.kafka.model.Kafka)30 ParallelTest (io.strimzi.test.annotations.ParallelTest)30 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)16 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 Container (io.fabric8.kubernetes.api.model.Container)10 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)10 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 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)3 HashMap (java.util.HashMap)3 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